MaterializedPathTreeMappingTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace Gedmo\Mapping\Xml;
  3. use Doctrine\Common\Annotations\AnnotationReader;
  4. use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
  5. use Doctrine\Common\EventManager;
  6. use Doctrine\ORM\Mapping\Driver\DriverChain;
  7. use Doctrine\ORM\Mapping\Driver\XmlDriver;
  8. use Gedmo\Tree\TreeListener;
  9. use Tool\BaseTestCaseOM;
  10. /**
  11. * These are mapping extension tests
  12. *
  13. * @author Gustavo Falco <comfortablynumb84@gmail.com>
  14. * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  15. * @link http://www.gediminasm.org
  16. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  17. */
  18. class MaterializedPathTreeMappingTest extends BaseTestCaseOM
  19. {
  20. /**
  21. * @var Doctrine\ORM\EntityManager
  22. */
  23. private $em;
  24. /**
  25. * @var Gedmo\Tree\TreeListener
  26. */
  27. private $tree;
  28. public function setUp()
  29. {
  30. parent::setUp();
  31. $reader = new AnnotationReader();
  32. $annotationDriver = new AnnotationDriver($reader);
  33. $xmlDriver = new XmlDriver(__DIR__.'/../Driver/Xml');
  34. $chain = new DriverChain;
  35. $chain->addDriver($xmlDriver, 'Mapping\Fixture\Xml');
  36. $chain->addDriver($annotationDriver, 'Mapping\Fixture');
  37. $chain->addDriver($annotationDriver, 'Gedmo\Tree');
  38. $this->tree = new TreeListener;
  39. $this->evm = new EventManager;
  40. $this->evm->addEventSubscriber($this->tree);
  41. $this->em = $this->getMockSqliteEntityManager(array(
  42. 'Mapping\Fixture\Xml\MaterializedPathTree'
  43. ), $chain);
  44. }
  45. public function testTreeMetadata()
  46. {
  47. $meta = $this->em->getClassMetadata('Mapping\Fixture\Xml\MaterializedPathTree');
  48. $config = $this->tree->getConfiguration($this->em, $meta->name);
  49. $this->assertArrayHasKey('strategy', $config);
  50. $this->assertEquals('materializedPath', $config['strategy']);
  51. $this->assertArrayHasKey('activate_locking', $config);
  52. $this->assertTrue($config['activate_locking']);
  53. $this->assertArrayHasKey('locking_timeout', $config);
  54. $this->assertEquals(10, $config['locking_timeout']);
  55. $this->assertArrayHasKey('level', $config);
  56. $this->assertEquals('level', $config['level']);
  57. $this->assertArrayHasKey('parent', $config);
  58. $this->assertEquals('parent', $config['parent']);
  59. $this->assertArrayHasKey('path_source', $config);
  60. $this->assertEquals('title', $config['path_source']);
  61. $this->assertArrayHasKey('path', $config);
  62. $this->assertEquals('path', $config['path']);
  63. $this->assertArrayHasKey('lock_time', $config);
  64. $this->assertEquals('lockTime', $config['lock_time']);
  65. }
  66. }