From a07928c68bfda17040ccd4bd1b44742466afd5cc Mon Sep 17 00:00:00 2001 From: Stephen Lucero <38796-slucero@users.noreply.drupalcode.org> Date: Wed, 31 Jan 2024 15:09:35 +0000 Subject: [PATCH] Issue #3416288: Bump minimum requirements: PHP 8.1 and Drupal 10.1 --- composer.json | 12 +++++------- .../patternkit_example/patternkit_example.info.yml | 2 +- .../patternkit_media_library.info.yml | 2 +- .../patternkit_usage_tracking.info.yml | 3 +-- .../tests/src/Unit/UsageRevisionHelperTest.php | 10 +++++----- patternkit.info.yml | 4 ++-- src/Entity/Pattern.php | 14 ++++++++++++++ tests/src/Unit/JSONSchemaEditorTraitTest.php | 7 +++++++ tests/src/Unit/PatternElementTest.php | 8 ++++++-- .../PatternFieldProcessor/TokenProcessorTest.php | 8 ++++++-- tests/src/Unit/Schema/SchemaRefHandlerTest.php | 7 +++++++ 11 files changed, 55 insertions(+), 22 deletions(-) diff --git a/composer.json b/composer.json index 64fa0f27..2e4913d1 100644 --- a/composer.json +++ b/composer.json @@ -14,16 +14,14 @@ ], "license": "MIT", "require": { - "php": ">=7.4.0", + "php": ">=8.1", "ext-json": "*", "marcj/topsort": "^2.0.0", "swaggest/json-schema": "^0.12", - "symfony/finder": "^3.4 || ^4 || ^6", - "symfony/polyfill-php80": "^1", - "symfony/polyfill-php81": "^1", - "symfony/serializer": "^3.4 || ^4 || ^6", - "symfony/property-access": "^3.4 || ^4 || ^6", - "symfony/yaml": "^3.4 || ^4 || ^6", + "symfony/finder": "^4 || ^5 || ^6", + "symfony/serializer": "^4 || ^5 || ^6", + "symfony/property-access": "^4 || ^5 || ^6", + "symfony/yaml": "^4 || ^5 || ^6", "webmozart/assert": "^1.0", "webmozart/path-util": "^2.1.0" }, diff --git a/modules/patternkit_example/patternkit_example.info.yml b/modules/patternkit_example/patternkit_example.info.yml index 17dcf0df..971767df 100644 --- a/modules/patternkit_example/patternkit_example.info.yml +++ b/modules/patternkit_example/patternkit_example.info.yml @@ -2,6 +2,6 @@ name: Patternkit Example description: Adds Patternkit example patterns. type: module package: Presentation Framework -core_version_requirement: ^9 || ^10 +core_version_requirement: ^10 dependencies: - patternkit diff --git a/modules/patternkit_media_library/patternkit_media_library.info.yml b/modules/patternkit_media_library/patternkit_media_library.info.yml index 885f0667..7baba111 100644 --- a/modules/patternkit_media_library/patternkit_media_library.info.yml +++ b/modules/patternkit_media_library/patternkit_media_library.info.yml @@ -2,7 +2,7 @@ name: Patternkit Media Library Support description: Adds Media Library Support to upload fields. type: module package: Presentation Framework -core_version_requirement: ^9 || ^10 +core_version_requirement: ^10 configure: patternkit.settings dependencies: - drupal:media_library diff --git a/modules/patternkit_usage_tracking/patternkit_usage_tracking.info.yml b/modules/patternkit_usage_tracking/patternkit_usage_tracking.info.yml index ab854cbe..ca135463 100644 --- a/modules/patternkit_usage_tracking/patternkit_usage_tracking.info.yml +++ b/modules/patternkit_usage_tracking/patternkit_usage_tracking.info.yml @@ -2,8 +2,7 @@ name: Patternkit Usage Tracking description: Adds tracking for where patterns are in use. type: module package: Presentation Framework -core_version_requirement: ^9 || ^10 +core_version_requirement: ^10 dependencies: - patternkit:patternkit -php: 7.4 lifecycle: experimental diff --git a/modules/patternkit_usage_tracking/tests/src/Unit/UsageRevisionHelperTest.php b/modules/patternkit_usage_tracking/tests/src/Unit/UsageRevisionHelperTest.php index 1eed733f..7f321583 100644 --- a/modules/patternkit_usage_tracking/tests/src/Unit/UsageRevisionHelperTest.php +++ b/modules/patternkit_usage_tracking/tests/src/Unit/UsageRevisionHelperTest.php @@ -613,7 +613,7 @@ class UsageRevisionHelperTest extends UnitTestCase { 'component_uuid' => $uuids[1], 'pattern_id' => $patterns['nested'], 'is_nested' => TRUE, - 'content_path' => $nested_path = "$patterns[1]=>${patterns['nested']}", + 'content_path' => $nested_path = "$patterns[1]=>{$patterns['nested']}", 'layout_path' => "1.$uuids[1]:$nested_path", ], ], @@ -696,7 +696,7 @@ class UsageRevisionHelperTest extends UnitTestCase { 'register' => [ [ $patterns['nested'], - "1.$uuids[1]:" . ($nested_path = "$patterns[1]=>${patterns['nested']}"), + "1.$uuids[1]:" . ($nested_path = "$patterns[1]=>{$patterns['nested']}"), ], ], 'update' => [ @@ -769,7 +769,7 @@ class UsageRevisionHelperTest extends UnitTestCase { 'component_uuid' => $uuids[1], 'pattern_id' => $patterns['nested'], 'is_nested' => TRUE, - 'content_path' => $nested_path = "$patterns[1]=>${patterns['nested']}", + 'content_path' => $nested_path = "$patterns[1]=>{$patterns['nested']}", 'layout_path' => "1.$uuids[1]:$nested_path", ], ], @@ -848,7 +848,7 @@ class UsageRevisionHelperTest extends UnitTestCase { // Register the new nested pattern. [ $patterns['nested'], - "1.$uuids[1]:" . ($nested_path = "$patterns[1]=>${patterns['nested']}"), + "1.$uuids[1]:" . ($nested_path = "$patterns[1]=>{$patterns['nested']}"), ], ], 'update' => [ @@ -934,7 +934,7 @@ class UsageRevisionHelperTest extends UnitTestCase { // Register a new nested pattern within the updated component. [ $patterns['nested'], - "2.$uuids[1]:" . ($new_nested_path = "$patterns[1]=>${patterns['nested']}"), + "2.$uuids[1]:" . ($new_nested_path = "$patterns[1]=>{$patterns['nested']}"), ], ], 'update' => [ diff --git a/patternkit.info.yml b/patternkit.info.yml index a4c7e407..3dd3d8b0 100644 --- a/patternkit.info.yml +++ b/patternkit.info.yml @@ -2,8 +2,8 @@ name: Patternkit description: Adds Patternkit patterns as blocks. type: module package: Presentation Framework -core_version_requirement: ^9 || ^10 +core_version_requirement: ^10 configure: patternkit.settings dependencies: - drupal:block_content -php: 7.4 +php: 8.1 diff --git a/src/Entity/Pattern.php b/src/Entity/Pattern.php index fb6fe06e..0e59d8f4 100644 --- a/src/Entity/Pattern.php +++ b/src/Entity/Pattern.php @@ -73,6 +73,20 @@ class Pattern extends ContentEntityBase implements PatternInterface { */ protected bool $bundled = FALSE; + /** + * An array of the current Pattern instance's configuration values. + * + * @var array + */ + public array $config = []; + + /** + * An array of the current Pattern instance's contexts. + * + * @var array + */ + public array $context = []; + /** * Constructs a new Pattern object, without permanently saving it. * diff --git a/tests/src/Unit/JSONSchemaEditorTraitTest.php b/tests/src/Unit/JSONSchemaEditorTraitTest.php index f42ffec8..52003e0e 100644 --- a/tests/src/Unit/JSONSchemaEditorTraitTest.php +++ b/tests/src/Unit/JSONSchemaEditorTraitTest.php @@ -36,6 +36,13 @@ class JSONSchemaEditorTraitTest extends UnitTestCase { */ protected ObjectProphecy $fileUrlGenerator; + /** + * A mocked editor plugin manager service. + * + * @var \Prophecy\Prophecy\ObjectProphecy<\Drupal\editor\Plugin\EditorManager> + */ + protected ObjectProphecy $editorPluginManager; + /** * A mocked query string service. * diff --git a/tests/src/Unit/PatternElementTest.php b/tests/src/Unit/PatternElementTest.php index 6e015a07..5ef8171a 100644 --- a/tests/src/Unit/PatternElementTest.php +++ b/tests/src/Unit/PatternElementTest.php @@ -4,6 +4,7 @@ namespace Drupal\Tests\patternkit\Unit; use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\patternkit\Element\Pattern; +use Drupal\patternkit\Entity\Pattern as EntityPattern; use Drupal\patternkit\Entity\PatternInterface; use Drupal\patternkit\Exception\SchemaValidationException; use Drupal\patternkit\Exception\UnknownPatternException; @@ -173,7 +174,7 @@ class PatternElementTest extends RendererTestBase { ]; $this->libraryPlugin->expects($this->once()) ->method('render') - ->with($this->callback(function ($arg) use ($patternMock, $element) { + ->with($this->callback(function ($arg) use ($patternMock): bool { return $arg[0] == $patternMock; })) ->willReturn($returnValue); @@ -283,7 +284,10 @@ class PatternElementTest extends RendererTestBase { * A mocked pattern entity for testing. */ protected function getPatternMock(): PatternInterface { - $patternMock = $this->createMock(PatternInterface::class); + // Mock the implementation class instead of the interface to sidestep + // assignment to dynamic property deprecation warnings for instance + // variables declared on the class. + $patternMock = $this->createMock(EntityPattern::class); $patternMock->expects($this->once()) ->method('getCacheTags') ->willReturn([]); diff --git a/tests/src/Unit/Plugin/PatternFieldProcessor/TokenProcessorTest.php b/tests/src/Unit/Plugin/PatternFieldProcessor/TokenProcessorTest.php index a9c3b7ce..a96bde14 100644 --- a/tests/src/Unit/Plugin/PatternFieldProcessor/TokenProcessorTest.php +++ b/tests/src/Unit/Plugin/PatternFieldProcessor/TokenProcessorTest.php @@ -176,7 +176,9 @@ JSON; $randomTitle = $this->getRandomGenerator()->name(); $expected = str_replace('[node:title]', $randomTitle, $value); $node = $this->createMock(NodeInterface::class); - $node->title = $randomTitle; + $node->method('get') + ->with('title') + ->willReturn($randomTitle); // Ensure the replacePlain method is not invoked for html formatted strings. $this->token->expects($this->never()) @@ -212,7 +214,9 @@ JSON; $randomTitle = $this->getRandomGenerator()->name(); $expected = str_replace('[node:title]', $randomTitle, $value); $node = $this->createMock(NodeInterface::class); - $node->title = $randomTitle; + $node->method('get') + ->with('title') + ->willReturn($randomTitle); // Ensure the replace method is not invoked for plain text strings. $this->token->expects($this->never()) diff --git a/tests/src/Unit/Schema/SchemaRefHandlerTest.php b/tests/src/Unit/Schema/SchemaRefHandlerTest.php index 776f590c..f7649980 100644 --- a/tests/src/Unit/Schema/SchemaRefHandlerTest.php +++ b/tests/src/Unit/Schema/SchemaRefHandlerTest.php @@ -13,6 +13,13 @@ use Drupal\Tests\UnitTestCase; */ class SchemaRefHandlerTest extends UnitTestCase { + /** + * The schema ref handler instance being tested. + * + * @var \Drupal\patternkit\Schema\SchemaRefHandler + */ + protected SchemaRefHandler $schemaRefHandler; + /** * {@inheritdoc} */ -- GitLab