| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 | 
							- <?php
 - 
 - namespace Gedmo\Tree;
 - 
 - use Doctrine\Common\EventManager;
 - use Tool\BaseTestCaseORM;
 - use Doctrine\Common\Util\Debug;
 - 
 - /**
 -  * These are tests for Tree behavior
 -  *
 -  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
 -  * @package Gedmo.Tree
 -  * @link http://www.gediminasm.org
 -  * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
 -  */
 - class MultiInheritanceTest extends BaseTestCaseORM
 - {
 -     const NODE = "Tree\\Fixture\\Node";
 -     const BASE_NODE = "Tree\\Fixture\\BaseNode";
 -     const ANODE = "Tree\\Fixture\\ANode";
 -     const TRANSLATION = "Gedmo\\Translatable\\Entity\\Translation";
 - 
 -     protected function setUp()
 -     {
 -         parent::setUp();
 - 
 -         $this->getMockSqliteEntityManager();
 -         $this->populate();
 -     }
 - 
 -     public function testInheritance()
 -     {
 -         $meta = $this->em->getClassMetadata(self::NODE);
 -         $repo = $this->em->getRepository(self::NODE);
 - 
 -         $food = $repo->findOneByIdentifier('food');
 -         $left = $meta->getReflectionProperty('lft')->getValue($food);
 -         $right = $meta->getReflectionProperty('rgt')->getValue($food);
 - 
 -         $this->assertEquals(1, $left);
 -         $this->assertNotNull($food->getCreated());
 -         $this->assertNotNull($food->getUpdated());
 - 
 -         $translationRepo = $this->em->getRepository(self::TRANSLATION);
 -         $translations = $translationRepo->findTranslations($food);
 - 
 -         $this->assertCount(0, $translations);
 -         $this->assertEquals('food', $food->getSlug());
 -     }
 - 
 -     /**
 -      * Test case for github issue#7
 -      * Child count is invalid resulting in SINGLE_TABLE and JOINED
 -      * inheritance mapping. Also getChildren, getPath results are invalid
 -      */
 -     public function testCaseGithubIssue7()
 -     {
 -         $repo = $this->em->getRepository(self::NODE);
 -         $vegies = $repo->findOneByTitle('Vegitables');
 - 
 -         $count = $repo->childCount($vegies, true/*direct*/);
 -         $this->assertEquals(3, $count);
 - 
 -         $children = $repo->children($vegies, true);
 -         $this->assertCount(3, $children);
 - 
 -         // node repository will not find it
 -         $baseNodeRepo = $this->em->getRepository(self::BASE_NODE);
 -         $cabbage = $baseNodeRepo->findOneByIdentifier('cabbage');
 -         $path = $baseNodeRepo->getPath($cabbage);
 -         $this->assertCount(3, $path);
 -     }
 - 
 -     protected function getUsedEntityFixtures()
 -     {
 -         return array(
 -             self::NODE,
 -             self::ANODE,
 -             self::TRANSLATION,
 -             self::BASE_NODE
 -         );
 -     }
 - 
 -     private function populate()
 -     {
 -         $root = new \Tree\Fixture\Node();
 -         $root->setTitle("Food");
 -         $root->setIdentifier('food');
 - 
 -         $root2 = new \Tree\Fixture\Node();
 -         $root2->setTitle("Sports");
 -         $root2->setIdentifier('sport');
 - 
 -         $child = new \Tree\Fixture\Node();
 -         $child->setTitle("Fruits");
 -         $child->setParent($root);
 -         $child->setIdentifier('fruit');
 - 
 -         $child2 = new \Tree\Fixture\Node();
 -         $child2->setTitle("Vegitables");
 -         $child2->setParent($root);
 -         $child2->setIdentifier('vegie');
 - 
 -         $childsChild = new \Tree\Fixture\Node();
 -         $childsChild->setTitle("Carrots");
 -         $childsChild->setParent($child2);
 -         $childsChild->setIdentifier('carrot');
 - 
 -         $potatoes = new \Tree\Fixture\Node();
 -         $potatoes->setTitle("Potatoes");
 -         $potatoes->setParent($child2);
 -         $potatoes->setIdentifier('potatoe');
 - 
 -         $cabbages = new \Tree\Fixture\BaseNode();
 -         $cabbages->setIdentifier('cabbage');
 -         $cabbages->setParent($child2);
 - 
 -         $this->em->persist($root);
 -         $this->em->persist($root2);
 -         $this->em->persist($child);
 -         $this->em->persist($child2);
 -         $this->em->persist($childsChild);
 -         $this->em->persist($potatoes);
 -         $this->em->persist($cabbages);
 -         $this->em->flush();
 -         $this->em->clear();
 -     }
 - }
 
 
  |