MNT Add test to SQLSelect for Zero limit

This commit is contained in:
Maxime Rainville 2023-01-25 17:19:30 +13:00
parent 5090f49ecc
commit fc6c45df57
2 changed files with 16 additions and 2 deletions

View File

@ -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],

View File

@ -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);