|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Bridge\Twig\Tests\Extension; |
| 13 | + |
| 14 | +use Symfony\Bridge\Twig\Extension\WorkflowExtension; |
| 15 | +use Symfony\Component\Workflow\Definition; |
| 16 | +use Symfony\Component\Workflow\Marking; |
| 17 | +use Symfony\Component\Workflow\Registry; |
| 18 | +use Symfony\Component\Workflow\Transition; |
| 19 | +use Symfony\Component\Workflow\Workflow; |
| 20 | + |
| 21 | +class WorkflowExtensionTest extends \PHPUnit_Framework_TestCase |
| 22 | +{ |
| 23 | + protected function setUp() |
| 24 | + { |
| 25 | + parent::setUp(); |
| 26 | + |
| 27 | + if (!class_exists('Symfony\Component\Workflow\Workflow')) { |
| 28 | + $this->markTestSkipped('The Workflow component is needed to run tests for this extension.'); |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + public function testHasPlace() |
| 33 | + { |
| 34 | + $subject = new \stdClass(); |
| 35 | + |
| 36 | + $marking = new Marking(array('ordered' => true, 'waiting_for_payment' => true)); |
| 37 | + |
| 38 | + $workflow = $this->getMock(Workflow::class, array(), array(), '', false); |
| 39 | + $workflow->expects($this->exactly(3)) |
| 40 | + ->method('getMarking') |
| 41 | + ->with($subject) |
| 42 | + ->will($this->returnValue($marking)); |
| 43 | + |
| 44 | + $registry = $this->getMock(Registry::class); |
| 45 | + $registry->expects($this->exactly(3)) |
| 46 | + ->method('get') |
| 47 | + ->with($subject) |
| 48 | + ->will($this->returnValue($workflow)); |
| 49 | + |
| 50 | + $extension = new WorkflowExtension($registry); |
| 51 | + |
| 52 | + $this->assertTrue($extension->hasPlace($subject, 'ordered')); |
| 53 | + $this->assertTrue($extension->hasPlace($subject, 'waiting_for_payment')); |
| 54 | + $this->assertFalse($extension->hasPlace($subject, 'processed')); |
| 55 | + } |
| 56 | +} |
0 commit comments