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()); }
public function testCreateData() { $gallery = Galleries::create(array('name' => 'New Gallery')); $this->assertTrue($gallery->save()); $this->assertNotEmpty($gallery->id); $this->assertTrue(Galleries::count() === 3); $img = Images::create(array('image' => 'newimage.png', 'title' => 'New Image', 'gallery_id' => $gallery->id)); $this->assertEqual(true, $img->save()); $img = Images::find($img->id); $this->assertEqual($gallery->id, $img->gallery_id); }