Skip to content

Commit

Permalink
Merge pull request #11040 from chinpei215/3.4-query-expression
Browse files Browse the repository at this point in the history
Fix backward incompatibility of QueryExpression::type()
  • Loading branch information
lorenzo committed Aug 15, 2017
2 parents af2e473 + 3f24349 commit bf64092
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Database/Expression/QueryExpression.php
Expand Up @@ -122,7 +122,7 @@ public function tieWith($conjunction = null)
*/
public function type($conjunction = null)
{
return $this->setConjunction($conjunction);
return $this->tieWith($conjunction);
}

/**
Expand Down
51 changes: 51 additions & 0 deletions tests/TestCase/Database/Expression/QueryExpressionTest.php
Expand Up @@ -23,6 +23,57 @@
*/
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
*
Expand Down

0 comments on commit bf64092

Please sign in to comment.