|
|
@@ -24,6 +24,57 @@ use Cake\TestSuite\TestCase;
|
|
|
class QueryExpressionTest extends TestCase
|
|
|
{
|
|
|
/**
|
|
|
+ * Test setConjunction()/getConjunction() works.
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public function testConjunction()
|
|
|
+ {
|
|
|
+ $expr = new QueryExpression(['1', '2']);
|
|
|
+ $binder = new ValueBinder();
|
|
|
+
|
|
|
+ $this->assertSame($expr, $expr->setConjunction('+'));
|
|
|
+ $this->assertSame('+', $expr->getConjunction());
|
|
|
+
|
|
|
+ $result = $expr->sql($binder);
|
|
|
+ $this->assertEquals('(1 + 2)', $result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Test tieWith() works.
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public function testTieWith()
|
|
|
+ {
|
|
|
+ $expr = new QueryExpression(['1', '2']);
|
|
|
+ $binder = new ValueBinder();
|
|
|
+
|
|
|
+ $this->assertSame($expr, $expr->tieWith('+'));
|
|
|
+ $this->assertSame('+', $expr->tieWith());
|
|
|
+
|
|
|
+ $result = $expr->sql($binder);
|
|
|
+ $this->assertEquals('(1 + 2)', $result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Test type() works.
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public function testType()
|
|
|
+ {
|
|
|
+ $expr = new QueryExpression(['1', '2']);
|
|
|
+ $binder = new ValueBinder();
|
|
|
+
|
|
|
+ $this->assertSame($expr, $expr->type('+'));
|
|
|
+ $this->assertSame('+', $expr->type());
|
|
|
+
|
|
|
+ $result = $expr->sql($binder);
|
|
|
+ $this->assertEquals('(1 + 2)', $result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Test and() and or() calls work transparently
|
|
|
*
|
|
|
* @return void
|