mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 17:05:39 +02:00
Add test for getting the correct Sort order from MMTL items, fix incorrect test class name
This commit is contained in:
parent
b221134ce1
commit
78c63c6725
@ -88,6 +88,40 @@ class GridFieldOrderableRowsTest extends SapphireTest
|
||||
$this->assertEquals($desiredOrder, $newOrder);
|
||||
}
|
||||
|
||||
public function testManyManyThroughListSortOrdersAreUsedForInitialRender()
|
||||
{
|
||||
/** @var ThroughDefiner $record */
|
||||
$record = $this->objFromFixture(ThroughDefiner::class, 'DefinerOne');
|
||||
|
||||
$orderable = new GridFieldOrderableRows('Sort');
|
||||
$config = new GridFieldConfig_RelationEditor();
|
||||
$config->addComponent($orderable);
|
||||
|
||||
$grid = new GridField(
|
||||
'Belongings',
|
||||
'Testing Many Many',
|
||||
$record->Belongings()->sort('Sort'),
|
||||
$config
|
||||
);
|
||||
|
||||
// Get the first record, which would be the first one to have column contents generated
|
||||
/** @var ThroughIntermediary $expected */
|
||||
$intermediary = $this->objFromFixture(ThroughIntermediary::class, 'One');
|
||||
|
||||
$result = $orderable->getColumnContent($grid, $record, 'irrelevant');
|
||||
|
||||
$this->assertContains(
|
||||
'Belongings[GridFieldEditableColumns][' . $record->ID . '][Sort]',
|
||||
$result,
|
||||
'The field name is indexed under the record\'s ID'
|
||||
);
|
||||
$this->assertContains(
|
||||
'value="' . $intermediary->Sort . '"',
|
||||
$result,
|
||||
'The value comes from the MMTL intermediary Sort value'
|
||||
);
|
||||
}
|
||||
|
||||
public function testSortableChildClass()
|
||||
{
|
||||
$orderable = new GridFieldOrderableRows('Sort');
|
||||
|
@ -12,7 +12,7 @@ use Symbiote\GridFieldExtensions\Tests\Stub\ThroughIntermediary;
|
||||
use Symbiote\GridFieldExtensions\Tests\Stub\ThroughBelongs;
|
||||
use Symbiote\GridFieldExtensions\GridFieldOrderableRows;
|
||||
|
||||
class OrderableRowsThroughTest extends SapphireTest
|
||||
class OrderableRowsThroughVersionedTest extends SapphireTest
|
||||
{
|
||||
protected static $fixture_file = 'OrderableRowsThroughTest.yml';
|
||||
|
||||
@ -105,7 +105,7 @@ class OrderableRowsThroughTest extends SapphireTest
|
||||
}
|
||||
}
|
||||
$this->assertTrue($differenceFound, 'All records should have changes in draft');
|
||||
|
||||
|
||||
// Verify live stage has NOT reordered
|
||||
Versioned::set_stage(Versioned::LIVE);
|
||||
$sameOrder = $parent->$relationName()->sort($sortName)->column('ID');
|
||||
|
@ -2,18 +2,17 @@
|
||||
|
||||
namespace Symbiote\GridFieldExtensions\Tests\Stub;
|
||||
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\FieldType\DBInt;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class ThroughIntermediary extends DataObject implements TestOnly
|
||||
{
|
||||
private static $table_name = 'IntermediaryThrough';
|
||||
|
||||
private static $db = [
|
||||
'Sort' => DBInt::class,
|
||||
'Sort' => 'Int',
|
||||
];
|
||||
|
||||
|
||||
private static $has_one = [
|
||||
'Defining' => ThroughDefiner::class,
|
||||
'Belonging' => ThroughBelongs::class,
|
||||
|
Loading…
Reference in New Issue
Block a user