|
@@ -6,6 +6,7 @@ use Doctrine\Common\EventManager;
|
|
use Tool\BaseTestCaseORM;
|
|
use Tool\BaseTestCaseORM;
|
|
use Doctrine\Common\Util\Debug;
|
|
use Doctrine\Common\Util\Debug;
|
|
use Tree\Fixture\Closure\Category;
|
|
use Tree\Fixture\Closure\Category;
|
|
|
|
+use Tree\Fixture\Closure\News;
|
|
use Tree\Fixture\Closure\CategoryClosure;
|
|
use Tree\Fixture\Closure\CategoryClosure;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -24,6 +25,7 @@ class ClosureTreeTest extends BaseTestCaseORM
|
|
const PERSON = "Tree\\Fixture\\Closure\\Person";
|
|
const PERSON = "Tree\\Fixture\\Closure\\Person";
|
|
const USER = "Tree\\Fixture\\Closure\\User";
|
|
const USER = "Tree\\Fixture\\Closure\\User";
|
|
const PERSON_CLOSURE = "Tree\\Fixture\\Closure\\PersonClosure";
|
|
const PERSON_CLOSURE = "Tree\\Fixture\\Closure\\PersonClosure";
|
|
|
|
+ const NEWS = "Tree\\Fixture\\Closure\\News";
|
|
|
|
|
|
protected function setUp()
|
|
protected function setUp()
|
|
{
|
|
{
|
|
@@ -229,7 +231,8 @@ class ClosureTreeTest extends BaseTestCaseORM
|
|
self::CLOSURE,
|
|
self::CLOSURE,
|
|
self::PERSON,
|
|
self::PERSON,
|
|
self::PERSON_CLOSURE,
|
|
self::PERSON_CLOSURE,
|
|
- self::USER
|
|
|
|
|
|
+ self::USER,
|
|
|
|
+ self::NEWS
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -296,4 +299,24 @@ class ClosureTreeTest extends BaseTestCaseORM
|
|
|
|
|
|
$this->em->flush();
|
|
$this->em->flush();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function testCascadePersistTree()
|
|
|
|
+ {
|
|
|
|
+ $politics = new Category();
|
|
|
|
+ $politics->setTitle('Politics');
|
|
|
|
+
|
|
|
|
+ $news = new News('Lorem ipsum', $politics);
|
|
|
|
+ $this->em->persist($news);
|
|
|
|
+ $this->em->flush();
|
|
|
|
+
|
|
|
|
+ $closure = $this->em->createQueryBuilder()
|
|
|
|
+ ->select('c')
|
|
|
|
+ ->from(self::CLOSURE, 'c')
|
|
|
|
+ ->where('c.ancestor = :ancestor')
|
|
|
|
+ ->setParameter('ancestor', $politics->getId())
|
|
|
|
+ ->getQuery()
|
|
|
|
+ ->getResult();
|
|
|
|
+
|
|
|
|
+ $this->assertEquals(1, count($closure));
|
|
|
|
+ }
|
|
}
|
|
}
|