示例#1
0
 public function testFieldsWithJoins()
 {
     $db = $this->_db;
     $this->skipIf(!$db::enabled('relationships'));
     $this->skipIf($this->with(array('MongoDb')));
     $new = Galleries::create(array('name' => 'Celebrities'));
     $cKey = Galleries::meta('key');
     $result = $new->save();
     $this->assertTrue($result);
     $cId = (string) $new->{$cKey};
     $new = Images::create(array('gallery_id' => $cId, 'title' => 'John Doe'));
     $eKey = Images::meta('key');
     $result = $new->save();
     $this->assertTrue($result);
     $eId = (string) $new->{$eKey};
     $entity = Galleries::first(array('with' => 'Images', 'conditions' => array('Galleries.id' => $cId), 'fields' => array('Galleries' => array('name'), 'Images' => array('id', 'title'))));
     $expected = array('id' => $cId, 'name' => 'Celebrities', 'images' => array($eId => array('id' => $eId, 'title' => 'John Doe')));
     $this->assertEqual($expected, $entity->data());
 }
示例#2
0
 public function testAbstractTypeHandling()
 {
     $key = Galleries::meta('key');
     foreach ($this->galleriesData as $data) {
         $galleries[] = Galleries::create($data);
         $this->assertTrue(end($galleries)->save());
         $this->assertNotEmpty(end($galleries)->{$key});
     }
     foreach (Galleries::all() as $galleries) {
         $this->assertTrue($galleries->delete());
     }
 }