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

Issue #3513129 by quietone, longwave, mstrelan: Remove uses of...

Issue #3513129 by quietone, longwave, mstrelan: Remove uses of FormattableMarkup in Functional test assertion messages
parent 8a856ce4
Branches
Tags
3 merge requests!5423Draft: Resolve #3329907 "Test2",!3478Issue #3337882: Deleted menus are not removed from content type config,!579Issue #2230909: Simple decimals fail to pass validation
Pipeline #487761 canceled
......@@ -4,7 +4,6 @@
namespace Drupal\Tests\content_translation\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Url;
use Drupal\entity_test\Entity\EntityTestMulRevPub;
......@@ -249,10 +248,10 @@ public function testWorkflows(): void {
foreach ($ops as $op => $label) {
if ($op != $current_op) {
$this->assertSession()->linkNotExists($label, new FormattableMarkup('No %op link found.', ['%op' => $label]));
$this->assertSession()->linkNotExists($label);
}
else {
$this->assertSession()->linkExists($label, 0, new FormattableMarkup('%op link found.', ['%op' => $label]));
$this->assertSession()->linkExists($label, 0);
}
}
}
......
......@@ -4,7 +4,6 @@
namespace Drupal\Tests\file\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Entity\FieldConfig;
use Drupal\file\FileInterface;
......@@ -222,7 +221,7 @@ public function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE)
public function assertFileEntryExists($file, $message = NULL) {
$this->container->get('entity_type.manager')->getStorage('file')->resetCache();
$db_file = File::load($file->id());
$message = $message ?? new FormattableMarkup('File %file exists in database at the correct path.', ['%file' => $file->getFileUri()]);
$message = $message ?? sprintf('File %s exists in database at the correct path.', $file->getFileUri());
$this->assertEquals($file->getFileUri(), $db_file->getFileUri(), $message);
}
......@@ -231,7 +230,7 @@ public function assertFileEntryExists($file, $message = NULL) {
*/
public function assertFileEntryNotExists($file, $message) {
$this->container->get('entity_type.manager')->getStorage('file')->resetCache();
$message = $message ?? new FormattableMarkup('File %file exists in database at the correct path.', ['%file' => $file->getFileUri()]);
$message = $message ?? sprintf('File %s exists in database at the correct path.', $file->getFileUri());
$this->assertNull(File::load($file->id()), $message);
}
......@@ -239,7 +238,7 @@ public function assertFileEntryNotExists($file, $message) {
* Asserts that a file's status is set to permanent in the database.
*/
public function assertFileIsPermanent(FileInterface $file, $message = NULL) {
$message = $message ?? new FormattableMarkup('File %file is permanent.', ['%file' => $file->getFileUri()]);
$message = $message ?? sprintf('File %s is permanent.', $file->getFileUri());
$this->assertTrue($file->isPermanent(), $message);
}
......
......@@ -4,7 +4,6 @@
namespace Drupal\Tests\help\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Tests\BrowserTestBase;
/**
......@@ -99,7 +98,7 @@ public function testHelp(): void {
// Make sure links are properly added for modules implementing hook_help().
foreach ($this->getModuleList() as $module => $name) {
$this->assertSession()->linkExists($name, 0, new FormattableMarkup('Link properly added to @name (admin/help/@module)', ['@module' => $module, '@name' => $name]));
$this->assertSession()->linkExists($name, 0, "Link properly added to $name (admin/help/$module)");
}
// Ensure a module which does not provide a module overview page is handled
......
......@@ -5,7 +5,6 @@
namespace Drupal\Tests\shortcut\Functional;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Url;
use Drupal\shortcut\Entity\Shortcut;
use Drupal\shortcut\Entity\ShortcutSet;
......@@ -109,10 +108,10 @@ public function testShortcutLinkAdd(): void {
$this->assertContains('internal:' . $test_path, $paths, 'Shortcut created: ' . $test_path);
if (in_array($test_path, $test_cases_non_access)) {
$this->assertSession()->linkNotExists($title, new FormattableMarkup('Shortcut link %url not accessible on the page.', ['%url' => $test_path]));
$this->assertSession()->linkNotExists($title, "Shortcut link $test_path not accessible on the page.");
}
else {
$this->assertSession()->linkExists($title, 0, new FormattableMarkup('Shortcut link %url found on the page.', ['%url' => $test_path]));
$this->assertSession()->linkExists($title, 0, "Shortcut link $test_path found on the page.");
}
}
$saved_set = ShortcutSet::load($set->id());
......@@ -486,7 +485,7 @@ public function testShortcutBlockAccess(): void {
*/
protected function assertShortcutQuickLink(string $label, int $index = 0, string $message = ''): void {
$links = $this->xpath('//a[normalize-space()=:label]', [':label' => $label]);
$message = ($message ?: (string) new FormattableMarkup('Shortcut quick link with label %label found.', ['%label' => $label]));
$message = ($message ?: "Shortcut quick link with label $label found.");
$this->assertArrayHasKey($index, $links, $message);
}
......
......@@ -4,7 +4,6 @@
namespace Drupal\Tests\views_ui\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Tests\views_ui\Traits\FilterEntityReferenceTrait;
......@@ -60,8 +59,7 @@ public function testFilterUi(): void {
});
$i = 0;
foreach ($this->targetEntities as $entity) {
$message = (string) new FormattableMarkup('Expected target entity label found for option :option', [':option' => $i]);
$this->assertEquals($options[$i]['label'], $entity->label(), $message);
$this->assertEquals($options[$i]['label'], $entity->label(), "Expected target entity label found for option $i");
$i++;
}
......@@ -79,8 +77,7 @@ public function testFilterUi(): void {
$options = $this->getUiOptions();
$i = 0;
foreach ($this->targetEntities as $entity) {
$message = (string) new FormattableMarkup('Expected target entity label found for option :option', [':option' => $i]);
$this->assertEquals($options[$i]['label'], $entity->label(), $message);
$this->assertEquals($options[$i]['label'], $entity->label(), "Expected target entity label found for option $i");
$i++;
}
......@@ -96,8 +93,7 @@ public function testFilterUi(): void {
$options = $this->getUiOptions();
$i = 0;
foreach ($this->hostEntities + $this->targetEntities as $entity) {
$message = (string) new FormattableMarkup('Expected target entity label found for option :option', [':option' => $i]);
$this->assertEquals($options[$i]['label'], $entity->label(), $message);
$this->assertEquals($options[$i]['label'], $entity->label(), "Expected target entity label found for option $i");
$i++;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment