-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed return type for CriteriaInterface::getLimit
See: #15004
- Loading branch information
1 parent
930fc08
commit 3271782
Showing
8 changed files
with
93 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ | |
* | ||
* (c) Phalcon Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
* For the full copyright and license information, please view the | ||
* LICENSE.txt file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\Mvc\Model; | ||
|
@@ -98,11 +98,13 @@ interface CriteriaInterface | |
public function getHaving(); | ||
|
||
/** | ||
* Returns the limit parameter in the criteria, which will be an integer if | ||
* limit was set without an offset, an array with 'number' and 'offset' keys | ||
* if an offset was set with the limit, or null if limit has not been set. | ||
* Returns the limit parameter in the criteria, which will be | ||
* | ||
* - An integer if 'limit' was set without an 'offset' | ||
* - An array with 'number' and 'offset' keys if an offset was set with the limit | ||
* - NULL if limit has not been set | ||
*/ | ||
public function getLimit() -> string | null; | ||
public function getLimit() -> int | array | null; | ||
|
||
/** | ||
* Returns an internal model name on which the criteria will be applied | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ | |
* | ||
* (c) Phalcon Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
* For the full copyright and license information, please view the | ||
* LICENSE.txt file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
@@ -16,24 +16,34 @@ | |
use DatabaseTester; | ||
use Phalcon\Mvc\Model\Criteria; | ||
use Phalcon\Mvc\Model\Query\Builder; | ||
use Phalcon\Storage\Exception; | ||
use Phalcon\Test\Fixtures\Traits\DiTrait; | ||
use Phalcon\Test\Models\Invoices; | ||
|
||
/** | ||
* Class LimitCest | ||
*/ | ||
class LimitCest | ||
{ | ||
use DiTrait; | ||
|
||
public function _before(DatabaseTester $I) | ||
/** | ||
* Executed before each test | ||
* | ||
* @param DatabaseTester $I | ||
* @return void | ||
*/ | ||
public function _before(DatabaseTester $I): void | ||
{ | ||
$this->setNewFactoryDefault(); | ||
try { | ||
$this->setNewFactoryDefault(); | ||
} catch (Exception $e) { | ||
$I->fail($e->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Mvc\Model\Criteria :: limit() | ||
* | ||
* @param DatabaseTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2020-02-01 | ||
* | ||
|
@@ -58,20 +68,16 @@ public function mvcModelCriteriaLimit(DatabaseTester $I) | |
$expected = 'SELECT [Phalcon\Test\Models\Invoices].* ' | ||
. 'FROM [Phalcon\Test\Models\Invoices] ' | ||
. 'LIMIT :APL0:'; | ||
$actual = $builder->getPhql(); | ||
$I->assertEquals($expected, $actual); | ||
|
||
$expected = [ | ||
'number' => 10, | ||
'offset' => 0, | ||
]; | ||
$actual = $criteria->getLimit(); | ||
$I->assertEquals($expected, $actual); | ||
$I->assertEquals($expected, $builder->getPhql()); | ||
$I->assertEquals(10, $criteria->getLimit()); | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Mvc\Model\Criteria :: limit() - offset | ||
* | ||
* @param DatabaseTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2020-02-01 | ||
* | ||
|
@@ -96,14 +102,14 @@ public function mvcModelCriteriaLimitOffset(DatabaseTester $I) | |
$expected = 'SELECT [Phalcon\Test\Models\Invoices].* ' | ||
. 'FROM [Phalcon\Test\Models\Invoices] ' | ||
. 'LIMIT :APL0: OFFSET :APL1:'; | ||
$actual = $builder->getPhql(); | ||
$I->assertEquals($expected, $actual); | ||
|
||
$I->assertEquals($expected, $builder->getPhql()); | ||
|
||
$expected = [ | ||
'number' => 10, | ||
'offset' => 15, | ||
]; | ||
$actual = $criteria->getLimit(); | ||
$I->assertEquals($expected, $actual); | ||
|
||
$I->assertEquals($expected, $criteria->getLimit()); | ||
} | ||
} |