Issue116Test.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. * @package Gedmo.Sluggable
  13. * @link http://www.gediminasm.org
  14. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  15. */
  16. class Issue116Test extends BaseTestCaseORM
  17. {
  18. const TARGET = 'Sluggable\\Fixture\\Issue116\\Country';
  19. protected function setUp()
  20. {
  21. parent::setUp();
  22. $evm = new EventManager;
  23. $evm->addEventSubscriber(new SluggableListener);
  24. $this->getMockSqliteEntityManager($evm);
  25. }
  26. protected function getMetadataDriverImplementation()
  27. {
  28. $chain = new DriverChain;
  29. $chain->addDriver(
  30. new YamlDriver(array(__DIR__ . '/../Fixture/Issue116/Mapping')),
  31. 'Sluggable\Fixture\Issue116'
  32. );
  33. return $chain;
  34. }
  35. public function testSlugGeneration()
  36. {
  37. $country = new Country;
  38. $country->setOriginalName('New Zealand');
  39. $this->em->persist($country);
  40. $this->em->flush();
  41. $this->assertEquals('new-zealand', $country->getAlias());
  42. }
  43. protected function getUsedEntityFixtures()
  44. {
  45. return array(
  46. self::TARGET
  47. );
  48. }
  49. }