Skip to content

Commit

Permalink
Increase test coverage of orderable rows
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Penny committed Jul 7, 2022
1 parent f7b2408 commit 07fd599
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/GridFieldOrderableRowsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor;
use Symbiote\GridFieldExtensions\GridFieldOrderableRows;
use Symbiote\GridFieldExtensions\Tests\Stub\PolymorphM2MChild;
use Symbiote\GridFieldExtensions\Tests\Stub\PolymorphM2MMapper;
use Symbiote\GridFieldExtensions\Tests\Stub\PolymorphM2MParent;
use Symbiote\GridFieldExtensions\Tests\Stub\StubOrderableChild;
Expand All @@ -17,9 +16,12 @@
use Symbiote\GridFieldExtensions\Tests\Stub\StubSubclass;
use Symbiote\GridFieldExtensions\Tests\Stub\StubSubclassOrderedVersioned;
use Symbiote\GridFieldExtensions\Tests\Stub\StubUnorderable;
use Symbiote\GridFieldExtensions\Tests\Stub\ThroughBelongs;
use Symbiote\GridFieldExtensions\Tests\Stub\ThroughBelongsVersioned;
use Symbiote\GridFieldExtensions\Tests\Stub\ThroughDefiner;
use Symbiote\GridFieldExtensions\Tests\Stub\ThroughDefinerVersioned;
use Symbiote\GridFieldExtensions\Tests\Stub\ThroughIntermediary;
use Symbiote\GridFieldExtensions\Tests\Stub\ThroughBelongs;
use Symbiote\GridFieldExtensions\Tests\Stub\ThroughIntermediaryVersioned;

/**
* Tests for the {@link GridFieldOrderableRows} component.
Expand All @@ -46,13 +48,20 @@ class GridFieldOrderableRowsTest extends SapphireTest
ThroughDefiner::class,
ThroughIntermediary::class,
ThroughBelongs::class,
ThroughDefinerVersioned::class,
ThroughIntermediaryVersioned::class,
ThroughBelongsVersioned::class,
];

public function reorderItemsProvider()
{
return [
[StubParent::class . '.parent', 'MyHasMany', 'Sort'],
[StubParent::class . '.parent', 'MyHasManySubclass', 'Sort'],
[StubParent::class . '.parent-subclass-ordered-versioned', 'MyHasManySubclassOrderedVersioned', 'Sort'],
[StubParent::class . '.parent', 'MyManyMany', 'ManyManySort'],
[ThroughDefiner::class . '.DefinerOne', 'Belongings', 'Sort'],
[ThroughDefinerVersioned::class . '.DefinerOne', 'Belongings', 'Sort'],
// [PolymorphM2MParent::class . '.ParentOne', 'Children', 'Sort']
];
}
Expand Down
29 changes: 29 additions & 0 deletions tests/GridFieldOrderableRowsTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Symbiote\GridFieldExtensions\Tests\Stub\StubOrderableChild:
Sort: 3
item4:
Sort: 4

Symbiote\GridFieldExtensions\Tests\Stub\StubOrdered:
item1:
Sort: 1
Expand All @@ -27,6 +28,20 @@ Symbiote\GridFieldExtensions\Tests\Stub\StubOrdered:
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubOrderableChild.item3
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubOrderableChild.item4

Symbiote\GridFieldExtensions\Tests\Stub\StubSubclass:
item1:
Sort: 1
item2:
Sort: 2
item3:
Sort: 3
item4:
Sort: 4
item5:
Sort: 5
item6:
Sort: 6

Symbiote\GridFieldExtensions\Tests\Stub\StubSubclassOrderedVersioned:
item1:
ExtraField: 1
Expand Down Expand Up @@ -56,6 +71,20 @@ Symbiote\GridFieldExtensions\Tests\Stub\StubParent:
ManyManySort: 108
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubOrdered.item6:
ManyManySort: 108
MyHasMany:
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubOrdered.item1
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubOrdered.item2
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubOrdered.item3
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubOrdered.item4
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubOrdered.item5
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubOrdered.item6
MyHasManySubclass:
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubSubclass.item1
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubSubclass.item2
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubSubclass.item3
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubSubclass.item4
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubSubclass.item5
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubSubclass.item6
parent-subclass-ordered-versioned:
MyHasManySubclassOrderedVersioned:
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubSubclassOrderedVersioned.item1
Expand Down
31 changes: 31 additions & 0 deletions tests/OrderableRowsThroughTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,34 @@ Symbiote\GridFieldExtensions\Tests\Stub\ThroughIntermediary:
Defining: =>Symbiote\GridFieldExtensions\Tests\Stub\ThroughDefiner.DefinerTwo
Belonging: =>Symbiote\GridFieldExtensions\Tests\Stub\ThroughBelongs.BelongsThree
Sort: 2

Symbiote\GridFieldExtensions\Tests\Stub\ThroughDefinerVersioned:
DefinerOne:
DefinerTwo:

Symbiote\GridFieldExtensions\Tests\Stub\ThroughBelongsVersioned:
BelongsOne:
BelongsTwo:
BelongsThree:

Symbiote\GridFieldExtensions\Tests\Stub\ThroughIntermediaryVersioned:
One:
Defining: =>Symbiote\GridFieldExtensions\Tests\Stub\ThroughDefinerVersioned.DefinerOne
Belonging: =>Symbiote\GridFieldExtensions\Tests\Stub\ThroughBelongsVersioned.BelongsOne
Sort: 3
Two:
Defining: =>Symbiote\GridFieldExtensions\Tests\Stub\ThroughDefinerVersioned.DefinerOne
Belonging: =>Symbiote\GridFieldExtensions\Tests\Stub\ThroughBelongsVersioned.BelongsTwo
Sort: 2
Three:
Defining: =>Symbiote\GridFieldExtensions\Tests\Stub\ThroughDefinerVersioned.DefinerOne
Belonging: =>Symbiote\GridFieldExtensions\Tests\Stub\ThroughBelongsVersioned.BelongsThree
Sort: 1
Four:
Defining: =>Symbiote\GridFieldExtensions\Tests\Stub\ThroughDefinerVersioned.DefinerTwo
Belonging: =>Symbiote\GridFieldExtensions\Tests\Stub\ThroughBelongsVersioned.BelongsTwo
Sort: 1
Five:
Defining: =>Symbiote\GridFieldExtensions\Tests\Stub\ThroughDefinerVersioned.DefinerTwo
Belonging: =>Symbiote\GridFieldExtensions\Tests\Stub\ThroughBelongsVersioned.BelongsThree
Sort: 2
25 changes: 25 additions & 0 deletions tests/Stub/ThroughBelongsVersioned.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Symbiote\GridFieldExtensions\Tests\Stub;

use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\Versioned\Versioned;

/**
* @method ManyManyList|ThroughDefinerVersioned[] Definers()
* @mixin Versioned
*/
class ThroughBelongsVersioned extends DataObject implements TestOnly
{
private static string $table_name = 'ThroughBelongsVersioned';

private static array $belongs_many_many = [
'Definers' => ThroughDefinerVersioned::class,
];

private static array $extensions = [
Versioned::class,
];
}
33 changes: 33 additions & 0 deletions tests/Stub/ThroughDefinerVersioned.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Symbiote\GridFieldExtensions\Tests\Stub;

use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ManyManyThroughList;
use SilverStripe\Versioned\Versioned;

/**
* @method ManyManyThroughList|ThroughIntermediaryVersioned Belongings()
* @mixin Versioned
*/
class ThroughDefinerVersioned extends DataObject implements TestOnly
{
private static string $table_name = 'ThroughDefinerVersioned';

private static array $many_many = [
'Belongings' => [
'through' => ThroughIntermediaryVersioned::class,
'from' => 'Defining',
'to' => 'Belonging',
]
];

private static array $owns = [
'Belongings'
];

private static array $extensions = [
Versioned::class,
];
}
32 changes: 32 additions & 0 deletions tests/Stub/ThroughIntermediaryVersioned.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Symbiote\GridFieldExtensions\Tests\Stub;

use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\DataObject;
use SilverStripe\Versioned\Versioned;

/**
* @property int $DefiningID
* @property int $BelongingID
* @method ThroughDefinerVersioned Defining()
* @method ThroughBelongsVersioned Belonging()
* @mixin Versioned
*/
class ThroughIntermediaryVersioned extends DataObject implements TestOnly
{
private static string $table_name = 'ThroughIntermediaryVersioned';

private static array $db = [
'Sort' => 'Int',
];

private static array $has_one = [
'Defining' => ThroughDefinerVersioned::class,
'Belonging' => ThroughBelongsVersioned::class,
];

private static array $extensions = [
Versioned::class,
];
}

0 comments on commit 07fd599

Please sign in to comment.