From 766a6433c6b389e4f7b8807f60350730de5fa8bd Mon Sep 17 00:00:00 2001 From: dannylamb Date: Mon, 9 Dec 2019 19:27:37 +0000 Subject: [PATCH] Tests, coding standards --- islandora.module | 5 +++-- tests/src/Functional/JsonldSelfReferenceReactionTest.php | 8 ++++++++ tests/src/Functional/JsonldTypeAlterReactionTest.php | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/islandora.module b/islandora.module index eb522ba7..2cae3270 100644 --- a/islandora.module +++ b/islandora.module @@ -14,6 +14,7 @@ * @author Diego Pino Navarro https://github.com/diegopino */ +use Drupal\Component\Plugin\Exception\PluginNotFoundException; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormStateInterface; @@ -259,8 +260,8 @@ function islandora_jsonld_alter_normalized_array(EntityInterface $entity, array $context['cacheability']->addCacheTags($context_config->getCacheTags()); }; } - catch (Drupal\Component\Plugin\Exception\PluginNotFoundException $e) { - // Squash :( + catch (PluginNotFoundException $e) { + // Squash :(. } } } diff --git a/tests/src/Functional/JsonldSelfReferenceReactionTest.php b/tests/src/Functional/JsonldSelfReferenceReactionTest.php index 6311cb17..0026b289 100644 --- a/tests/src/Functional/JsonldSelfReferenceReactionTest.php +++ b/tests/src/Functional/JsonldSelfReferenceReactionTest.php @@ -98,6 +98,10 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase { $this->assertSession() ->pageTextContains("The context $context_name has been saved"); + // The first time a Context is saved, you need to clear the cache. + // Subsequent changes to the context don't need a cache rebuild, though. + drupal_flush_all_caches(); + $new_contents = $this->drupalGet($url . '?_format=jsonld'); $json = \GuzzleHttp\json_decode($new_contents, TRUE); $this->assertEquals( @@ -177,6 +181,10 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase { $this->assertSession() ->pageTextContains("The context $context_name has been saved"); + // The first time a Context is saved, you need to clear the cache. + // Subsequent changes to the context don't need a cache rebuild, though. + drupal_flush_all_caches(); + $new_contents = $this->drupalGet($media_url . '?_format=jsonld'); $json = \GuzzleHttp\json_decode($new_contents, TRUE); $this->assertEquals( diff --git a/tests/src/Functional/JsonldTypeAlterReactionTest.php b/tests/src/Functional/JsonldTypeAlterReactionTest.php index 29232ca1..0232518b 100644 --- a/tests/src/Functional/JsonldTypeAlterReactionTest.php +++ b/tests/src/Functional/JsonldTypeAlterReactionTest.php @@ -75,6 +75,10 @@ class JsonldTypeAlterReactionTest extends JsonldSelfReferenceReactionTest { $this->getSession()->getPage()->findById("edit-conditions-entity-bundle-context-mapping-node")->selectOption("@node.node_route_context:node"); $this->getSession()->getPage()->pressButton(t('Save and continue')); + // The first time a Context is saved, you need to clear the cache. + // Subsequent changes to the context don't need a cache rebuild, though. + drupal_flush_all_caches(); + // Check for the new @type from the field_type_predicate value. $new_contents = $this->drupalGet($url . '?_format=jsonld'); $json = \GuzzleHttp\json_decode($new_contents, TRUE);