mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-04 08:47:59 +02:00
Merge pull request #10693 from creative-commoners/pulls/5.0/tweak-test-for-postgresql
MNT Tweak some test to account for slightly different sorting logic in PostgreSQL
This commit is contained in:
commit
bf058ee968
@ -1958,8 +1958,6 @@ class DataListTest extends SapphireTest
|
|||||||
/**
|
/**
|
||||||
* Test passing scalar values to sort()
|
* Test passing scalar values to sort()
|
||||||
*
|
*
|
||||||
* Explicity tests that sort(null) will wipe any existing sort on a DataList
|
|
||||||
*
|
|
||||||
* @dataProvider provideSortScalarValues
|
* @dataProvider provideSortScalarValues
|
||||||
*/
|
*/
|
||||||
public function testSortScalarValues(mixed $emtpyValue, string $type): void
|
public function testSortScalarValues(mixed $emtpyValue, string $type): void
|
||||||
@ -1967,16 +1965,14 @@ class DataListTest extends SapphireTest
|
|||||||
$this->assertSame(['Subteam 1'], Team::get()->limit(1)->column('Title'));
|
$this->assertSame(['Subteam 1'], Team::get()->limit(1)->column('Title'));
|
||||||
$list = Team::get()->sort('Title DESC');
|
$list = Team::get()->sort('Title DESC');
|
||||||
$this->assertSame(['Team 3'], $list->limit(1)->column('Title'));
|
$this->assertSame(['Team 3'], $list->limit(1)->column('Title'));
|
||||||
if ($type !== 'wipes-existing') {
|
$this->expectException(InvalidArgumentException::class);
|
||||||
$this->expectException(InvalidArgumentException::class);
|
|
||||||
}
|
|
||||||
if ($type === 'invalid-scalar') {
|
if ($type === 'invalid-scalar') {
|
||||||
$this->expectExceptionMessage('sort() arguments must either be a string, an array, or null');
|
$this->expectExceptionMessage('sort() arguments must either be a string, an array, or null');
|
||||||
}
|
}
|
||||||
if ($type === 'empty-scalar') {
|
if ($type === 'empty-scalar') {
|
||||||
$this->expectExceptionMessage('Invalid sort parameter');
|
$this->expectExceptionMessage('Invalid sort parameter');
|
||||||
}
|
}
|
||||||
// $type === 'wipes-existing' is valid
|
|
||||||
$list = $list->sort($emtpyValue);
|
$list = $list->sort($emtpyValue);
|
||||||
$this->assertSame(['Subteam 1'], $list->limit(1)->column('Title'));
|
$this->assertSame(['Subteam 1'], $list->limit(1)->column('Title'));
|
||||||
}
|
}
|
||||||
@ -1984,7 +1980,6 @@ class DataListTest extends SapphireTest
|
|||||||
public function provideSortScalarValues(): array
|
public function provideSortScalarValues(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[null, 'wipes-existing'],
|
|
||||||
['', 'empty-scalar'],
|
['', 'empty-scalar'],
|
||||||
[[], 'empty-scalar'],
|
[[], 'empty-scalar'],
|
||||||
[false, 'invalid-scalar'],
|
[false, 'invalid-scalar'],
|
||||||
@ -1994,6 +1989,27 @@ class DataListTest extends SapphireTest
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Explicity tests that sort(null) will wipe any existing sort on a DataList
|
||||||
|
*/
|
||||||
|
public function testSortNull(): void
|
||||||
|
{
|
||||||
|
$list = Team::get()->sort('Title DESC');
|
||||||
|
$query = $list->dataQuery()->getFinalisedQuery();
|
||||||
|
$this->assertSame(
|
||||||
|
['"DataObjectTest_Team"."Title"' => 'DESC'],
|
||||||
|
$query->getOrderBy(),
|
||||||
|
'Calling sort on a DataList sets an Orderby on the underlying query.'
|
||||||
|
);
|
||||||
|
|
||||||
|
$list = $list->sort(null);
|
||||||
|
$query = $list->dataQuery()->getFinalisedQuery();
|
||||||
|
$this->assertEmpty(
|
||||||
|
$query->getOrderBy(),
|
||||||
|
'Calling sort with null on a DataList unsets the orderby on the underlying query.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testShuffle()
|
public function testShuffle()
|
||||||
{
|
{
|
||||||
$list = Team::get()->shuffle();
|
$list = Team::get()->shuffle();
|
||||||
|
@ -1831,7 +1831,7 @@ class MemberTest extends FunctionalTest
|
|||||||
$result = Member::mapInCMSGroups($groups);
|
$result = Member::mapInCMSGroups($groups);
|
||||||
$this->assertInstanceOf(Map::class, $result);
|
$this->assertInstanceOf(Map::class, $result);
|
||||||
|
|
||||||
$this->assertSame($expectedUsers, $result->keys());
|
$this->assertEqualsCanonicalizing($expectedUsers, $result->keys());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideMapInCMSGroups()
|
public function provideMapInCMSGroups()
|
||||||
|
Loading…
Reference in New Issue
Block a user