|
|
@@ -1122,6 +1122,42 @@ class DboSourceTest extends CakeTestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * data provider for testBuildJoinStatementWithTablePrefix
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public static function joinStatementsWithPrefix($schema) {
|
|
|
+ return array(
|
|
|
+ array(array(
|
|
|
+ 'type' => 'LEFT',
|
|
|
+ 'alias' => 'PostsTag',
|
|
|
+ 'table' => 'posts_tags',
|
|
|
+ 'conditions' => array('PostsTag.post_id = Post.id')
|
|
|
+ ), 'LEFT JOIN pre_posts_tags AS PostsTag ON (PostsTag.post_id = Post.id)'),
|
|
|
+ array(array(
|
|
|
+ 'type' => 'LEFT',
|
|
|
+ 'alias' => 'Stock',
|
|
|
+ 'table' => '(SELECT Stock.article_id, sum(quantite) quantite FROM stocks AS Stock GROUP BY Stock.article_id)',
|
|
|
+ 'conditions' => 'Stock.article_id = Article.id'
|
|
|
+ ), 'LEFT JOIN (SELECT Stock.article_id, sum(quantite) quantite FROM stocks AS Stock GROUP BY Stock.article_id) AS Stock ON (Stock.article_id = Article.id)')
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * Test buildJoinStatement()
|
|
|
+ * ensure that prefix is not added when table value is a subquery
|
|
|
+ *
|
|
|
+ * @dataProvider joinStatementsWithPrefix
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testBuildJoinStatementWithTablePrefix($join, $expected) {
|
|
|
+ $db = new DboTestSource;
|
|
|
+ $db->config['prefix'] = 'pre_';
|
|
|
+ $result = $db->buildJoinStatement($join);
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* Test conditionKeysToString()
|
|
|
*
|
|
|
* @return void
|