Browse Source

Added test case for closures in QueryExpression.

Michał Wadowski 11 years ago
parent
commit
689504294e
1 changed files with 15 additions and 0 deletions
  1. 15 0
      tests/TestCase/Database/Expression/TupleComparisonTest.php

+ 15 - 0
tests/TestCase/Database/Expression/TupleComparisonTest.php

@@ -70,6 +70,21 @@ class TupleComparisonTest extends TestCase {
 	}
 
 /**
+ * Tests generating tuples in the values side containing 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
  *
  * @return void