12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
-
- namespace Gedmo\Mapping\Xml;
-
- use Doctrine\Common\Annotations\AnnotationReader;
- use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
- use Doctrine\Common\EventManager;
- use Doctrine\ORM\Mapping\Driver\DriverChain;
- use Doctrine\ORM\Mapping\Driver\XmlDriver;
- use Gedmo\Tree\TreeListener;
- use Tool\BaseTestCaseOM;
-
-
- class ClosureTreeMappingTest extends BaseTestCaseOM
- {
-
-
- private $em;
-
-
-
- private $tree;
-
- public function setUp()
- {
- parent::setUp();
-
- $reader = new AnnotationReader();
- $annotationDriver = new AnnotationDriver($reader);
-
- $xmlDriver = new XmlDriver(__DIR__.'/../Driver/Xml');
-
- $chain = new DriverChain;
- $chain->addDriver($xmlDriver, 'Mapping\Fixture\Xml');
- $chain->addDriver($annotationDriver, 'Mapping\Fixture');
- $chain->addDriver($annotationDriver, 'Gedmo\Tree');
-
- $this->tree = new TreeListener;
- $this->evm = new EventManager;
- $this->evm->addEventSubscriber($this->tree);
-
- $this->em = $this->getMockSqliteEntityManager(array(
- 'Mapping\Fixture\Xml\ClosureTree',
- 'Mapping\Fixture\ClosureTreeClosure'
- ), $chain);
- }
-
- public function testTreeMetadata()
- {
- $meta = $this->em->getClassMetadata('Mapping\Fixture\Xml\ClosureTree');
- $config = $this->tree->getConfiguration($this->em, $meta->name);
-
- $this->assertArrayHasKey('strategy', $config);
- $this->assertEquals('closure', $config['strategy']);
- $this->assertArrayHasKey('closure', $config);
- $this->assertEquals('Mapping\Fixture\ClosureTreeClosure', $config['closure']);
- $this->assertArrayHasKey('parent', $config);
- $this->assertEquals('parent', $config['parent']);
- }
- }
|