Add tests that show that joinClass default_sort is not used and order is honoured

This commit is contained in:
Robbie Averill 2018-09-28 15:38:37 +02:00
parent 0c7ced1513
commit 4aa7fb70ee
2 changed files with 19 additions and 34 deletions

View File

@ -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'],
],
];
}

View File

@ -23,4 +23,6 @@ class JoinObject extends DataObject implements TestOnly
'Parent' => TestObject::class,
'Child' => Item::class,
];
private static $default_sort = '"Sort" ASC';
}