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 */
|
/** @var ManyManyThroughListTest\TestObject $parent */
|
||||||
$parent = $this->objFromFixture(ManyManyThroughListTest\TestObject::class, 'parent1');
|
$parent = $this->objFromFixture(ManyManyThroughListTest\TestObject::class, 'parent1');
|
||||||
|
|
||||||
$items = $parent->Items()->sort($sort);
|
$items = $parent->Items();
|
||||||
$this->assertListEquals($expected, $items);
|
if ($sort) {
|
||||||
|
$items = $items->sort($sort);
|
||||||
|
}
|
||||||
|
$this->assertSame($expected, $items->column('Title'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,61 +95,41 @@ class ManyManyThroughListTest extends SapphireTest
|
|||||||
public function sortingProvider()
|
public function sortingProvider()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'nothing passed (default)' => [
|
||||||
|
null,
|
||||||
|
['item 2', 'item 1'],
|
||||||
|
],
|
||||||
'table with default column' => [
|
'table with default column' => [
|
||||||
'"ManyManyThroughListTest_JoinObject"."Sort"',
|
'"ManyManyThroughListTest_JoinObject"."Sort"',
|
||||||
[
|
['item 2', 'item 1'],
|
||||||
['Title' => 'item 2'],
|
|
||||||
['Title' => 'item 1'],
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
'table with default column ascending' => [
|
'table with default column ascending' => [
|
||||||
'"ManyManyThroughListTest_JoinObject"."Sort" ASC',
|
'"ManyManyThroughListTest_JoinObject"."Sort" ASC',
|
||||||
[
|
['item 2', 'item 1'],
|
||||||
['Title' => 'item 1'],
|
|
||||||
['Title' => 'item 2'],
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
'table with column descending' => [
|
'table with column descending' => [
|
||||||
'"ManyManyThroughListTest_JoinObject"."Title" DESC',
|
'"ManyManyThroughListTest_JoinObject"."Title" DESC',
|
||||||
[
|
['item 2', 'item 1'],
|
||||||
['Title' => 'item 2'],
|
|
||||||
['Title' => 'item 1'],
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
'table with column ascending' => [
|
'table with column ascending' => [
|
||||||
'"ManyManyThroughListTest_JoinObject"."Title" ASC',
|
'"ManyManyThroughListTest_JoinObject"."Title" ASC',
|
||||||
[
|
['item 1', 'item 2'],
|
||||||
['Title' => 'item 1'],
|
|
||||||
['Title' => 'item 2'],
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
'default column' => [
|
'default column' => [
|
||||||
'"Sort"',
|
'"Sort"',
|
||||||
[
|
['item 2', 'item 1'],
|
||||||
['Title' => 'item 2'],
|
|
||||||
['Title' => 'item 1'],
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
'default column ascending' => [
|
'default column ascending' => [
|
||||||
'"Sort" ASC',
|
'"Sort" ASC',
|
||||||
[
|
['item 2', 'item 1'],
|
||||||
['Title' => 'item 1'],
|
|
||||||
['Title' => 'item 2'],
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
'column descending' => [
|
'column descending' => [
|
||||||
'"Title" DESC',
|
'"Title" DESC',
|
||||||
[
|
['item 2', 'item 1'],
|
||||||
['Title' => 'item 2'],
|
|
||||||
['Title' => 'item 1'],
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
'column ascending' => [
|
'column ascending' => [
|
||||||
'"Title" ASC',
|
'"Title" ASC',
|
||||||
[
|
['item 1', 'item 2'],
|
||||||
['Title' => 'item 1'],
|
|
||||||
['Title' => 'item 2'],
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -23,4 +23,6 @@ class JoinObject extends DataObject implements TestOnly
|
|||||||
'Parent' => TestObject::class,
|
'Parent' => TestObject::class,
|
||||||
'Child' => Item::class,
|
'Child' => Item::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
private static $default_sort = '"Sort" ASC';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user