Пример #1
0
 public function testDateCastingUsingExists()
 {
     Galleries::config(array('schema' => array('_id' => 'id', 'created_at' => 'date')));
     $gallery = Galleries::create(array('created_at' => time()));
     $gallery->save();
     $result = Galleries::first(array('conditions' => array('created_at' => array('$exists' => false))));
     $this->assertNull($result);
 }
Пример #2
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());
 }
Пример #3
0
 public function testOrderWithRelationAndLimit()
 {
     $galleries = Galleries::first(array('with' => array('Images'), 'order' => 'name'));
     $this->assertNotEmpty($galleries);
 }
Пример #4
0
 public function testDelete()
 {
     Galleries::create(array('name' => 'Flowers', 'active' => true))->save();
     $existing = Galleries::first();
     $this->assertTrue($existing->exists());
     $this->assertTrue($existing->delete());
     $this->assertNull(Galleries::first(array('conditions' => Galleries::key($existing))));
     $this->assertIdentical(0, Galleries::count());
 }