mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-29 20:59:23 +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],
|
||||
|
@ -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