Skip to content

Commit

Permalink
Move test into class where the problem/feature was.
Browse files Browse the repository at this point in the history
Refs #3852
Refs #3853
  • Loading branch information
markstory committed Jul 4, 2014
1 parent 74a1685 commit 831b2e9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
15 changes: 0 additions & 15 deletions tests/TestCase/Database/Expression/TupleComparisonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
26 changes: 26 additions & 0 deletions tests/TestCase/Database/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 831b2e9

Please sign in to comment.