mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Add tests that show that joinClass default_sort is not used and order is honoured
This commit is contained in:
parent
0c7ced1513
commit
4aa7fb70ee
@ -82,8 +82,11 @@ class ManyManyThroughListTest extends SapphireTest
|
||||
/** @var ManyManyThroughListTest\TestObject $parent */
|
||||
$parent = $this->objFromFixture(ManyManyThroughListTest\TestObject::class, 'parent1');
|
||||
|
||||
$items = $parent->Items()->sort($sort);
|
||||
$this->assertListEquals($expected, $items);
|
||||
$items = $parent->Items();
|
||||
if ($sort) {
|
||||
$items = $items->sort($sort);
|
||||
}
|
||||
$this->assertSame($expected, $items->column('Title'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,61 +95,41 @@ class ManyManyThroughListTest extends SapphireTest
|
||||
public function sortingProvider()
|
||||
{
|
||||
return [
|
||||
'nothing passed (default)' => [
|
||||
null,
|
||||
['item 2', 'item 1'],
|
||||
],
|
||||
'table with default column' => [
|
||||
'"ManyManyThroughListTest_JoinObject"."Sort"',
|
||||
[
|
||||
['Title' => 'item 2'],
|
||||
['Title' => 'item 1'],
|
||||
]
|
||||
['item 2', 'item 1'],
|
||||
],
|
||||
'table with default column ascending' => [
|
||||
'"ManyManyThroughListTest_JoinObject"."Sort" ASC',
|
||||
[
|
||||
['Title' => 'item 1'],
|
||||
['Title' => 'item 2'],
|
||||
]
|
||||
['item 2', 'item 1'],
|
||||
],
|
||||
'table with column descending' => [
|
||||
'"ManyManyThroughListTest_JoinObject"."Title" DESC',
|
||||
[
|
||||
['Title' => 'item 2'],
|
||||
['Title' => 'item 1'],
|
||||
]
|
||||
['item 2', 'item 1'],
|
||||
],
|
||||
'table with column ascending' => [
|
||||
'"ManyManyThroughListTest_JoinObject"."Title" ASC',
|
||||
[
|
||||
['Title' => 'item 1'],
|
||||
['Title' => 'item 2'],
|
||||
]
|
||||
['item 1', 'item 2'],
|
||||
],
|
||||
'default column' => [
|
||||
'"Sort"',
|
||||
[
|
||||
['Title' => 'item 2'],
|
||||
['Title' => 'item 1'],
|
||||
]
|
||||
['item 2', 'item 1'],
|
||||
],
|
||||
'default column ascending' => [
|
||||
'"Sort" ASC',
|
||||
[
|
||||
['Title' => 'item 1'],
|
||||
['Title' => 'item 2'],
|
||||
]
|
||||
['item 2', 'item 1'],
|
||||
],
|
||||
'column descending' => [
|
||||
'"Title" DESC',
|
||||
[
|
||||
['Title' => 'item 2'],
|
||||
['Title' => 'item 1'],
|
||||
]
|
||||
['item 2', 'item 1'],
|
||||
],
|
||||
'column ascending' => [
|
||||
'"Title" ASC',
|
||||
[
|
||||
['Title' => 'item 1'],
|
||||
['Title' => 'item 2'],
|
||||
]
|
||||
['item 1', 'item 2'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@ -23,4 +23,6 @@ class JoinObject extends DataObject implements TestOnly
|
||||
'Parent' => TestObject::class,
|
||||
'Child' => Item::class,
|
||||
];
|
||||
|
||||
private static $default_sort = '"Sort" ASC';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user