Verified Commit 362a5f61 authored by quietone's avatar quietone
Browse files

Issue #3412464 by mstrelan, smustgrave, quietone: Fix strict type errors:...

Issue #3412464 by mstrelan, smustgrave, quietone: Fix strict type errors: Convert FormattableMarkup to strings (complex replacement) in core Functional tests
parent 8b9ff02e
Loading
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@

use Drupal\block_content\Entity\BlockContent;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Tests\views\Functional\ViewTestBase;

/**
@@ -71,7 +70,7 @@ protected function createBlockContent(array $values = []) {
    if ($block_content = BlockContent::create($values)) {
      $status = $block_content->save();
    }
    $this->assertEquals(SAVED_NEW, $status, new FormattableMarkup('Created block content %info.', ['%info' => $block_content->label()]));
    $this->assertEquals(SAVED_NEW, $status, "Created block content {$block_content->label()}.");
    return $block_content;
  }

@@ -103,7 +102,7 @@ protected function createBlockContentType(array $values = []) {
    $status = $bundle->save();
    block_content_add_body_field($bundle->id());

    $this->assertEquals(SAVED_NEW, $status, new FormattableMarkup('Created block content type %bundle.', ['%bundle' => $bundle->id()]));
    $this->assertEquals(SAVED_NEW, $status, sprintf('Created block content type %s.', $bundle->id()));
    return $bundle;
  }

+1 −3
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace Drupal\Tests\comment\Functional;

use Drupal\Component\Render\FormattableMarkup;
use Drupal\comment\Entity\Comment;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\comment\Tests\CommentTestTrait;
@@ -149,8 +148,7 @@ public function testCommentLanguage() {
          ->range(0, 1)
          ->execute();
        $comment = Comment::load(reset($cids));
        $args = ['%node_language' => $node_langcode, '%comment_language' => $comment->langcode->value, '%langcode' => $langcode];
        $this->assertEquals($langcode, $comment->langcode->value, new FormattableMarkup('The comment posted with content language %langcode and belonging to the node with language %node_language has language %comment_language', $args));
        $this->assertEquals($langcode, $comment->langcode->value, "The comment posted with content language $langcode and belonging to the node with language $node_langcode has language {$comment->langcode->value}");
        $this->assertEquals($comment_values[$node_langcode][$langcode], $comment->comment_body->value, 'Comment body correctly stored.');
      }
    }
+1 −1
Original line number Diff line number Diff line
@@ -238,7 +238,7 @@ public function assertCommentOrder(array $comments, array $expected_order): void
    foreach ($comment_anchors as $anchor) {
      $result_order[] = substr($anchor->getAttribute('id'), 8);
    }
    $this->assertEquals($expected_cids, $result_order, new FormattableMarkup('Comment order: expected @expected, returned @returned.', ['@expected' => implode(',', $expected_cids), '@returned' => implode(',', $result_order)]));
    $this->assertEquals($expected_cids, $result_order, sprintf('Comment order: expected %s, returned %s.', implode(',', $expected_cids), implode(',', $result_order)));
  }

  /**
+1 −4
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace Drupal\Tests\comment\Functional\Views;

use Drupal\Component\Render\FormattableMarkup;
use Drupal\comment\CommentInterface;
use Drupal\comment\Entity\Comment;
use Drupal\comment\Tests\CommentTestTrait;
@@ -140,9 +139,7 @@ public function testBlockDisplay() {

    // Check the number of results given by the display is the expected.
    $this->assertCount($this->blockDisplayResults, $view->result,
      new FormattableMarkup('There are exactly @results comments. Expected @expected',
        ['@results' => count($view->result), '@expected' => $this->blockDisplayResults]
      )
      'There are exactly ' . count($view->result) . ' comments. Expected ' . $this->blockDisplayResults
    );
  }

+1 −2
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace Drupal\Tests\contact\Functional;

use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Url;
use Drupal\contact\Entity\ContactForm;
use Drupal\Core\Mail\MailFormatHelper;
@@ -612,7 +611,7 @@ public function deleteContactForms() {
        $this->drupalGet("admin/structure/contact/manage/{$id}/delete");
        $this->submitForm([], 'Delete');
        $this->assertSession()->pageTextContains("The contact form {$contact_form->label()} has been deleted.");
        $this->assertNull(ContactForm::load($id), new FormattableMarkup('Form %contact_form not found', ['%contact_form' => $contact_form->label()]));
        $this->assertNull(ContactForm::load($id), "Form {$contact_form->label()} not found");
      }
    }
  }
Loading