AnnotationValidationTest.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. * @package Gedmo.Sluggable
  11. * @link http://www.gediminasm.org
  12. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  13. */
  14. class AnnotationValidationTest extends BaseTestCaseORM
  15. {
  16. const TARGET = 'Sluggable\\Fixture\\Validate';
  17. /**
  18. * @test
  19. * @expectedException Gedmo\Exception\InvalidMappingException
  20. */
  21. function shouldFailValidationOnInvalidAnnotation()
  22. {
  23. $evm = new EventManager;
  24. $evm->addEventSubscriber(new SluggableListener);
  25. $this->getMockSqliteEntityManager($evm);
  26. $slug = new Validate;
  27. $slug->setTitle('My Slug');
  28. $slug2 = new Validate;
  29. $slug2->setTitle('My Slug');
  30. $this->em->persist($slug);
  31. $this->em->persist($slug2);
  32. $this->em->flush();
  33. $this->assertEquals('my-slug', $slug2->getSlug());
  34. }
  35. protected function getUsedEntityFixtures()
  36. {
  37. return array(
  38. self::TARGET
  39. );
  40. }
  41. }