mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
Added event tests
This commit is contained in:
parent
137dd0ceaf
commit
c1044c8aa8
2 changed files with 96 additions and 0 deletions
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\FlowBundle\Tests\EventDispatcher\Event;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Sylius\Bundle\FlowBundle\EventDispatcher\SyliusFlowEvents;
|
||||
use Sylius\Bundle\FlowBundle\EventDispatcher\Event\FilterProcessEvent;
|
||||
|
||||
/**
|
||||
* FilterProcessEvent test.
|
||||
*
|
||||
* @author Leszek Prabucki <leszek.prabucki@gmail.com>
|
||||
*/
|
||||
class FilterProcessEventTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
* @covers Sylius\Bundle\FlowBundle\EventDispatcher\Event\FilterProcessEvent
|
||||
* @covers Sylius\Bundle\FlowBundle\EventDispatcher\SyliusFlowEvents
|
||||
*/
|
||||
public function shouldDispatchFilterProcessEvent()
|
||||
{
|
||||
$process = $this->getProcess();
|
||||
$testCase = $this;
|
||||
$dispatcher = new EventDispatcher();
|
||||
|
||||
$dispatcher->addListener('sylius_flow.event.process.start', function (FilterProcessEvent $event) use ($testCase, $process) {
|
||||
$testCase->assertSame($process, $event->getProcess());
|
||||
});
|
||||
|
||||
$event = new FilterProcessEvent($process);
|
||||
$dispatcher->dispatch(SyliusFlowEvents::PROCESS_START, $event);
|
||||
}
|
||||
|
||||
private function getProcess()
|
||||
{
|
||||
return $this->getMock('Sylius\Bundle\FlowBundle\Process\ProcessInterface');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\FlowBundle\Tests\EventDispatcher\Event;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Sylius\Bundle\FlowBundle\EventDispatcher\SyliusFlowEvents;
|
||||
use Sylius\Bundle\FlowBundle\EventDispatcher\Event\FilterStepEvent;
|
||||
|
||||
/**
|
||||
* FilterStepEvent test.
|
||||
*
|
||||
* @author Leszek Prabucki <leszek.prabucki@gmail.com>
|
||||
*/
|
||||
class FilterStepEventTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
* @covers Sylius\Bundle\FlowBundle\EventDispatcher\Event\FilterStepEvent
|
||||
* @covers Sylius\Bundle\FlowBundle\EventDispatcher\SyliusFlowEvents
|
||||
*/
|
||||
public function shouldDispatchFilterStepEvent()
|
||||
{
|
||||
$step = $this->getStep();
|
||||
$testCase = $this;
|
||||
$dispatcher = new EventDispatcher();
|
||||
|
||||
$dispatcher->addListener('sylius_flow.event.step.display', function (FilterStepEvent $event) use ($testCase, $step) {;
|
||||
$testCase->assertSame($step, $event->getStep());
|
||||
});
|
||||
|
||||
$event = new FilterStepEvent($step);
|
||||
$dispatcher->dispatch(SyliusFlowEvents::STEP_DISPLAY, $event);
|
||||
}
|
||||
|
||||
private function getStep()
|
||||
{
|
||||
return $this->getMock('Sylius\Bundle\FlowBundle\Process\Step\StepInterface');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue