From 4e704268455948faee2968d4e044c6722082249e Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Mon, 20 May 2024 15:28:40 +1200 Subject: [PATCH] API Set extension hook implementation visibility to protected --- src/Extensions/ArchiveRestoreAction.php | 2 +- src/Extensions/UsedOnTableExtension.php | 2 +- tests/Extensions/ArchiveRestoreActionTest.php | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Extensions/ArchiveRestoreAction.php b/src/Extensions/ArchiveRestoreAction.php index a0c6e91..5d81160 100644 --- a/src/Extensions/ArchiveRestoreAction.php +++ b/src/Extensions/ArchiveRestoreAction.php @@ -28,7 +28,7 @@ class ArchiveRestoreAction extends DataExtension * @param Form $form * @return mixed */ - public function updateItemEditForm(Form $form) + protected function updateItemEditForm(Form $form) { $record = $this->owner->getRecord(); diff --git a/src/Extensions/UsedOnTableExtension.php b/src/Extensions/UsedOnTableExtension.php index 7aa55a8..fbab16c 100644 --- a/src/Extensions/UsedOnTableExtension.php +++ b/src/Extensions/UsedOnTableExtension.php @@ -14,7 +14,7 @@ class UsedOnTableExtension extends Extension /** * @var array $excludedClasses */ - public function updateUsageExcludedClasses(array &$excludedClasses) + protected function updateUsageExcludedClasses(array &$excludedClasses) { $excludedClasses[] = ChangeSetItem::class; } diff --git a/tests/Extensions/ArchiveRestoreActionTest.php b/tests/Extensions/ArchiveRestoreActionTest.php index 6ea5dc0..c0b24b4 100644 --- a/tests/Extensions/ArchiveRestoreActionTest.php +++ b/tests/Extensions/ArchiveRestoreActionTest.php @@ -18,6 +18,8 @@ use SilverStripe\Versioned\VersionedGridFieldItemRequest; use SilverStripe\VersionedAdmin\ArchiveAdmin; use SilverStripe\VersionedAdmin\Tests\Controllers\HistoryViewerControllerTest\ViewableVersionedObject; +use ReflectionMethod; +use SilverStripe\VersionedAdmin\Extensions\ArchiveRestoreAction; class ArchiveRestoreActionTest extends SapphireTest { @@ -79,7 +81,12 @@ public function testUpdateItemEditForm() 'test' ); - $itemRequest->updateItemEditForm($form); + $ext = new ArchiveRestoreAction(); + $method = new ReflectionMethod(ArchiveRestoreAction::class, 'updateItemEditForm'); + $method->setAccessible(true); + $ext->setOwner($itemRequest); + $method->invokeArgs($ext, [$form]); + $actions = $form->Actions(); $this->assertInstanceOf(FormAction::class, $actions->fieldByName('action_doRestore')); }