public function setUp() { $this->_db->dropSchema('galleries'); $schema = new Schema($this->_schema); $this->_db->createSchema('galleries', $schema); Galleries::config(array('meta' => array('connection' => $this->_connection))); }
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); }
public function setUp() { Galleries::config(array('meta' => array('connection' => 'test'))); }
public function testOneToManyUsingSameKeyName() { Fixtures::drop('db', array('galleries')); $fixture = Fixtures::get('db', 'galleries'); $fixture->alter('change', 'id', array('to' => 'gallery_id')); Fixtures::save('db', array('galleries')); Galleries::reset(); Galleries::config(array('meta' => array('connection' => $this->_connection, 'key' => 'gallery_id'))); $opts = array('conditions' => array('Galleries.gallery_id' => 1)); $query = new Query($opts + array('type' => 'read', 'model' => 'lithium\\tests\\fixture\\model\\gallery\\Galleries', 'source' => 'galleries', 'alias' => 'Galleries', 'with' => array('Images'))); $galleries = $this->_db->read($query); $this->assertCount(3, $galleries->first()->images); }
/** * Tests if the `value()` and `_cast()` methods work correctly * when a schema is hardcoded. * * @link https://github.com/UnionOfRAD/lithium/issues/1003 */ public function testValueWithHardcodedSchema() { Galleries::config(array('schema' => new Schema(array('fields' => array('id' => array('type' => 'id'), 'name' => array('type' => 'string', 'length' => 50), 'active' => array('type' => 'boolean', 'default' => true), 'created' => array('type' => 'datetime'), 'modified' => array('type' => 'datetime')))))); $results = Galleries::find('all', array('conditions' => array('name' => 'Foo Gallery'), 'order' => array('id' => 'DESC'))); $this->assertEqual(1, $results->count()); }