mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MNT Add test to SQLSelect for Zero limit
This commit is contained in:
parent
5090f49ecc
commit
fc6c45df57
@ -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'
|
||||
);
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user