NestedTreeMappingTest.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace Gedmo\Mapping\Xml;
  3. use Doctrine\Common\EventManager;
  4. use Doctrine\ORM\Mapping\Driver\DriverChain;
  5. use Doctrine\ORM\Mapping\Driver\XmlDriver;
  6. use Gedmo\Tree\TreeListener;
  7. use Tool\BaseTestCaseOM;
  8. /**
  9. * These are mapping extension tests
  10. *
  11. * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  12. * @link http://www.gediminasm.org
  13. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  14. */
  15. class NestedTreeMappingTest extends BaseTestCaseOM
  16. {
  17. /**
  18. * @var Doctrine\ORM\EntityManager
  19. */
  20. private $em;
  21. /**
  22. * @var Gedmo\Tree\TreeListener
  23. */
  24. private $tree;
  25. public function setUp()
  26. {
  27. parent::setUp();
  28. $xmlDriver = new XmlDriver(__DIR__.'/../Driver/Xml');
  29. $chain = new DriverChain;
  30. $chain->addDriver($xmlDriver, 'Mapping\Fixture\Xml');
  31. $this->tree = new TreeListener;
  32. $this->evm = new EventManager;
  33. $this->evm->addEventSubscriber($this->tree);
  34. $this->em = $this->getMockSqliteEntityManager(array(
  35. 'Mapping\Fixture\Xml\NestedTree',
  36. ), $chain);
  37. }
  38. public function testTreeMetadata()
  39. {
  40. $meta = $this->em->getClassMetadata('Mapping\Fixture\Xml\NestedTree');
  41. $config = $this->tree->getConfiguration($this->em, $meta->name);
  42. $this->assertArrayHasKey('strategy', $config);
  43. $this->assertEquals('nested', $config['strategy']);
  44. $this->assertArrayHasKey('left', $config);
  45. $this->assertEquals('left', $config['left']);
  46. $this->assertArrayHasKey('right', $config);
  47. $this->assertEquals('right', $config['right']);
  48. $this->assertArrayHasKey('level', $config);
  49. $this->assertEquals('level', $config['level']);
  50. $this->assertArrayHasKey('root', $config);
  51. $this->assertEquals('root', $config['root']);
  52. $this->assertArrayHasKey('parent', $config);
  53. $this->assertEquals('parent', $config['parent']);
  54. }
  55. }