diff --git a/core/modules/filter/src/Element/ProcessedText.php b/core/modules/filter/src/Element/ProcessedText.php index e0045d1..de9d5cc 100644 --- a/core/modules/filter/src/Element/ProcessedText.php +++ b/core/modules/filter/src/Element/ProcessedText.php @@ -80,7 +80,7 @@ public static function preRenderText($element) { } /** @var \Drupal\filter\Entity\FilterFormat $format **/ $format = FilterFormat::load($format_id); - // If the requested text format doesn't exist or it's disabled, the text + // If the requested text format doesn't exist or its disabled, the text // cannot be filtered. if (!$format || !$format->status()) { $message = !$format ? 'Missing text format: %format.' : 'Disabled text format: %format.'; diff --git a/core/modules/filter/src/Entity/FilterFormat.php b/core/modules/filter/src/Entity/FilterFormat.php index db136c9..3f01d7a 100644 --- a/core/modules/filter/src/Entity/FilterFormat.php +++ b/core/modules/filter/src/Entity/FilterFormat.php @@ -180,9 +180,10 @@ public function toArray() { * {@inheritdoc} */ public function disable() { - // The fallback text format cannot be disabled. + // The fallback text format cannot be disabled, as we always have to be able + // to run it, in case a different format is disabled. if ($this->isFallbackFormat()) { - throw new \LogicException(sprintf("The fallback text format '%s' cannot be disabled.", $this->id())); + throw new \LogicException("The fallback text format '{$this->id()}' cannot be disabled."); } parent::disable(); diff --git a/core/modules/filter/src/Tests/FilterAdminTest.php b/core/modules/filter/src/Tests/FilterAdminTest.php index eff64ca..54a7237 100644 --- a/core/modules/filter/src/Tests/FilterAdminTest.php +++ b/core/modules/filter/src/Tests/FilterAdminTest.php @@ -391,25 +391,19 @@ function testFilterTipHtmlEscape() { } /** - * Tests whether a field having a disabled format is rendered. + * Tests whether a field using a disabled format is rendered. */ public function testDisabledFormat() { - // We test the interface as anonymous user. - $this->drupalLogout(); - // Create a node type and add a standard body field. $node_type = NodeType::create(['type' => Unicode::strtolower($this->randomMachineName())]); $node_type->save(); node_add_body_field($node_type, $this->randomString()); - // Create a new format and add a filter that replaces the text with a static - // text every time. - /** @var \Drupal\filter\FilterFormatInterface $format */ + // Create a text format with a filter that returns a static string. $format = FilterFormat::create([ 'name' => $this->randomString(), 'format' => $format_id = Unicode::strtolower($this->randomMachineName()), ]); - $format->save(); $format->setFilterConfig('filter_static_text', ['status' => TRUE]); $format->save(); @@ -418,20 +412,20 @@ public function testDisabledFormat() { 'type' => $node_type->id(), 'title' => $this->randomString(), ]); - $body_value = 'body text &<'; + $body_value = $this->randomString(); $node->body->value = $body_value; $node->body->format = $format_id; $node->save(); // The format is used and we should see the static text instead of the body // value. - $this->drupalGet('node/' . $node->id()); + $this->drupalGet($node->urlInfo()); $this->assertText('filtered text'); // Disable the format. $format->disable()->save(); - $this->drupalGet('node/' . $node->id()); + $this->drupalGet($node->urlInfo()); // The format is not used anymore. $this->assertNoText('filtered text'); @@ -450,7 +444,7 @@ public function testDisabledFormat() { $format_id = $this->randomMachineName(); $node->body->format = $format_id; $node->save(); - $this->drupalGet('node/' . $node->id()); + $this->drupalGet($node->urlInfo()); // The text is not displayed unfiltered or escaped. $this->assertNoRaw($body_value); $this->assertNoEscaped($body_value); diff --git a/core/modules/filter/tests/filter_test_plugin/src/Plugin/Filter/FilterTestStatic.php b/core/modules/filter/tests/filter_test_plugin/src/Plugin/Filter/FilterTestStatic.php new file mode 100644 index 0000000..0119642 --- /dev/null +++ b/core/modules/filter/tests/filter_test_plugin/src/Plugin/Filter/FilterTestStatic.php @@ -0,0 +1,33 @@ +