AbstractTranslationSpec.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace spec\Sylius\Component\Translation\Model;
  3. use PhpSpec\ObjectBehavior;
  4. use Prophecy\Argument;
  5. use Sylius\Component\Translation\Model\TranslatableInterface;
  6. use Sylius\Component\Translation\Model\AbstractTranslation;
  7. class AbstractTranslationSpec extends ObjectBehavior
  8. {
  9. function let()
  10. {
  11. $this->beAnInstanceOf('spec\Sylius\Component\Translation\Model\ConcreteTranslation');
  12. }
  13. function it_is_a_translation()
  14. {
  15. $this->shouldImplement('Sylius\Component\Translation\Model\TranslationInterface');
  16. }
  17. function its_translatable_is_mutabale(TranslatableInterface $translatable)
  18. {
  19. $this->setTranslatable($translatable)->shouldReturn($this);
  20. $this->getTranslatable()->shouldReturn($translatable);
  21. }
  22. function its_detaches_from_its_translatable_correctly(
  23. TranslatableInterface $translatable1,
  24. TranslatableInterface $translatable2
  25. ) {
  26. $translatable1->addTranslation(Argument::type('Sylius\Component\Translation\Model\AbstractTranslation'));
  27. $this->setTranslatable($translatable1);
  28. $translatable1->removeTranslation(Argument::type('Sylius\Component\Translation\Model\AbstractTranslation'));
  29. $translatable2->addTranslation(Argument::type('Sylius\Component\Translation\Model\AbstractTranslation'));
  30. $this->setTranslatable($translatable2);
  31. }
  32. function its_locale_is_mutable()
  33. {
  34. $this->setLocale('en')->shouldReturn($this);
  35. $this->getLocale()->shouldReturn('en');
  36. }
  37. }
  38. class ConcreteTranslation extends AbstractTranslation
  39. {
  40. }