SMExtensionSpec.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace spec\SM\Extension\Twig;
  3. use PhpSpec\ObjectBehavior;
  4. use Prophecy\Argument;
  5. use SM\Factory\FactoryInterface;
  6. use SM\StateMachine\StateMachineInterface;
  7. use spec\SM\DummyObject;
  8. class SMExtensionSpec extends ObjectBehavior
  9. {
  10. function let(FactoryInterface $factory, StateMachineInterface $stateMachine)
  11. {
  12. $this->beConstructedWith($factory);
  13. $factory->get(new DummyObject(), 'simple')->willReturn($stateMachine);
  14. }
  15. function it_is_initializable()
  16. {
  17. $this->shouldHaveType('SM\Extension\Twig\SMExtension');
  18. }
  19. function it_is_a_twig_extension()
  20. {
  21. $this->shouldBeAnInstanceOf('\Twig_Extension');
  22. }
  23. function it_should_have_a_name()
  24. {
  25. $this->getName()->shouldReturn('sm');
  26. }
  27. function it_provide_sm_can_function(FactoryInterface $factory, StateMachineInterface $stateMachine)
  28. {
  29. $this->can($object = new DummyObject(), 'new', 'simple');
  30. $factory->get($object, 'simple')->shouldHaveBeenCalled();
  31. $stateMachine->can('new')->shouldHaveBeenCalled();
  32. }
  33. function it_provide_sm_getState_function(FactoryInterface $factory, StateMachineInterface $stateMachine)
  34. {
  35. $this->getState($object = new DummyObject(), 'simple');
  36. $factory->get($object, 'simple')->shouldHaveBeenCalled();
  37. $stateMachine->getState()->shouldHaveBeenCalled();
  38. }
  39. function it_provide_sm_getPossibleTransitions_function(FactoryInterface $factory, StateMachineInterface $stateMachine)
  40. {
  41. $this->getPossibleTransitions($object = new DummyObject(), 'simple');
  42. $factory->get($object, 'simple')->shouldHaveBeenCalled();
  43. $stateMachine->getPossibleTransitions()->shouldHaveBeenCalled();
  44. }
  45. }