function testLazyLoad() { $this->getDB(); $childID = $this->db->queryValue('SELECT ID FROM Test WHERE Parent = ? LIMIT 1', $GLOBALS['FirstObjectID']); DBObject::purgeInstance('DBTest', $GLOBALS['FirstObjectID']); $child = DBTest::get($childID); $r = new ReflectionObject($child); foreach ($r->getProperties() as $prop) { $this->assertNotEquals($prop->getName(), 'Parent'); // Parent should not be defined as we have not yet accessed it } $foo = $child->Parent; $this->assertType('object', $foo); $this->assertEquals($foo->ID, $GLOBALS['FirstObjectID']); $found = false; foreach ($r->getProperties() as $prop) { if ($prop->getName() == 'Parent') { $found = true; } } $this->assertTrue($found); }