mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Add tests for sorting many many through list without a table alias
This commit is contained in:
parent
89df5515ae
commit
3321c6b39d
@ -70,8 +70,13 @@ class ManyManyThroughListTest extends SapphireTest
|
||||
$this->assertNotNull($item2->getJoin());
|
||||
$this->assertEquals('join 2', $item2->getJoin()->Title);
|
||||
$this->assertEquals('join 2', $item2->ManyManyThroughListTest_JoinObject->Title);
|
||||
}
|
||||
|
||||
public function testSortingOnJoinTable()
|
||||
{
|
||||
/** @var ManyManyThroughListTest\TestObject $parent */
|
||||
$parent = $this->objFromFixture(ManyManyThroughListTest\TestObject::class, 'parent1');
|
||||
|
||||
// Test sorting on join table
|
||||
$items = $parent->Items()->sort('"ManyManyThroughListTest_JoinObject"."Sort"');
|
||||
$this->assertListEquals(
|
||||
[
|
||||
@ -89,6 +94,7 @@ class ManyManyThroughListTest extends SapphireTest
|
||||
],
|
||||
$items
|
||||
);
|
||||
|
||||
$items = $parent->Items()->sort('"ManyManyThroughListTest_JoinObject"."Title" DESC');
|
||||
$this->assertListEquals(
|
||||
[
|
||||
@ -97,6 +103,57 @@ class ManyManyThroughListTest extends SapphireTest
|
||||
],
|
||||
$items
|
||||
);
|
||||
|
||||
$items = $parent->Items()->sort('"ManyManyThroughListTest_JoinObject"."Title" ASC');
|
||||
$this->assertListEquals(
|
||||
[
|
||||
['Title' => 'item 1'],
|
||||
['Title' => 'item 2'],
|
||||
],
|
||||
$items
|
||||
);
|
||||
}
|
||||
|
||||
public function testSortingOnJoinTableWithoutTableAlias()
|
||||
{
|
||||
/** @var ManyManyThroughListTest\TestObject $parent */
|
||||
$parent = $this->objFromFixture(ManyManyThroughListTest\TestObject::class, 'parent1');
|
||||
|
||||
$items = $parent->Items()->sort('"Sort"');
|
||||
$this->assertListEquals(
|
||||
[
|
||||
['Title' => 'item 2'],
|
||||
['Title' => 'item 1'],
|
||||
],
|
||||
$items
|
||||
);
|
||||
|
||||
$items = $parent->Items()->sort('"Sort" ASC');
|
||||
$this->assertListEquals(
|
||||
[
|
||||
['Title' => 'item 1'],
|
||||
['Title' => 'item 2'],
|
||||
],
|
||||
$items
|
||||
);
|
||||
|
||||
$items = $parent->Items()->sort('"Title" DESC');
|
||||
$this->assertListEquals(
|
||||
[
|
||||
['Title' => 'item 2'],
|
||||
['Title' => 'item 1'],
|
||||
],
|
||||
$items
|
||||
);
|
||||
|
||||
$items = $parent->Items()->sort('"Title" ASC');
|
||||
$this->assertListEquals(
|
||||
[
|
||||
['Title' => 'item 1'],
|
||||
['Title' => 'item 2'],
|
||||
],
|
||||
$items
|
||||
);
|
||||
}
|
||||
|
||||
public function testAdd()
|
||||
|
Loading…
x
Reference in New Issue
Block a user