public function testWithOptionAndCustomAlias()
{
$model = 'lithium\\tests\\mocks\\data\\model\\MockGallery';
$model::bind('hasMany', 'Image', array('to' => 'lithium\\tests\\mocks\\data\\model\\MockImage', 'constraints' => array('Image.title' => (object) "'MyImage'")));
$options = array('type' => 'read', 'model' => $model, 'alias' => 'MyGallery', 'with' => array('Image' => array('alias' => 'MyImage')));
$result = $this->_db->read(new Query($options));
$query = new Query($options);
$expected = 'SELECT * FROM {mock_gallery} AS {MyGallery} LEFT JOIN ';
$expected .= '{mock_image} AS {MyImage} ON {MyImage}.{title} = \'MyImage\' ';
$expected .= 'AND {MyGallery}.{id} = {MyImage}.{gallery_id};';
$this->assertEqual($expected, $this->_db->sql);
$model::reset();
}