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); }
$person->name_first = 'Lady'; $person->name_last = 'Cat'; $person->favorite_color = 'green'; $person->save(); $child = new Child(); $child->name_first = 'Fluffy'; $child->name_last = 'Cat'; $child->favorite_pet = 'Cat Lady'; $child->person_id = $person->id; $child->save(); $child = new Child(); $child->name_first = 'Sun'; $child->name_last = 'Cat'; $child->favorite_pet = 'Cat Lady'; $child->person_id = $person->id; $child->save(); $err_count = 0; ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n"); ar_echo("person->Find('id=1') [Lazy Method]\n"); ar_echo("person is loaded but its children will be loaded on-demand later on\n"); ar_echo("-------------------------------------------------------------------------------------------------------------------\n"); $person = new Person(); $people = $person->Find('id=1'); ar_echo(ar_assert(found($people, "'name_first' => 'John'")) ? "[OK] Found John\n" : "[!!] Find failed\n"); ar_echo(ar_assert(notfound($people, "'favorite_pet' => 'tortoise'")) ? "[OK] No relation yet\n" : "[!!] Found relation when I shouldn't\n"); ar_echo("\n-- Lazily Loading Children:\n\n"); foreach ($people as $aperson) { foreach ($aperson->children as $achild) { if ($achild->name_first) { } }