Skip to content

Commit

Permalink
Merge pull request #15686 from BeMySlaveDarlin/issue/15553-fix-return…
Browse files Browse the repository at this point in the history
…-type

#15553 - Fix Query::getExpression return type
  • Loading branch information
niden authored Sep 30, 2021
2 parents cd06b5b + ccedaff commit e667816
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG-5.0.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# [5.0.0alpha7](https://github.com/phalcon/cphalcon/releases/tag/v5.0.0alpha6) (xxxx-xx-xx)

## Fixed
- Fixed `Query::getExpression()` return type [#15553](https://github.com/phalcon/cphalcon/issues/15553)

# [5.0.0alpha6](https://github.com/phalcon/cphalcon/releases/tag/v5.0.0alpha6) (2021-09-16)

## Changed
Expand Down
4 changes: 2 additions & 2 deletions phalcon/Mvc/Model/Query.zep
Original file line number Diff line number Diff line change
Expand Up @@ -1542,9 +1542,9 @@ class Query implements QueryInterface, InjectionAwareInterface
}

/**
* Resolves an expression from its intermediate code into a string
* Resolves an expression from its intermediate code into an array
*/
final protected function getExpression(array expr, bool quoting = true) -> string
final protected function getExpression(array expr, bool quoting = true) -> array
{
var exprType, exprLeft, exprRight, left = null, right = null,
listItems, exprListItem, exprReturn, value, escapedValue,
Expand Down
64 changes: 64 additions & 0 deletions tests/unit/Mvc/Model/Query/GetExpressionCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <team@phalcon.io>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Phalcon\Test\Unit\Mvc\Model\Query;

use Phalcon\Mvc\Model\Query;
use UnitTester;

class GetExpressionCest
{
private $PHQL_T_AND = 266;
private $PHQL_T_OR = 267;

/**
* Tests Phalcon\Mvc\Model\Query :: getExpression()
*
* @author Phalcon Team <team@phalcon.io>
* @since 2021-09-21
* @issue 15553
*/
public function mvcModelQueryGetExpression(UnitTester $I)
{
$I->wantToTest('Phalcon\Mvc\Model\Query - getExpression()');

$valueOne = [
'type' => 'binary-op',
'op' => 'AND',
'left' => null,
'right' => null,
];
$valueTwo = [
'type' => 'binary-op',
'op' => 'OR',
'left' => null,
'right' => null,
];

$oneExpr = [
'type' => $this->PHQL_T_AND,
];

$twoExpr = [
'type' => $this->PHQL_T_OR,
];

$query = new Query();
$reflection = new \ReflectionClass(Query::class);
$getExpression = $reflection->getMethod('getExpression');
$getExpression->setAccessible(true);

$I->assertEquals($getExpression->invokeArgs($query, [$oneExpr, false]), $valueOne);
$I->assertEquals($getExpression->invokeArgs($query, [$twoExpr, false]), $valueTwo);
}
}

0 comments on commit e667816

Please sign in to comment.