From 887876f8572ac75a2e6f3daee9ff2645b1b116e9 Mon Sep 17 00:00:00 2001 From: Rosie Le Faive Date: Wed, 21 Jun 2023 11:46:09 -0300 Subject: [PATCH 1/5] Add contrib hal and rdf to composer. --- composer.json | 4 +++- jsonld.info.yml | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 3d1a93f..652a24e 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,9 @@ } ], "require" : { - "php": ">=7.4" + "php": ">=7.4", + "drupal/hal": "^1||^2", + "drupal/rdf": "^2.1" }, "require-dev": { "phpunit/phpunit": "^8", diff --git a/jsonld.info.yml b/jsonld.info.yml index 53e9b62..c12cb33 100644 --- a/jsonld.info.yml +++ b/jsonld.info.yml @@ -4,6 +4,6 @@ description: 'Serializes entities to JSON-LD / LDP for the Islandora Project' package: Web services core_version_requirement: ^9 dependencies: - - hal - - serialization - - rdf + - drupal:serialization + - hal:hal + - rdf:rdf From bdbd81f3a17230b96717a5c720d315d82d2ad1fa Mon Sep 17 00:00:00 2001 From: Rosie Le Faive Date: Thu, 22 Jun 2023 10:20:00 -0300 Subject: [PATCH 2/5] Fix deprecations. --- src/ContextGenerator/JsonldContextGenerator.php | 7 +++---- tests/src/Functional/JsonldContextGeneratorTest.php | 4 ++-- tests/src/Kernel/JsonldContextGeneratorTest.php | 2 +- tests/src/Kernel/JsonldHookTest.php | 2 +- tests/src/Kernel/JsonldKernelTestBase.php | 2 +- tests/src/Kernel/JsonldTestEntityGenerator.php | 2 +- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/ContextGenerator/JsonldContextGenerator.php b/src/ContextGenerator/JsonldContextGenerator.php index f9a2cc8..b0ccc7e 100644 --- a/src/ContextGenerator/JsonldContextGenerator.php +++ b/src/ContextGenerator/JsonldContextGenerator.php @@ -333,9 +333,8 @@ protected function getTermContextFromField($field_type) { // yet for this instance. if (empty($this->fieldMappings)) { // Cribbed from rdf module's rdf_get_namespaces. - foreach (\Drupal::moduleHandler()->getImplementations(self::FIELD_MAPPPINGS_HOOK) as $module) { - $function = $module . '_' . self::FIELD_MAPPPINGS_HOOK; - foreach ($function() as $field => $mapping) { + \Drupal::moduleHandler()->invokeAllWith(self::FIELD_MAPPPINGS_HOOK, function (callable $hook, string $module) { + foreach ($hook() as $field => $mapping) { if (array_key_exists($field, $this->fieldMappings)) { $this->logger->warning( t('Tried to map @field_type to @new_type, but @field_type is already mapped to @orig_type.', [ @@ -349,7 +348,7 @@ protected function getTermContextFromField($field_type) { $this->fieldMappings[$field] = $mapping; } } - } + }); } return array_key_exists($field_type, $this->fieldMappings) ? $this->fieldMappings[$field_type] : $default_mapping; } diff --git a/tests/src/Functional/JsonldContextGeneratorTest.php b/tests/src/Functional/JsonldContextGeneratorTest.php index 649e4f3..3f9e0f9 100644 --- a/tests/src/Functional/JsonldContextGeneratorTest.php +++ b/tests/src/Functional/JsonldContextGeneratorTest.php @@ -94,7 +94,7 @@ public function testJsonldcontextContentypeheaderResponseIsValid() { ); $this->drupalGet($url); $this->assertSession()->statusCodeEquals(200); - $this->assertEquals($this->drupalGetHeader('Content-Type'), 'application/ld+json', 'Correct JSON-LD mime type was returned'); + $this->assertEquals($this->getSession()->getResponseHeader('Content-Type'), 'application/ld+json', 'Correct JSON-LD mime type was returned'); } /** @@ -121,7 +121,7 @@ public function testJsonldcontextResponseIsValid() { $this->drupalGet($url); $this->assertSession()->statusCodeEquals(200); $jsonldarray = json_decode($this->getSession()->getPage()->getContent(), TRUE); - $this->verbose($jsonldarray); + dump($jsonldarray); $this->assertEquals($expected, $jsonldarray, "Returned @context matches expected response."); } diff --git a/tests/src/Kernel/JsonldContextGeneratorTest.php b/tests/src/Kernel/JsonldContextGeneratorTest.php index 85d5c99..ecbafe3 100644 --- a/tests/src/Kernel/JsonldContextGeneratorTest.php +++ b/tests/src/Kernel/JsonldContextGeneratorTest.php @@ -17,7 +17,7 @@ class JsonldContextGeneratorTest extends JsonldKernelTestBase { /** * {@inheritdoc} */ - public static $modules = [ + protected static $modules = [ 'entity_test', 'hal', 'jsonld', diff --git a/tests/src/Kernel/JsonldHookTest.php b/tests/src/Kernel/JsonldHookTest.php index b7ae0b7..ccfc17b 100644 --- a/tests/src/Kernel/JsonldHookTest.php +++ b/tests/src/Kernel/JsonldHookTest.php @@ -13,7 +13,7 @@ class JsonldHookTest extends JsonldKernelTestBase { /** * {@inheritdoc} */ - public static $modules = [ + protected static $modules = [ 'entity_test', 'hal', 'jsonld', diff --git a/tests/src/Kernel/JsonldKernelTestBase.php b/tests/src/Kernel/JsonldKernelTestBase.php index 24c8e8f..13d05b4 100644 --- a/tests/src/Kernel/JsonldKernelTestBase.php +++ b/tests/src/Kernel/JsonldKernelTestBase.php @@ -24,7 +24,7 @@ abstract class JsonldKernelTestBase extends KernelTestBase { /** * {@inheritdoc} */ - public static $modules = [ + protected static $modules = [ 'system', 'user', 'field', diff --git a/tests/src/Kernel/JsonldTestEntityGenerator.php b/tests/src/Kernel/JsonldTestEntityGenerator.php index 8d5c4f1..13fca31 100644 --- a/tests/src/Kernel/JsonldTestEntityGenerator.php +++ b/tests/src/Kernel/JsonldTestEntityGenerator.php @@ -158,7 +158,7 @@ public function makeDuplicateReferenceMapping(): JsonldTestEntityGenerator { * Error saving the entity. */ public function generateNewEntity(): array { - $dt = new \DateTime(NULL, new \DateTimeZone('UTC')); + $dt = new \DateTime('now', new \DateTimeZone('UTC')); $created = $dt->format("U"); $created_iso = $dt->format(\DateTime::W3C); // Create an entity. From e5bd2df1e9f9b69a10d8789175760393620a0b76 Mon Sep 17 00:00:00 2001 From: Rosie Le Faive Date: Thu, 22 Jun 2023 10:24:14 -0300 Subject: [PATCH 3/5] Drop 9.3 which isn't compatible with contributed RDF module. --- .github/workflows/build-2.x.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-2.x.yml b/.github/workflows/build-2.x.yml index 230e247..87a8d14 100644 --- a/.github/workflows/build-2.x.yml +++ b/.github/workflows/build-2.x.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: php-versions: ["7.4", "8.0", "8.1"] - drupal-version: ["9.3.x", "9.4.x", "9.5.x-dev"] + drupal-version: ["9.4.x", "9.5.x-dev"] env: DRUPAL_VERSION: ${{ matrix.drupal-version }} From ed0e59f575dec8987eb3362fffd23ef5c24a7a65 Mon Sep 17 00:00:00 2001 From: Rosie Le Faive Date: Thu, 22 Jun 2023 10:36:13 -0300 Subject: [PATCH 4/5] Add requirement of 9.4 to .info.yml. --- jsonld.info.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsonld.info.yml b/jsonld.info.yml index c12cb33..4f80cd0 100644 --- a/jsonld.info.yml +++ b/jsonld.info.yml @@ -2,7 +2,7 @@ name: 'JSON-LD' type: module description: 'Serializes entities to JSON-LD / LDP for the Islandora Project' package: Web services -core_version_requirement: ^9 +core_version_requirement: ^9.4 dependencies: - drupal:serialization - hal:hal From 08d4a516b7ffa8ff62706c859040503f6979f79e Mon Sep 17 00:00:00 2001 From: Rosie Le Faive Date: Thu, 22 Jun 2023 10:38:25 -0300 Subject: [PATCH 5/5] Test on 9.5 released versions. --- .github/workflows/build-2.x.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-2.x.yml b/.github/workflows/build-2.x.yml index 87a8d14..cb0d726 100644 --- a/.github/workflows/build-2.x.yml +++ b/.github/workflows/build-2.x.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: php-versions: ["7.4", "8.0", "8.1"] - drupal-version: ["9.4.x", "9.5.x-dev"] + drupal-version: ["9.4.x", "9.5.x"] env: DRUPAL_VERSION: ${{ matrix.drupal-version }}