/** * Test for issue #1 */ public function testStoresReplacementChild() { $parent = new HasOneParent(); $parent->Name = 'Has One Parent'; $child = new Child(); $child->Name = 'Child'; $parent->Child = $child; $parent->save(); $this->assertCollectionExists('HasOneParent'); $this->assertCollectionExists('Child'); $this->assertDocumentExists('HasOneParent', $parent->id()); $this->assertDocumentExists('Child', $child->id()); //now for the second child $child2 = new Child(); $child2->Name = 'Child2'; $parent->Child = $child2; $parent->save(); $this->assertDocumentExists('Child', $child2->id()); }
public function testStoresAddChild() { $parent = new HasManyParent(); $parent->Name = 'Has Many Parent'; $child1 = new Child(); $child1->Name = 'Child1'; $parent->Children[] = $child1; $parent->save(); $this->assertCollectionExists('HasManyParent'); $this->assertCollectionExists('Child'); $this->assertDocumentExists('HasManyParent', $parent->id()); $this->assertDocumentExists('Child', $child1->id()); $child2 = new Child(); $child2->Name = 'Child2'; $parent->Children[] = $child2; $parent->save(); $this->assertDocumentExists('Child', $child2->id()); }
public function testEditStoredObject() { $child = new Child(); $child->Name = 'Child'; $child->save(); $expected = 'Child with edit'; $id = $child->id(); $childFetched = new Child; $childFetched->loadById($id); $childFetched->Name = $expected; $childFetched->save(); $this->assertDocumentPropertyEquals($expected, 'Child', 'Name', $id); }