diff --git a/tests/php/ORM/DataListTest.php b/tests/php/ORM/DataListTest.php index 643a169a8..a50bb6598 100755 --- a/tests/php/ORM/DataListTest.php +++ b/tests/php/ORM/DataListTest.php @@ -121,7 +121,8 @@ class DataListTest extends SapphireTest $this->assertEquals(['Joe', 'Phil'], $list->limit(2, 1)->column('Name')); } - public function limitDataProvider(): array { + public function limitDataProvider(): array + { return [ 'no limit' => [null, 0, 3], 'smaller limit' => [2, 0, 2], @@ -151,7 +152,7 @@ class DataListTest extends SapphireTest $this->assertCount($expectedCount, $list->limit($length, $offset)); $this->assertCount( $expectedCount, - $list->limit(0,9999)->limit($length, $offset), + $list->limit(0, 9999)->limit($length, $offset), 'Follow up limit calls unset previous ones' ); diff --git a/tests/php/ORM/SQLSelectTest.php b/tests/php/ORM/SQLSelectTest.php index ce372e50a..be70ccb3a 100755 --- a/tests/php/ORM/SQLSelectTest.php +++ b/tests/php/ORM/SQLSelectTest.php @@ -173,6 +173,7 @@ class SQLSelectTest extends SapphireTest $this->assertSQLEquals("SELECT * FROM MyTable LIMIT 99 OFFSET 97", $query->sql($parameters)); } + public function testSelectWithOrderbyClause() { $query = new SQLSelect(); @@ -255,6 +256,18 @@ class SQLSelectTest extends SapphireTest ); } + public function testZeroLimit() + { + $query = new SQLSelect(); + $query->setFrom("MyTable"); + $query->setLimit(0); + + $this->assertSQLEquals( + 'SELECT * FROM MyTable LIMIT 0', + $query->sql($parameters) + ); + } + public function testNegativeLimit() { $this->expectException(\InvalidArgumentException::class);