Skip to content
Snippets Groups Projects
Verified Commit 8964a2de authored by Dave Long's avatar Dave Long
Browse files

Issue #3402707 by mstrelan, smustgrave, dww, longwave, quietone: Fix strict...

Issue #3402707 by mstrelan, smustgrave, dww, longwave, quietone: Fix strict type errors in AssertContentTrait
parent ac0a3c1f
Branches
Tags
4 merge requests!11958Issue #3490507 by alexpott, smustgrave: Fix bogus mocking in...,!11769Issue #3517987: Add option to contextual filters to encode slashes in query parameter.,!11185Issue #3477324 by andypost, alexpott: Fix usage of str_getcsv() and fgetcsv() for PHP 8.4,!9944Issue #3483353: Consider making the createCopy config action optionally fail...
Pipeline #247053 passed with warnings
Pipeline: drupal

#247067

    Pipeline: drupal

    #247063

      Pipeline: drupal

      #247059

        ......@@ -117,7 +117,7 @@ public function testTemplatePreprocessUpdateFetchErrorMessageWithDblog(): void {
        $this->render($build);
        $this->assertRaw('Failed to fetch available update data:<ul><li>See <a href="https://www.drupal.org/node/3170647">PHP OpenSSL requirements</a> in the Drupal.org handbook for possible reasons this could happen and what you can do to resolve them.</li><li>Check');
        $dblog_url = Url::fromRoute('dblog.overview', [], ['query' => ['type' => ['update']]]);
        $this->assertRaw(Link::fromTextAndUrl('your local system logs', $dblog_url)->toString());
        $this->assertRaw((string) Link::fromTextAndUrl('your local system logs', $dblog_url)->toString());
        $this->assertRaw(' for additional error messages.</li></ul>');
        $variables = [];
        ......
        ......@@ -278,8 +278,6 @@
        <include-pattern>./modules/system/src/Tests/Routing/*</include-pattern>
        <exclude-pattern>./tests/Drupal/Tests/*/Fixture/*</exclude-pattern>
        <exclude-pattern>./tests/Drupal/Tests/*/fixtures/*</exclude-pattern>
        <!-- @todo remove this in https://www.drupal.org/project/drupal/issues/3402707 -->
        <exclude-pattern>./tests/Drupal/KernelTests/AssertContentTrait.php</exclude-pattern>
        </rule>
        <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
        ......
        <?php
        declare(strict_types=1);
        namespace Drupal\KernelTests;
        use Drupal\Component\Serialization\Json;
        ......@@ -58,11 +60,11 @@ protected function getRawContent() {
        * The raw content to set.
        */
        protected function setRawContent($content) {
        $this->content = $content;
        $this->content = (string) $content;
        $this->plainTextContent = NULL;
        $this->elements = NULL;
        $this->drupalSettings = [];
        if (preg_match('@<script type="application/json" data-drupal-selector="drupal-settings-json">([^<]*)</script>@', $content, $matches)) {
        if (preg_match('@<script type="application/json" data-drupal-selector="drupal-settings-json">([^<]*)</script>@', (string) $content, $matches)) {
        $this->drupalSettings = Json::decode($matches[1]);
        }
        }
        ......@@ -305,7 +307,7 @@ protected function assertNoLink($label, $message = '') {
        // Cast MarkupInterface objects to string.
        $label = (string) $label;
        $links = $this->xpath('//a[normalize-space(text())=:label]', [':label' => $label]);
        $message = ($message ? $message : new FormattableMarkup('Link with label %label not found.', ['%label' => $label]));
        $message = $message ?: "Link with label $label not found.";
        $this->assertEmpty($links, $message);
        return TRUE;
        }
        ......@@ -328,8 +330,8 @@ protected function assertNoLink($label, $message = '') {
        */
        protected function assertLinkByHref($href, $index = 0, $message = '') {
        $links = $this->xpath('//a[contains(@href, :href)]', [':href' => $href]);
        $message = ($message ? $message : new FormattableMarkup('Link containing href %href found.', ['%href' => $href]));
        $this->assertArrayHasKey($index, $links, $message);
        $message = $message ?: "Link containing href $href found.";
        $this->assertArrayHasKey($index, $links, (string) $message);
        return TRUE;
        }
        ......@@ -390,7 +392,7 @@ protected function assertNoLinkByHrefInMainRegion($href, $message = '') {
        */
        protected function assertRaw($raw, $message = ''): void {
        if (!$message) {
        $message = 'Raw "' . Html::escape($raw) . '" found';
        $message = 'Raw "' . Html::escape((string) $raw) . '" found';
        }
        $this->assertStringContainsString((string) $raw, $this->getRawContent(), $message);
        }
        ......@@ -410,7 +412,7 @@ protected function assertRaw($raw, $message = ''): void {
        */
        protected function assertNoRaw($raw, $message = ''): void {
        if (!$message) {
        $message = 'Raw "' . Html::escape($raw) . '" not found';
        $message = 'Raw "' . Html::escape((string) $raw) . '" not found';
        }
        $this->assertStringNotContainsString((string) $raw, $this->getRawContent(), $message);
        }
        ......@@ -430,9 +432,9 @@ protected function assertNoRaw($raw, $message = ''): void {
        */
        protected function assertEscaped($raw, $message = ''): void {
        if (!$message) {
        $message = 'Escaped "' . Html::escape($raw) . '" found';
        $message = 'Escaped "' . Html::escape((string) $raw) . '" found';
        }
        $this->assertStringContainsString(Html::escape($raw), $this->getRawContent(), $message);
        $this->assertStringContainsString(Html::escape((string) $raw), $this->getRawContent(), $message);
        }
        /**
        ......@@ -450,9 +452,9 @@ protected function assertEscaped($raw, $message = ''): void {
        */
        protected function assertNoEscaped($raw, $message = ''): void {
        if (!$message) {
        $message = 'Escaped "' . Html::escape($raw) . '" not found';
        $message = 'Escaped "' . Html::escape((string) $raw) . '" not found';
        }
        $this->assertStringNotContainsString(Html::escape($raw), $this->getRawContent(), $message);
        $this->assertStringNotContainsString(Html::escape((string) $raw), $this->getRawContent(), $message);
        }
        /**
        ......@@ -518,10 +520,10 @@ protected function assertTextHelper($text, $message = '', $group = NULL, $not_ex
        $message = !$not_exists ? new FormattableMarkup('"@text" found', ['@text' => $text]) : new FormattableMarkup('"@text" not found', ['@text' => $text]);
        }
        if ($not_exists) {
        $this->assertStringNotContainsString((string) $text, $this->getTextContent(), $message);
        $this->assertStringNotContainsString((string) $text, $this->getTextContent(), (string) $message);
        }
        else {
        $this->assertStringContainsString((string) $text, $this->getTextContent(), $message);
        $this->assertStringContainsString((string) $text, $this->getTextContent(), (string) $message);
        }
        }
        ......@@ -624,7 +626,7 @@ protected function assertPattern($pattern, $message = '') {
        if (!$message) {
        $message = new FormattableMarkup('Pattern "@pattern" found', ['@pattern' => $pattern]);
        }
        $this->assertMatchesRegularExpression($pattern, $this->getRawContent(), $message);
        $this->assertMatchesRegularExpression($pattern, $this->getRawContent(), (string) $message);
        return TRUE;
        }
        ......@@ -691,7 +693,7 @@ protected function assertTitle($title, $message = '') {
        '@expected' => var_export($title, TRUE),
        ]);
        }
        $this->assertEquals($title, $actual, $message);
        $this->assertEquals($title, $actual, (string) $message);
        }
        else {
        $this->fail('No title element found on the page.');
        ......@@ -749,7 +751,7 @@ protected function assertThemeOutput($callback, array $variables = [], $expected
        $message = '%callback rendered correctly.';
        }
        $message = new FormattableMarkup($message, ['%callback' => 'theme_' . $callback . '()']);
        $this->assertSame($expected, $output, $message);
        $this->assertSame($expected, $output, (string) $message);
        }
        /**
        ......@@ -802,7 +804,7 @@ protected function assertFieldsByValue($fields, $value = NULL, $message = '') {
        }
        }
        $this->assertNotEmpty($fields);
        $this->assertTrue($found, $message);
        $this->assertTrue($found, (string) $message);
        return TRUE;
        }
        ......@@ -886,7 +888,7 @@ protected function assertNoFieldByXPath($xpath, $value = NULL, $message = '') {
        }
        }
        $this->assertNotEmpty($fields);
        $this->assertTrue($found, $message);
        $this->assertTrue($found, (string) $message);
        return TRUE;
        }
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment