Skip to content

Instantly share code, notes, and snippets.

@ssmusoke
Created May 16, 2012 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssmusoke/2707681 to your computer and use it in GitHub Desktop.
Save ssmusoke/2707681 to your computer and use it in GitHub Desktop.
Test case for Cascading Tree Saves from root to child
function testTheTreeWithCascadesForRootandOneChild() {
$meta = $this->em->getClassMetadata(self::CATEGORY);
$root = new Category();
$root->setTitle("Root");
$this->assertTrue($root instanceof Node);
$child = new Category();
$child->setTitle("child");
$child->setParent($root);
$this->em->persist($child);
$this->em->flush();
$this->em->clear();
$root = $this->em->getRepository(self::CATEGORY)->find(1);
$left = $meta->getReflectionProperty('lft')->getValue($root);
$right = $meta->getReflectionProperty('rgt')->getValue($root);
$level = $meta->getReflectionProperty('level')->getValue($root);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment