Exemple #1
0
 public function testChangeTracking()
 {
     $parent = new DDC1690Parent();
     $child = new DDC1690Child();
     $parent->setName('parent');
     $child->setName('child');
     $parent->setChild($child);
     $child->setParent($parent);
     $this->_em->persist($parent);
     $this->_em->persist($child);
     $this->assertEquals(1, count($parent->listeners));
     $this->assertEquals(1, count($child->listeners));
     $this->_em->flush();
     $this->_em->clear();
     $this->assertEquals(1, count($parent->listeners));
     $this->assertEquals(1, count($child->listeners));
     $parentId = $parent->getId();
     $childId = $child->getId();
     unset($parent, $child);
     $parent = $this->_em->find(__NAMESPACE__ . '\\DDC1690Parent', $parentId);
     $child = $this->_em->find(__NAMESPACE__ . '\\DDC1690Child', $childId);
     $this->assertEquals(1, count($parent->listeners));
     $this->assertEquals(1, count($child->listeners));
     unset($parent, $child);
     $parent = $this->_em->find(__NAMESPACE__ . '\\DDC1690Parent', $parentId);
     $child = $parent->getChild();
     $this->assertEquals(1, count($parent->listeners));
     $this->assertEquals(1, count($child->listeners));
     unset($parent, $child);
     $child = $this->_em->find(__NAMESPACE__ . '\\DDC1690Child', $childId);
     $parent = $child->getParent();
     $this->assertEquals(1, count($parent->listeners));
     $this->assertEquals(1, count($child->listeners));
 }
Exemple #2
0
 public function testChangeTracking()
 {
     $parent = new DDC1690Parent();
     $child = new DDC1690Child();
     $parent->setName('parent');
     $child->setName('child');
     $parent->setChild($child);
     $child->setParent($parent);
     $this->_em->persist($parent);
     $this->_em->persist($child);
     $this->assertEquals(1, count($parent->listeners));
     $this->assertEquals(1, count($child->listeners));
     $this->_em->flush();
     $this->_em->clear();
     $this->assertEquals(1, count($parent->listeners));
     $this->assertEquals(1, count($child->listeners));
     $parentId = $parent->getId();
     $childId = $child->getId();
     unset($parent, $child);
     $parent = $this->_em->find(__NAMESPACE__ . '\\DDC1690Parent', $parentId);
     $child = $this->_em->find(__NAMESPACE__ . '\\DDC1690Child', $childId);
     $this->assertEquals(1, count($parent->listeners));
     $this->assertInstanceOf('Doctrine\\ORM\\Proxy\\Proxy', $child, 'Verifying that $child is a proxy before using proxy API');
     $this->assertCount(0, $child->listeners);
     $child->__load();
     $this->assertCount(1, $child->listeners);
     unset($parent, $child);
     $parent = $this->_em->find(__NAMESPACE__ . '\\DDC1690Parent', $parentId);
     $child = $parent->getChild();
     $this->assertEquals(1, count($parent->listeners));
     $this->assertEquals(1, count($child->listeners));
     unset($parent, $child);
     $child = $this->_em->find(__NAMESPACE__ . '\\DDC1690Child', $childId);
     $parent = $child->getParent();
     $this->assertEquals(1, count($parent->listeners));
     $this->assertEquals(1, count($child->listeners));
 }