Unverified Commit e39262bf authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2228741 by rpayanm, mikelutz, voleger, epari.siva, malotor, Rolf van de...

Issue #2228741 by rpayanm, mikelutz, voleger, epari.siva, malotor, Rolf van de Krol, quietone, Mile23, andypost, ianthomas_uk, Lendude, alexpott, dawehner, xjm, Gábor Hojtsy, Berdir, catch: Replace calls to format_string() with Drupal\Component\Render\FormattableMarkup
parent 3ae3e525
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -354,17 +354,17 @@ function t($string, array $args = [], array $options = []) {
/**
 * Formats a string for HTML display by replacing variable placeholders.
 *
 * @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0.
 *   Use \Drupal\Component\Render\FormattableMarkup instead.
 *
 * @see https://www.drupal.org/node/2302363
 * @see \Drupal\Component\Render\FormattableMarkup::placeholderFormat()
 * @see \Drupal\Component\Render\FormattableMarkup
 * @see t()
 * @ingroup sanitization
 *
 * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
 *   Use \Drupal\Component\Render\FormattableMarkup.
 *
 * @see https://www.drupal.org/node/2302363
 */
function format_string($string, array $args) {
  @trigger_error("format_string() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Component\Render\FormattableMarkup instead. See https://www.drupal.org/node/2302363", E_USER_DEPRECATED);
  return new FormattableMarkup($string, $args);
}

+4 −2
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@

namespace Drupal\Core\Test;

use Drupal\Component\Render\FormattableMarkup;

/**
 * Provides methods for testing emails sent during test runs.
 */
@@ -103,7 +105,7 @@ protected function assertMailString($field_name, $string, $email_depth, $message
      }
    }
    if (!$message) {
      $message = format_string('Expected text found in @field of email message: "@expected".', ['@field' => $field_name, '@expected' => $string]);
      $message = new FormattableMarkup('Expected text found in @field of email message: "@expected".', ['@field' => $field_name, '@expected' => $string]);
    }
    return $this->assertTrue($string_found, $message, $group);
  }
@@ -134,7 +136,7 @@ protected function assertMailPattern($field_name, $regex, $message = '', $group
    $mail = end($mails);
    $regex_found = preg_match("/$regex/", $mail[$field_name]);
    if (!$message) {
      $message = format_string('Expected text found in @field of email message: "@expected".', ['@field' => $field_name, '@expected' => $regex]);
      $message = new FormattableMarkup('Expected text found in @field of email message: "@expected".', ['@field' => $field_name, '@expected' => $regex]);
    }
    return $this->assertTrue($regex_found, $message, $group);
  }
+4 −3
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@

@trigger_error(__NAMESPACE__ . '\AggregatorTestBase is deprecated for removal before Drupal 9.0.0. Use \Drupal\Tests\aggregator\Functional\AggregatorTestBase instead. See https://www.drupal.org/node/2999939', E_USER_DEPRECATED);

use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Url;
use Drupal\aggregator\Entity\Feed;
use Drupal\Component\Utility\Html;
@@ -70,7 +71,7 @@ protected function setUp() {
  public function createFeed($feed_url = NULL, array $edit = []) {
    $edit = $this->getFeedEditArray($feed_url, $edit);
    $this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
    $this->assertText(t('The feed @name has been added.', ['@name' => $edit['title[0][value]']]), format_string('The feed @name has been added.', ['@name' => $edit['title[0][value]']]));
    $this->assertText(t('The feed @name has been added.', ['@name' => $edit['title[0][value]']]), new FormattableMarkup('The feed @name has been added.', ['@name' => $edit['title[0][value]']]));

    // Verify that the creation message contains a link to a feed.
    $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'aggregator/sources/']);
@@ -181,7 +182,7 @@ public function getDefaultFeedItemCount() {
  public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {
    // First, let's ensure we can get to the rss xml.
    $this->drupalGet($feed->getUrl());
    $this->assertResponse(200, format_string(':url is reachable.', [':url' => $feed->getUrl()]));
    $this->assertResponse(200, new FormattableMarkup(':url is reachable.', [':url' => $feed->getUrl()]));

    // Attempt to access the update link directly without an access token.
    $this->drupalGet('admin/config/services/aggregator/update/' . $feed->id());
@@ -200,7 +201,7 @@ public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {

    if ($expected_count !== NULL) {
      $feed->item_count = count($feed->items);
      $this->assertEqual($expected_count, $feed->item_count, format_string('Total items in feed equal to the total items in database (@val1 != @val2)', ['@val1' => $expected_count, '@val2' => $feed->item_count]));
      $this->assertEqual($expected_count, $feed->item_count, new FormattableMarkup('Total items in feed equal to the total items in database (@val1 != @val2)', ['@val1' => $expected_count, '@val2' => $feed->item_count]));
    }
  }

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

namespace Drupal\Tests\aggregator\Functional;

use Drupal\Component\Render\FormattableMarkup;

/**
 * Tests aggregator admin pages.
 *
@@ -35,7 +37,7 @@ public function testSettingsPage() {
    $this->assertText(t('The configuration options have been saved.'));

    foreach ($edit as $name => $value) {
      $this->assertFieldByName($name, $value, format_string('"@name" has correct default value.', ['@name' => $name]));
      $this->assertFieldByName($name, $value, new FormattableMarkup('"@name" has correct default value.', ['@name' => $name]));
    }

    // Check for our test processor settings form.
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ public function testBlockLinks() {
    // Find the expected read_more link.
    $href = $feed->toUrl()->toString();
    $links = $this->xpath('//a[@href = :href]', [':href' => $href]);
    $this->assert(isset($links[0]), format_string('Link to href %href found.', ['%href' => $href]));
    $this->assert(isset($links[0]), new FormattableMarkup('Link to href %href found.', ['%href' => $href]));
    $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
    $cache_tags = explode(' ', $cache_tags_header);
    $this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
Loading