AnnotationValidationTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Gedmo\Sluggable;
  3. use Doctrine\Common\EventManager;
  4. use Tool\BaseTestCaseORM;
  5. use Sluggable\Fixture\Validate;
  6. /**
  7. * These are tests for Sluggable behavior
  8. *
  9. * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  10. * @link http://www.gediminasm.org
  11. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  12. */
  13. class AnnotationValidationTest extends BaseTestCaseORM
  14. {
  15. const TARGET = 'Sluggable\\Fixture\\Validate';
  16. /**
  17. * @test
  18. * @expectedException Gedmo\Exception\InvalidMappingException
  19. */
  20. function shouldFailValidationOnInvalidAnnotation()
  21. {
  22. $evm = new EventManager;
  23. $evm->addEventSubscriber(new SluggableListener);
  24. $this->getMockSqliteEntityManager($evm);
  25. $slug = new Validate;
  26. $slug->setTitle('My Slug');
  27. $slug2 = new Validate;
  28. $slug2->setTitle('My Slug');
  29. $this->em->persist($slug);
  30. $this->em->persist($slug2);
  31. $this->em->flush();
  32. $this->assertEquals('my-slug', $slug2->getSlug());
  33. }
  34. protected function getUsedEntityFixtures()
  35. {
  36. return array(
  37. self::TARGET
  38. );
  39. }
  40. }