/** * Creating the test database */ public function setUp() { Fixtures::config(array('db' => array('adapter' => 'Connection', 'connection' => $this->_connection, 'fixtures' => $this->_fixtures))); Fixtures::create('db'); $db = $this->_db; if (!$db::enabled('schema')) { $gallery = Fixtures::get('db', 'galleries'); $images = Fixtures::get('db', 'images'); Galleries::schema($gallery->fields()); Images::schema($images->fields()); } }
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); }