From 2b9d9833b3c706a56a54b7c725f42afca90674a5 Mon Sep 17 00:00:00 2001 From: Sabina Talipova Date: Tue, 13 Dec 2022 17:42:43 +1300 Subject: [PATCH] DEP PHP Support in CMS5 --- code/Control/UserDefinedFormAdmin.php | 2 +- .../EditableMultipleOptionField.php | 2 +- composer.json | 16 ++++++++-------- .../Control/UserDefinedFormControllerTest.php | 8 +++----- tests/php/Model/SubmittedFileFieldTest.php | 3 ++- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/code/Control/UserDefinedFormAdmin.php b/code/Control/UserDefinedFormAdmin.php index 780fdb1..1fec7de 100644 --- a/code/Control/UserDefinedFormAdmin.php +++ b/code/Control/UserDefinedFormAdmin.php @@ -80,7 +80,7 @@ class UserDefinedFormAdmin extends LeftAndMain } - public function index($request) + public function index(HTTPRequest $request): HTTPResponse { // Don't serve anythign under the main URL. return $this->httpError(404); diff --git a/code/Model/EditableFormField/EditableMultipleOptionField.php b/code/Model/EditableFormField/EditableMultipleOptionField.php index dbd8625..cb9add6 100644 --- a/code/Model/EditableFormField/EditableMultipleOptionField.php +++ b/code/Model/EditableFormField/EditableMultipleOptionField.php @@ -120,7 +120,7 @@ class EditableMultipleOptionField extends EditableFormField * @param string $manyMany @deprecated * {@inheritDoc} */ - public function duplicate($doWrite = true, $manyMany = 'many_many') + public function duplicate(bool $doWrite = true, ?array $manyMany = null): static { $clonedNode = parent::duplicate(true); diff --git a/composer.json b/composer.json index f73f6fa..4841b25 100644 --- a/composer.json +++ b/composer.json @@ -30,17 +30,17 @@ } ], "require": { - "php": "^7.4 || ^8.0", - "silverstripe/framework": "^4.10", - "silverstripe/cms": "^4.6", - "symbiote/silverstripe-gridfieldextensions": "^3.1", - "silverstripe/segment-field": "^2.2", - "silverstripe/versioned": "^1.0", - "silverstripe/mimevalidator": "^2.0" + "php": "^8.1", + "silverstripe/framework": "^5", + "silverstripe/cms": "^5", + "symbiote/silverstripe-gridfieldextensions": "^4", + "silverstripe/segment-field": "^3", + "silverstripe/versioned": "^2", + "silverstripe/mimevalidator": "^3" }, "require-dev": { "phpunit/phpunit": "^9.5", - "squizlabs/php_codesniffer": "^3.0" + "squizlabs/php_codesniffer": "^3" }, "conflict": { "egulias/email-validator": "^2" diff --git a/tests/php/Control/UserDefinedFormControllerTest.php b/tests/php/Control/UserDefinedFormControllerTest.php index 8ccd362..4530cb2 100644 --- a/tests/php/Control/UserDefinedFormControllerTest.php +++ b/tests/php/Control/UserDefinedFormControllerTest.php @@ -37,8 +37,6 @@ class UserDefinedFormControllerTest extends FunctionalTest { protected static $fixture_file = '../UserFormsTest.yml'; - protected static $use_draft_site = true; - protected static $disable_themes = true; protected function setUp(): void @@ -109,7 +107,7 @@ class UserDefinedFormControllerTest extends FunctionalTest $this->assertEmailSent('nohtml@example.com', 'no-reply@example.com', 'Email Subject'); $nohtml = $this->findEmail('nohtml@example.com', 'no-reply@example.com', 'Email Subject'); - $this->assertStringContainsString('Basic Text Field: Basic Value', $nohtml['Content'], 'Email contains no html'); + $this->assertStringContainsString('* Basic Value HTML', $nohtml['Content'], 'Email contains no html'); // submitted html tags are not escaped because the email is being sent as text/plain $value = 'My body text Basic Value HTML'; @@ -132,8 +130,8 @@ class UserDefinedFormControllerTest extends FunctionalTest // check that multiple email addresses are supported in to and from $this->assertEmailSent( - 'test1@example.com; test2@example.com', - 'test3@example.com; test4@example.com', + 'test1@example.com, test2@example.com', + 'test3@example.com, test4@example.com', 'Test Email' ); } diff --git a/tests/php/Model/SubmittedFileFieldTest.php b/tests/php/Model/SubmittedFileFieldTest.php index 9db30dc..b1e568b 100644 --- a/tests/php/Model/SubmittedFileFieldTest.php +++ b/tests/php/Model/SubmittedFileFieldTest.php @@ -83,7 +83,8 @@ class SubmittedFileFieldTest extends SapphireTest ), $this->submittedFile->getFormattedValue()->value ); - + + $this->logOut(); $this->loginWithPermission('CMS_ACCESS_CMSMain'); $this->assertEquals( sprintf(