예제 #1
0
 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)));
 }
예제 #2
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);
 }
예제 #3
0
 public function setUp()
 {
     Galleries::config(array('meta' => array('connection' => 'test')));
 }
예제 #4
0
 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);
 }
예제 #5
0
 /**
  * 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());
 }