SluggablePrefixSuffixTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Created by Dirk Luijk (dirk@luijkwebcreations.nl)
  4. * 2013
  5. */
  6. namespace Gedmo\Sluggable;
  7. use Doctrine\Common\EventManager;
  8. use Sluggable\Fixture\Prefix;
  9. use Sluggable\Fixture\Suffix;
  10. use Tool\BaseTestCaseORM;
  11. class SluggablePrefixSuffixTest extends BaseTestCaseORM {
  12. const PREFIX = 'Sluggable\\Fixture\\Prefix';
  13. const SUFFIX = 'Sluggable\\Fixture\\Suffix';
  14. protected function setUp()
  15. {
  16. parent::setUp();
  17. $evm = new EventManager;
  18. $evm->addEventSubscriber(new SluggableListener);
  19. $this->getMockSqliteEntityManager($evm);
  20. }
  21. /**
  22. * @test
  23. */
  24. function testPrefix()
  25. {
  26. $foo = new Prefix();
  27. $foo->setTitle('Bar');
  28. $this->em->persist($foo);
  29. $this->em->flush();
  30. $this->assertEquals('test-bar', $foo->getSlug());
  31. }
  32. /**
  33. * @test
  34. */
  35. function testSuffix()
  36. {
  37. $foo = new Suffix();
  38. $foo->setTitle('Bar');
  39. $this->em->persist($foo);
  40. $this->em->flush();
  41. $this->assertEquals('bar.test', $foo->getSlug());
  42. }
  43. /**
  44. * Get a list of used fixture classes
  45. *
  46. * @return array
  47. */
  48. protected function getUsedEntityFixtures()
  49. {
  50. return array(
  51. self::SUFFIX,
  52. self::PREFIX,
  53. );
  54. }
  55. }