ResourceEventSpec.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace spec\Sylius\Component\Resource\Event;
  3. use PhpSpec\ObjectBehavior;
  4. use Prophecy\Argument;
  5. use Sylius\Component\Resource\Event\ResourceEvent;
  6. class ResourceEventSpec extends ObjectBehavior
  7. {
  8. function let()
  9. {
  10. $this->beConstructedWith('message');
  11. }
  12. function it_is_initializable()
  13. {
  14. $this->shouldHaveType('Sylius\Component\Resource\Event\ResourceEvent');
  15. }
  16. function it_stops_event_propagation()
  17. {
  18. $this->stop('message', ResourceEvent::TYPE_SUCCESS, array('parameter'));
  19. $this->getMessageType()->shouldReturn(ResourceEvent::TYPE_SUCCESS);
  20. $this->getMessageParameters()->shouldReturn(array('parameter'));
  21. $this->getMessage()->shouldReturn('message');
  22. $this->isPropagationStopped()->shouldReturn(true);
  23. }
  24. function it_check_if_an_error_has_been_detected()
  25. {
  26. $this->isStopped()->shouldReturn(false);
  27. $this->stop('message');
  28. $this->isStopped()->shouldReturn(true);
  29. }
  30. function it_has_not_message_type_by_default()
  31. {
  32. $this->getMessageType()->shouldReturn('');
  33. }
  34. function its_message_type_is_mutable()
  35. {
  36. $this->setMessageType(ResourceEvent::TYPE_SUCCESS)->shouldReturn($this);
  37. $this->getMessageType()->shouldReturn(ResourceEvent::TYPE_SUCCESS);
  38. }
  39. function it_has_not_message_by_default()
  40. {
  41. $this->getMessage()->shouldReturn('');
  42. }
  43. function its_message_is_mutable()
  44. {
  45. $this->setMessage('message')->shouldReturn($this);
  46. $this->getMessage()->shouldReturn('message');
  47. }
  48. function it_has_not_message_parameter_by_default()
  49. {
  50. $this->getMessageParameters()->shouldReturn(array());
  51. }
  52. function its_message_parameter_is_mutable()
  53. {
  54. $this->setMessageParameters(array('parameters'))->shouldReturn($this);
  55. $this->getMessageParameters()->shouldReturn(array('parameters'));
  56. }
  57. }