Skip to content

Commit

Permalink
phalcon#15553 - Added unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Aziz Muzafarov committed Sep 21, 2021
1 parent 2b28edc commit ccedaff
Showing 1 changed file with 64 additions and 0 deletions.
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 ccedaff

Please sign in to comment.