Spaces:
No application file
No application file
declare(strict_types=1); | |
namespace Mautic\CampaignBundle\Tests\Executioner\Dispatcher; | |
use Mautic\CampaignBundle\CampaignEvents; | |
use Mautic\CampaignBundle\Entity\LeadEventLog; | |
use Mautic\CampaignBundle\Event\ConditionEvent; | |
use Mautic\CampaignBundle\EventCollector\Accessor\Event\ConditionAccessor; | |
use Mautic\CampaignBundle\Executioner\Dispatcher\ConditionDispatcher; | |
use PHPUnit\Framework\MockObject\MockObject; | |
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | |
class ConditionDispatcherTest extends \PHPUnit\Framework\TestCase | |
{ | |
/** | |
* @var MockObject|EventDispatcherInterface | |
*/ | |
private MockObject $dispatcher; | |
/** | |
* @var MockObject|ConditionAccessor | |
*/ | |
private MockObject $config; | |
protected function setUp(): void | |
{ | |
parent::setUp(); | |
$this->dispatcher = $this->createMock(EventDispatcherInterface::class); | |
$this->config = $this->createMock(ConditionAccessor::class); | |
} | |
public function testConditionEventIsDispatched(): void | |
{ | |
$this->config->expects($this->once()) | |
->method('getEventName') | |
->willReturn('something'); | |
$this->dispatcher->expects($this->exactly(2)) | |
->method('dispatch') | |
->withConsecutive( | |
[$this->isInstanceOf(ConditionEvent::class), 'something'], | |
[$this->isInstanceOf(ConditionEvent::class), CampaignEvents::ON_EVENT_CONDITION_EVALUATION] | |
); | |
(new ConditionDispatcher($this->dispatcher))->dispatchEvent($this->config, new LeadEventLog()); | |
} | |
} | |