Skip to content
Permalink
Browse files

Move test into class where the problem/feature was.

Refs #3852
Refs #3853
  • Loading branch information...
markstory committed Jul 4, 2014
1 parent 74a1685 commit 831b2e9b5dd7eb21637baa324ebac974f281b1f2
Showing with 26 additions and 15 deletions.
  1. +0 −15 tests/TestCase/Database/Expression/TupleComparisonTest.php
  2. +26 −0 tests/TestCase/Database/QueryTest.php
@@ -69,21 +69,6 @@ public function testTupleWithExpressionValues() {
$this->assertSame(2, $binder->bindings()[':c1']['value']);
}
/**
* Tests generating tuples in the values side containing closure expressions
*
* @return void
*/
public function testTupleWithClosureExpression() {
$field1 = new QueryExpression([function($e) {return $e->eq('a', 1);}]);
$f = new TupleComparison([$field1, 'field2'], [4, 5], ['integer', 'integer'], '>');
$binder = new ValueBinder;
$this->assertEquals('(a = :c0, field2) > (:c1, :c2)', $f->sql($binder));
$this->assertSame(1, $binder->bindings()[':c0']['value']);
$this->assertSame(4, $binder->bindings()[':c1']['value']);
$this->assertSame(5, $binder->bindings()[':c2']['value']);
}
/**
* Tests generating tuples using the IN conjunction
*
@@ -631,6 +631,32 @@ public function testSelectWhereUsingClosure() {
$this->assertCount(0, $result);
}
/**
* Tests generating tuples in the values side containing closure expressions
*
* @return void
*/
public function testTupleWithClosureExpression() {
$query = new Query($this->connection);
$query->select(['id'])
->from('comments')
->where([
'OR' => [
'id' => 1,
function($exp) {
return $exp->eq('id', 2);
}
]
]);
$result = $query->sql();
$this->assertQuotedQuery(
'SELECT <id> FROM <comments> WHERE \(<id> = :c0 OR <id> = :c1\)',
$result,
true
);
}
/**
* Tests that it is possible to pass a closure to andWhere() to build a set of
* conditions and return the expression to be used

0 comments on commit 831b2e9

Please sign in to comment.
You can’t perform that action at this time.