示例#1
0
 public function testFindSeveral()
 {
     $wifes = Model\Wife::find(1, 2, 3);
     // Should be an array, contain 3 wife objects
     $this->assertCount(3, $wifes);
     foreach ($wifes as $wife) {
         // Consist
         $this->assertInstanceOf('Gas\\ORM', $wife);
         $this->assertInstanceOf('Gas\\Data', $wife->record);
         // Check results
         switch ($wife->id) {
             case '1':
                 $this->assertEquals($wife->name, 'Lourie Jones');
                 break;
             case '2':
                 $this->assertEquals($wife->name, 'Patricia Doe');
                 break;
             case '3':
                 $this->assertEquals($wife->name, 'Lily Sinatra');
                 break;
         }
     }
 }
示例#2
0
 public function testBelongsToSimpleOne()
 {
     // Find wife with id `1`
     $wife1 = Model\Wife::find(1);
     // Consist
     $this->assertInstanceOf('Gas\\ORM', $wife1);
     $this->assertInstanceOf('Gas\\Data', $wife1->record);
     // Check result
     $this->assertEquals($wife1->id, '1');
     $this->assertEquals($wife1->name, 'Lourie Jones');
     $this->assertEquals($wife1->hair_color, 'black');
     // Grab related husband (user)
     $wife1_husband = $wife1->user();
     // Consist
     $this->assertInstanceOf('Gas\\ORM', $wife1_husband);
     $this->assertInstanceOf('Gas\\Data', $wife1_husband->record);
     // Check results, this should be `Derek Jones` with `2` as his id
     // `derekjones@world.com` as his email and `derek` as his username
     $this->assertEquals($wife1_husband->id, '2');
     $this->assertEquals($wife1_husband->name, 'Derek Jones');
     $this->assertEquals($wife1_husband->email, '*****@*****.**');
     $this->assertEquals($wife1_husband->username, 'derek');
 }