diff --git a/.gitignore b/.gitignore index 66f6d1d..0691b81 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /.buildpath /.project /.settings +/.phpunit.result.cache diff --git a/README.md b/README.md index 7ff13f7..18e3cef 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ SilverStripe GridField Deleted Items ================= -[![CI](https://github.com/webbuilders-group/silverstripe-gridfield-deleted-items/actions/workflows/ci.yml/badge.svg)](https://github.com/webbuilders-group/silverstripe-versioned-helpers/actions/workflows/ci.yml) +[![CI](https://github.com/webbuilders-group/silverstripe-gridfield-deleted-items/actions/workflows/ci.yml/badge.svg)](https://github.com/webbuilders-group/silverstripe-gridfield-deleted-items/actions/workflows/ci.yml) Provides a series of components that allows you to view versioned objects that have been deleted from the draft site. diff --git a/tests/Forms/GridField/GridFieldDeletedTest.php b/tests/Forms/GridField/GridFieldDeletedTest.php index 96997bf..c90857e 100644 --- a/tests/Forms/GridField/GridFieldDeletedTest.php +++ b/tests/Forms/GridField/GridFieldDeletedTest.php @@ -3,10 +3,7 @@ use SilverStripe\Control\Controller; use SilverStripe\Control\HTTPRequest; -use SilverStripe\Control\Session; -use SilverStripe\Core\Injector\Injector; use SilverStripe\Dev\FunctionalTest; -use SilverStripe\Dev\TestOnly; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; use SilverStripe\Forms\GridField\GridField; @@ -14,29 +11,29 @@ use SilverStripe\Forms\GridField\GridFieldDataColumns; use SilverStripe\Forms\GridField\GridFieldEditButton; use SilverStripe\Forms\GridField\GridFieldToolbarHeader; -use SilverStripe\ORM\DataObject; use SilverStripe\Versioned\Versioned; use WebbuildersGroup\GridFieldDeletedItems\Forms\GridFieldDeletedColumns; -use WebbuildersGroup\GridFieldDeletedItems\Forms\GridFieldDeletedDeleteAction; use WebbuildersGroup\GridFieldDeletedItems\Forms\GridFieldDeletedEditButton; use WebbuildersGroup\GridFieldDeletedItems\Forms\GridFieldDeletedManipulator; use WebbuildersGroup\GridFieldDeletedItems\Forms\GridFieldDeletedRestoreButton; use WebbuildersGroup\GridFieldDeletedItems\Forms\GridFieldDeletedToggle; +use WebbuildersGroup\GridFieldDeletedItems\Tests\GridFieldDeletedTest\DummyController; +use WebbuildersGroup\GridFieldDeletedItems\Tests\GridFieldDeletedTest\TestObject; class GridFieldDeletedTest extends FunctionalTest { protected static $fixture_file = 'GridFieldDeletedTest.yml'; - protected static $extra_dataobjects = [GridFieldDeletedTest\TestObject::class]; + protected static $extra_dataobjects = [TestObject::class]; protected $list; protected $gridField; protected $form; - public function setUp() + protected function setUp(): void { parent::setUp(); - $this->list = GridFieldDeletedTest\TestObject::get(); + $this->list = TestObject::get(); $config = GridFieldConfig_RecordEditor::create(10) ->removeComponentsByType(GridFieldDataColumns::class) ->removeComponentsByType(GridFieldEditButton::class) @@ -47,7 +44,7 @@ public function setUp() ->addComponent(new GridFieldDeletedToggle('buttons-before-left')); $this->gridField = new GridField('testfield', 'testfield', $this->list, $config); - $this->form = new Form(new GridFieldDeletedTest\DummyController(), 'mockform', new FieldList([$this->gridField]), new FieldList()); + $this->form = new Form(new DummyController(), 'mockform', new FieldList([$this->gridField]), new FieldList()); } /** @@ -56,7 +53,7 @@ public function setUp() public function testToggleShowDeleted() { $deletedIDs = []; - $list = GridFieldDeletedTest\TestObject::get(); + $list = TestObject::get(); foreach ($list as $item) { if ($item->ID % 2 == 0) { $deletedIDs[] = $item->ID; @@ -103,13 +100,13 @@ public function testToggleShowDeleted() public function testRestoreDeleted() { // Load the item to delete and capture it's id then delete it - $deletedItem = $this->objFromFixture(GridFieldDeletedTest\TestObject::class, 'testobj2'); + $deletedItem = $this->objFromFixture(TestObject::class, 'testobj2'); $deletedItemID = $deletedItem->ID; $deletedItem->delete(); // Make sure the item was deleted - $this->assertNull(Versioned::get_one_by_stage(GridFieldDeletedTest\TestObject::class, 'Stage', '"ID"=' . $deletedItemID), 'Item was not deleted prior to restoring'); + $this->assertNull(Versioned::get_one_by_stage(TestObject::class, 'Stage', '"ID"=' . $deletedItemID), 'Item was not deleted prior to restoring'); // Attempt to restore the item @@ -123,8 +120,8 @@ public function testRestoreDeleted() // Check to see if the item exists again - $item = Versioned::get_one_by_stage(GridFieldDeletedTest\TestObject::class, 'Stage', '"Title"=\'Test Object 2\''); - $this->assertInstanceOf(GridFieldDeletedTest\TestObject::class, $item, 'Could not find the item after restoring'); + $item = Versioned::get_one_by_stage(TestObject::class, 'Stage', '"Title"=\'Test Object 2\''); + $this->assertInstanceOf(TestObject::class, $item, 'Could not find the item after restoring'); $this->assertTrue($item->exists(), 'Could not find the item after restoring'); } @@ -134,7 +131,7 @@ public function testRestoreDeleted() public function testDeletedNoEdit() { // Load the item to delete and capture it's id then delete it - $deletedItem = $this->objFromFixture(GridFieldDeletedTest\TestObject::class, 'testobj2'); + $deletedItem = $this->objFromFixture(TestObject::class, 'testobj2'); $deletedItem->delete(); @@ -147,7 +144,7 @@ public function testDeletedNoEdit() // Verify we have an array and the class attribute exists - $this->assertInternalType('array', $attributes); + $this->assertIsArray($attributes); $this->assertArrayHasKey('class', $attributes); @@ -157,11 +154,11 @@ public function testDeletedNoEdit() // Get the attributes for a non-deleted item - $attributes = $this->gridField->getConfig()->getComponentByType(GridFieldDeletedColumns::class)->getColumnAttributes($this->gridField, $this->objFromFixture(GridFieldDeletedTest\TestObject::class, 'testobj1'), 'Title'); + $attributes = $this->gridField->getConfig()->getComponentByType(GridFieldDeletedColumns::class)->getColumnAttributes($this->gridField, $this->objFromFixture(TestObject::class, 'testobj1'), 'Title'); // Verify we have an array and the class attribute exists - $this->assertInternalType('array', $attributes); + $this->assertIsArray($attributes); $this->assertArrayHasKey('class', $attributes); diff --git a/tests/Forms/GridField/GridFieldDeletedTest/TestObject.php b/tests/Forms/GridField/GridFieldDeletedTest/TestObject.php index e558efd..75a36a5 100644 --- a/tests/Forms/GridField/GridFieldDeletedTest/TestObject.php +++ b/tests/Forms/GridField/GridFieldDeletedTest/TestObject.php @@ -4,7 +4,6 @@ use SilverStripe\Dev\TestOnly; use SilverStripe\ORM\DataObject; use SilverStripe\Versioned\Versioned; -use WebbuildersGroup\GridFieldDeletedItems\Tests\GridFieldDeletedTest_TestObject; class TestObject extends DataObject implements TestOnly {