Skip to content

Commit

Permalink
Merge pull request #340 from creative-commoners/pulls/3/protect-hooks
Browse files Browse the repository at this point in the history
API Set extension hook implementation visibility to protected
  • Loading branch information
GuySartorelli authored May 21, 2024
2 parents 92f7bbf + 4e70426 commit eb0318d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Extensions/ArchiveRestoreAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/Extensions/UsedOnTableExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class UsedOnTableExtension extends Extension
/**
* @var array $excludedClasses
*/
public function updateUsageExcludedClasses(array &$excludedClasses)
protected function updateUsageExcludedClasses(array &$excludedClasses)
{
$excludedClasses[] = ChangeSetItem::class;
}
Expand Down
9 changes: 8 additions & 1 deletion tests/Extensions/ArchiveRestoreActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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'));
}
Expand Down

0 comments on commit eb0318d

Please sign in to comment.