public function testCanUpdateChildElementWithoutLoosingParentFK() { $this->entity->setOneToManyChild(array(new ChildTest())); $this->annotatedTestDao->create($this->entity); $this->entity = $this->annotatedTestDao->find($this->entity->getId()); $this->assertEquals(1, count($this->entity->getOneToManyChild())); $child = current($this->entity->getOneToManyChild()); $child->setData('something updated'); $this->childTestDao->update($child); $this->annotatedTestDao->refresh($this->entity); $this->assertEquals(1, count($this->entity->getOneToManyChild())); }
public function testCanAddToCollectionProxy() { $parent = new ParentTest(); $id = $this->parentDao->create($parent); /** * fetch lazy object * @var $parent ParentTest */ $parent = $this->parentDao->find($id); $this->assertTrue($parent->getChildren() instanceof CollectionProxy); $parent->addToChildren(new ChildTest()); $this->parentDao->update($parent); $children = $parent->getChildren(); $this->assertTrue(is_array($children)); $this->assertEquals(1, count($children)); $this->assertFalse($this->childDao->isTransient(current($children))); $this->assertTrue(is_numeric(current($children)->getId())); }