public function testBelongsToSimpleMany() { // Find kid with id `3` $kid3 = Model\Kid::find(3); // Consist $this->assertInstanceOf('Gas\\ORM', $kid3); $this->assertInstanceOf('Gas\\Data', $kid3->record); // Check result $this->assertEquals($kid3->id, '3'); $this->assertEquals($kid3->name, 'Abraham Jones'); $this->assertEquals($kid3->age, '3'); // Grab related father (user) $kid3_father = $kid3->user(); // Consist $this->assertInstanceOf('Gas\\ORM', $kid3_father); $this->assertInstanceOf('Gas\\Data', $kid3_father->record); // Check results, this should be `Derek Jones` with `2` as his id // and `derek` as his username $this->assertEquals($kid3_father->id, '2'); $this->assertEquals($kid3_father->name, 'Derek Jones'); $this->assertEquals($kid3_father->username, 'derek'); // Since the third parameter for kid <-> user relationship // contain `select:id,name,username` for pre-process relation // Other fields should be null $this->assertNull($kid3_father->email); }
public function testBelongsToFinder() { // Find a belongs-to record $dad_of_kid1 = Model\Kid::find(1)->user(); $this->assertInternalType('object', $dad_of_kid1); $this->assertTrue($dad_of_kid1 instanceof Gas\ORM); }