Issue116Test.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Gedmo\Sluggable;
  3. use Doctrine\Common\EventManager;
  4. use Tool\BaseTestCaseORM;
  5. use Sluggable\Fixture\Issue116\Country;
  6. use Doctrine\ORM\Mapping\Driver\YamlDriver;
  7. use Doctrine\ORM\Mapping\Driver\DriverChain;
  8. /**
  9. * These are tests for Sluggable behavior
  10. *
  11. * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  12. * @link http://www.gediminasm.org
  13. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  14. */
  15. class Issue116Test extends BaseTestCaseORM
  16. {
  17. const TARGET = 'Sluggable\\Fixture\\Issue116\\Country';
  18. protected function setUp()
  19. {
  20. parent::setUp();
  21. $evm = new EventManager;
  22. $evm->addEventSubscriber(new SluggableListener);
  23. $this->getMockSqliteEntityManager($evm);
  24. }
  25. protected function getMetadataDriverImplementation()
  26. {
  27. $chain = new DriverChain;
  28. $chain->addDriver(
  29. new YamlDriver(array(__DIR__ . '/../Fixture/Issue116/Mapping')),
  30. 'Sluggable\Fixture\Issue116'
  31. );
  32. return $chain;
  33. }
  34. public function testSlugGeneration()
  35. {
  36. $country = new Country;
  37. $country->setOriginalName('New Zealand');
  38. $this->em->persist($country);
  39. $this->em->flush();
  40. $this->assertEquals('new-zealand', $country->getAlias());
  41. }
  42. protected function getUsedEntityFixtures()
  43. {
  44. return array(
  45. self::TARGET
  46. );
  47. }
  48. }