From 575bc5b4ecc2c00d94f47f087f8459ac7abbb4a4 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Mon, 19 Aug 2024 09:45:53 +1200 Subject: [PATCH] API Standardise extension hooks --- tests/php/Controller/AssetAdminTest/FileExtension.php | 9 ++++----- tests/php/Controller/AssetAdminTest/FolderExtension.php | 8 ++++---- tests/php/Forms/FileFormBuilderTest.php | 2 +- tests/php/Forms/FileFormBuilderTest/FileExtension.php | 8 ++++---- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/tests/php/Controller/AssetAdminTest/FileExtension.php b/tests/php/Controller/AssetAdminTest/FileExtension.php index 8727d54d0..0bab0c23d 100644 --- a/tests/php/Controller/AssetAdminTest/FileExtension.php +++ b/tests/php/Controller/AssetAdminTest/FileExtension.php @@ -7,29 +7,28 @@ class FileExtension extends DataExtension implements TestOnly { - public function canView($member = null) + protected function canView($member = null) { if ($this->owner->Name === 'disallowCanView.txt') { return false; } } - public function canEdit($member = null) + protected function canEdit($member = null) { if ($this->owner->Name === 'disallowCanEdit.txt') { return false; } } - public function canDelete($member = null) + protected function canDelete($member = null) { if ($this->owner->Name === 'disallowCanDelete.txt') { return false; } } - - public function canCreate($member = null, $context = []) + protected function canCreate($member = null, $context = []) { if (isset($context['Parent']) && $context['Parent']->Name === 'disallowCanAddChildren') { return false; diff --git a/tests/php/Controller/AssetAdminTest/FolderExtension.php b/tests/php/Controller/AssetAdminTest/FolderExtension.php index cfeb5d1a3..7e3713454 100644 --- a/tests/php/Controller/AssetAdminTest/FolderExtension.php +++ b/tests/php/Controller/AssetAdminTest/FolderExtension.php @@ -7,28 +7,28 @@ class FolderExtension extends DataExtension implements TestOnly { - public function canView($member = null, $context = array()) + protected function canView($member = null, $context = array()) { if ($this->owner->Name === 'disallowCanView') { return false; } } - public function canEdit($member = null, $context = array()) + protected function canEdit($member = null, $context = array()) { if ($this->owner->Name === 'disallowCanEdit') { return false; } } - public function canDelete($member = null, $context = array()) + protected function canDelete($member = null, $context = array()) { if ($this->owner->Name === 'disallowCanDelete') { return false; } } - public function canCreate($member = null, $context = array()) + protected function canCreate($member = null, $context = array()) { if (isset($context['Name']) && $context['Name'] === 'disallowCanCreate') { return false; diff --git a/tests/php/Forms/FileFormBuilderTest.php b/tests/php/Forms/FileFormBuilderTest.php index b27928705..407edcf00 100644 --- a/tests/php/Forms/FileFormBuilderTest.php +++ b/tests/php/Forms/FileFormBuilderTest.php @@ -120,7 +120,7 @@ public function testEditFileFormWithPermissions() // Add extension to simulate different permissions File::add_extension(FileExtension::class); - $this->logInWithPermission('ADMIN'); + $this->logInWithPermission('CMS_ACCESS_CampaignAdmin'); /** @var File $file */ $file = $this->objFromFixture(File::class, 'file1'); diff --git a/tests/php/Forms/FileFormBuilderTest/FileExtension.php b/tests/php/Forms/FileFormBuilderTest/FileExtension.php index 89dbde036..e7e9799d7 100644 --- a/tests/php/Forms/FileFormBuilderTest/FileExtension.php +++ b/tests/php/Forms/FileFormBuilderTest/FileExtension.php @@ -17,22 +17,22 @@ class FileExtension extends DataExtension implements TestOnly public static $canUnpublish = true; public static $canEdit = true; - public function canDelete($member) + protected function canDelete($member) { return FileExtension::$canDelete; } - public function canPublish($member = null) + protected function canPublish($member = null) { return FileExtension::$canPublish; } - public function canUnpublish($member = null) + protected function canUnpublish($member = null) { return FileExtension::$canUnpublish; } - public function canEdit($member = null) + protected function canEdit($member = null) { return FileExtension::$canEdit; }