From 6dc5310a30080938b22c9a23b1d4ff92d0aa8495 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Sat, 20 Jun 2015 15:29:08 -0500 Subject: [PATCH] Issue #2505937 by JeroenT: Remove usage of @deprecated methods on BubbleableMetadata class --- .../src/Plugin/Filter/FilterCaption.php | 2 +- .../filter/src/Tests/FilterUnitTest.php | 24 +++++++++---------- .../src/Plugin/Filter/FilterTestAssets.php | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/core/modules/filter/src/Plugin/Filter/FilterCaption.php b/core/modules/filter/src/Plugin/Filter/FilterCaption.php index 32977ece3560..6f90565ebf75 100644 --- a/core/modules/filter/src/Plugin/Filter/FilterCaption.php +++ b/core/modules/filter/src/Plugin/Filter/FilterCaption.php @@ -80,7 +80,7 @@ public function process($text, $langcode) { } $result->setProcessedText(Html::serialize($dom)) - ->addAssets(array( + ->addAttachments(array( 'library' => array( 'filter/caption', ), diff --git a/core/modules/filter/src/Tests/FilterUnitTest.php b/core/modules/filter/src/Tests/FilterUnitTest.php index e4eeb33780a6..5d0b1d65f335 100644 --- a/core/modules/filter/src/Tests/FilterUnitTest.php +++ b/core/modules/filter/src/Tests/FilterUnitTest.php @@ -123,7 +123,7 @@ function testCaptionFilter() { $expected = '<figure><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>'; $output = $test($input); $this->assertIdentical($expected, $output->getProcessedText()); - $this->assertIdentical($attached_library, $output->getAssets()); + $this->assertIdentical($attached_library, $output->getAttachments()); // Empty data-caption attribute. $input = '<img src="llama.jpg" data-caption="" />'; @@ -135,14 +135,14 @@ function testCaptionFilter() { $expected = '<figure><img src="llama.jpg" /><figcaption>“Loquacious llama!”</figcaption></figure>'; $output = $test($input); $this->assertIdentical($expected, $output->getProcessedText()); - $this->assertIdentical($attached_library, $output->getAssets()); + $this->assertIdentical($attached_library, $output->getAttachments()); // HTML encoded as HTML entities in data-caption attribute. $input = '<img src="llama.jpg" data-caption="<em>Loquacious llama!</em>" />'; $expected = '<figure><img src="llama.jpg" /><figcaption><em>Loquacious llama!</em></figcaption></figure>'; $output = $test($input); $this->assertIdentical($expected, $output->getProcessedText()); - $this->assertIdentical($attached_library, $output->getAssets()); + $this->assertIdentical($attached_library, $output->getAttachments()); // HTML (not encoded as HTML entities) in data-caption attribute, which is // not allowed by the HTML spec, but may happen when people manually write @@ -151,33 +151,33 @@ function testCaptionFilter() { $expected = '<figure><img src="llama.jpg" /><figcaption><em>Loquacious llama!</em></figcaption></figure>'; $output = $test($input); $this->assertIdentical($expected, $output->getProcessedText()); - $this->assertIdentical($attached_library, $output->getAssets()); + $this->assertIdentical($attached_library, $output->getAttachments()); // Security test: attempt an XSS. $input = '<img src="llama.jpg" data-caption="<script>alert(\'Loquacious llama!\')</script>" />'; $expected = '<figure><img src="llama.jpg" /><figcaption>alert(\'Loquacious llama!\')</figcaption></figure>'; $output = $test($input); $this->assertIdentical($expected, $output->getProcessedText()); - $this->assertIdentical($attached_library, $output->getAssets()); + $this->assertIdentical($attached_library, $output->getAttachments()); // Ensure the filter also works with uncommon yet valid attribute quoting. $input = '<img src=llama.jpg data-caption=\'Loquacious llama!\' />'; $expected = '<figure><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>'; $output = $test($input); $this->assertIdentical($expected, $output->getProcessedText()); - $this->assertIdentical($attached_library, $output->getAssets()); + $this->assertIdentical($attached_library, $output->getAttachments()); // Finally, ensure that this also works on any other tag. $input = '<video src="llama.jpg" data-caption="Loquacious llama!" />'; $expected = '<figure><video src="llama.jpg"></video><figcaption>Loquacious llama!</figcaption></figure>'; $output = $test($input); $this->assertIdentical($expected, $output->getProcessedText()); - $this->assertIdentical($attached_library, $output->getAssets()); + $this->assertIdentical($attached_library, $output->getAttachments()); $input = '<foobar data-caption="Loquacious llama!">baz</foobar>'; $expected = '<figure><foobar>baz</foobar><figcaption>Loquacious llama!</figcaption></figure>'; $output = $test($input); $this->assertIdentical($expected, $output->getProcessedText()); - $this->assertIdentical($attached_library, $output->getAssets()); + $this->assertIdentical($attached_library, $output->getAttachments()); // So far we've tested that the caption filter works correctly. But we also // want to make sure that it works well in tandem with the "Limit allowed @@ -271,17 +271,17 @@ function testAlignAndCaptionFilters() { $expected = '<figure class="align-left"><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>'; $output = $test($input); $this->assertIdentical($expected, $output->getProcessedText()); - $this->assertIdentical($attached_library, $output->getAssets()); + $this->assertIdentical($attached_library, $output->getAttachments()); $input = '<img src="llama.jpg" data-caption="Loquacious llama!" data-align="center" />'; $expected = '<figure class="align-center"><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>'; $output = $test($input); $this->assertIdentical($expected, $output->getProcessedText()); - $this->assertIdentical($attached_library, $output->getAssets()); + $this->assertIdentical($attached_library, $output->getAttachments()); $input = '<img src="llama.jpg" data-caption="Loquacious llama!" data-align="right" />'; $expected = '<figure class="align-right"><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>'; $output = $test($input); $this->assertIdentical($expected, $output->getProcessedText()); - $this->assertIdentical($attached_library, $output->getAssets()); + $this->assertIdentical($attached_library, $output->getAttachments()); // Both data-caption and data-align attributes, but a disallowed data-align // attribute value. @@ -289,7 +289,7 @@ function testAlignAndCaptionFilters() { $expected = '<figure><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>'; $output = $test($input); $this->assertIdentical($expected, $output->getProcessedText()); - $this->assertIdentical($attached_library, $output->getAssets()); + $this->assertIdentical($attached_library, $output->getAttachments()); } /** diff --git a/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestAssets.php b/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestAssets.php index a7de6d91d19f..30feb7d994fc 100644 --- a/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestAssets.php +++ b/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestAssets.php @@ -27,7 +27,7 @@ class FilterTestAssets extends FilterBase { */ public function process($text, $langcode) { $result = new FilterProcessResult($text); - $result->addAssets(array( + $result->addAttachments(array( 'library' => array( 'filter/caption', ), -- GitLab