MappingTest.php 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace Gedmo\Mapping;
  3. use Doctrine\Common\Util\Debug,
  4. Tree\Fixture\BehavioralCategory,
  5. Gedmo\Mapping\ExtensionMetadataFactory;
  6. /**
  7. * These are mapping extension tests
  8. *
  9. * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  10. * @package Gedmo.Mapping
  11. * @link http://www.gediminasm.org
  12. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  13. */
  14. class MappingTest extends \PHPUnit_Framework_TestCase
  15. {
  16. const TEST_ENTITY_CATEGORY = "Tree\Fixture\BehavioralCategory";
  17. const TEST_ENTITY_TRANSLATION = "Gedmo\Translatable\Entity\Translation";
  18. private $em;
  19. private $timestampable;
  20. public function setUp()
  21. {
  22. $config = new \Doctrine\ORM\Configuration();
  23. $config->setProxyDir(TESTS_TEMP_DIR);
  24. $config->setProxyNamespace('Gedmo\Mapping\Proxy');
  25. //$this->markTestSkipped('Skipping according to a bug in annotation reader creation.');
  26. $config->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($_ENV['annotation_reader']));
  27. $conn = array(
  28. 'driver' => 'pdo_sqlite',
  29. 'memory' => true,
  30. );
  31. $evm = new \Doctrine\Common\EventManager();
  32. $evm->addEventSubscriber(new \Gedmo\Translatable\TranslatableListener());
  33. $this->timestampable = new \Gedmo\Timestampable\TimestampableListener();
  34. $evm->addEventSubscriber($this->timestampable);
  35. $evm->addEventSubscriber(new \Gedmo\Sluggable\SluggableListener());
  36. $evm->addEventSubscriber(new \Gedmo\Tree\TreeListener());
  37. $this->em = \Doctrine\ORM\EntityManager::create($conn, $config, $evm);
  38. $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
  39. $schemaTool->dropSchema(array());
  40. $schemaTool->createSchema(array(
  41. $this->em->getClassMetadata(self::TEST_ENTITY_CATEGORY),
  42. $this->em->getClassMetadata(self::TEST_ENTITY_TRANSLATION)
  43. ));
  44. }
  45. public function testNoCacheImplementationMapping()
  46. {
  47. $food = new BehavioralCategory();
  48. $food->setTitle('Food');
  49. $this->em->persist($food);
  50. $this->em->flush();
  51. // assertion checks if configuration is read correctly without cache driver
  52. $conf = $this->timestampable->getConfiguration(
  53. $this->em,
  54. self::TEST_ENTITY_CATEGORY
  55. );
  56. $this->assertCount(0, $conf);
  57. }
  58. }