function test_references() { // basic references (belongs_to) $f = new Foo(array('id' => 1, 'name' => 'Joe')); $f->put(); $b = new Bar(array('id' => 1, 'name' => 'Jim', 'foo' => 1)); $b->put(); $this->assertEquals($b->name, 'Jim'); $this->assertEquals($b->foo, 1); $this->assertEquals($b->foo()->name, 'Joe'); $this->assertEquals($b->foo()->name, 'Joe'); // fake reference should fail try { $this->assertTrue($b->fake()); } catch (Exception $e) { $this->assertRegExp('/Call to undefined method Bar::fake in .+tests\\/ModelTest\\.php on line [0-9]+/', $e->getMessage()); } }