diff --git a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php index 3ee86bb675524f360ecd1074c59f8fa6c3220feb..d1e5eef1643980ab30cdcb7b4652abdf87e777f5 100644 --- a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php +++ b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php @@ -148,19 +148,19 @@ public function postComment(EntityInterface $entity, $comment, $subject = '', $c switch ($preview_mode) { case DRUPAL_REQUIRED: // Preview required so no save button should be found. - $this->assertSession()->buttonNotExists(t('Save')); + $this->assertSession()->buttonNotExists('Save'); $this->submitForm($edit, 'Preview'); // Don't break here so that we can test post-preview field presence and // function below. case DRUPAL_OPTIONAL: - $this->assertSession()->buttonExists(t('Preview')); - $this->assertSession()->buttonExists(t('Save')); + $this->assertSession()->buttonExists('Preview'); + $this->assertSession()->buttonExists('Save'); $this->submitForm($edit, 'Save'); break; case DRUPAL_DISABLED: - $this->assertSession()->buttonNotExists(t('Preview')); - $this->assertSession()->buttonExists(t('Save')); + $this->assertSession()->buttonNotExists('Preview'); + $this->assertSession()->buttonExists('Save'); $this->submitForm($edit, 'Save'); break; } @@ -502,7 +502,7 @@ public function testsNonIntegerIdEntities() { // Attempt to add a comment-type referencing this entity-type. $this->drupalGet('admin/structure/comment/types/add'); $this->assertSession()->optionNotExists('edit-target-entity-type-id', 'entity_test_string_id'); - $this->assertSession()->responseNotContains(t('Test entity with string_id')); + $this->assertSession()->responseNotContains('Test entity with string_id'); // Create a bundle for entity_test_no_id. entity_test_create_bundle('entity_test', 'Entity Test', 'entity_test_no_id'); diff --git a/core/modules/comment/tests/src/Functional/CommentTestBase.php b/core/modules/comment/tests/src/Functional/CommentTestBase.php index 4c58735260f617446f62212727046a6e2a52e7b6..9b44b420959c33a9e28467d3a0feab229070ff21 100644 --- a/core/modules/comment/tests/src/Functional/CommentTestBase.php +++ b/core/modules/comment/tests/src/Functional/CommentTestBase.php @@ -148,19 +148,19 @@ public function postComment($entity, $comment, $subject = '', $contact = NULL, $ switch ($preview_mode) { case DRUPAL_REQUIRED: // Preview required so no save button should be found. - $this->assertSession()->buttonNotExists(t('Save')); + $this->assertSession()->buttonNotExists('Save'); $this->submitForm($edit, 'Preview'); // Don't break here so that we can test post-preview field presence and // function below. case DRUPAL_OPTIONAL: - $this->assertSession()->buttonExists(t('Preview')); - $this->assertSession()->buttonExists(t('Save')); + $this->assertSession()->buttonExists('Preview'); + $this->assertSession()->buttonExists('Save'); $this->submitForm($edit, 'Save'); break; case DRUPAL_DISABLED: - $this->assertSession()->buttonNotExists(t('Preview')); - $this->assertSession()->buttonExists(t('Save')); + $this->assertSession()->buttonNotExists('Preview'); + $this->assertSession()->buttonExists('Save'); $this->submitForm($edit, 'Save'); break; } diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php index c67db412d1d3fbe68bc6095cd770f3904278b1d2..025f933eb44f668af574a2d5e73346dee9272a08 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php @@ -414,15 +414,15 @@ public function testContactConfigEntityTranslation() { // Test that delete links work and operations perform properly. foreach ($this->langcodes as $langcode) { - $replacements = ['%label' => t('@label @entity_type', ['@label' => $label, '@entity_type' => mb_strtolower(t('Contact form'))]), '@language' => \Drupal::languageManager()->getLanguage($langcode)->getName()]; + $language = \Drupal::languageManager()->getLanguage($langcode)->getName(); $this->drupalGet("$translation_base_url/$langcode/delete"); - $this->assertSession()->responseContains(t('Are you sure you want to delete the @language translation of %label?', $replacements)); + $this->assertSession()->pageTextContains("Are you sure you want to delete the $language translation of $label contact form?"); // Assert link back to list page to cancel delete is present. $this->assertSession()->linkByHrefExists($translation_base_url); $this->submitForm([], 'Delete'); - $this->assertSession()->responseContains(t('@language translation of %label was deleted', $replacements)); + $this->assertSession()->pageTextContains("$language translation of $label contact form was deleted"); $this->assertSession()->linkByHrefExists("$translation_base_url/$langcode/add"); $this->assertSession()->linkByHrefNotExists("translation_base_url/$langcode/edit"); $this->assertSession()->linkByHrefNotExists("$translation_base_url/$langcode/delete"); diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationDisableSettingTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationDisableSettingTest.php index 037402c1f0af33b5dd2619f0cba1c67242f89b6f..664fe88d24eb961696ab4f3600383e6390581fb9 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationDisableSettingTest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationDisableSettingTest.php @@ -55,7 +55,7 @@ public function testDisableSetting() { ]; $this->submitForm($edit, 'Save configuration'); - $assert->pageTextContains(t('Settings successfully updated.')); + $assert->pageTextContains('Settings successfully updated.'); $assert->checkboxChecked($group_checkbox); @@ -66,7 +66,7 @@ public function testDisableSetting() { ]; $this->submitForm($edit, 'Save configuration'); - $assert->pageTextContains(t('Settings successfully updated.')); + $assert->pageTextContains('Settings successfully updated.'); $assert->checkboxNotChecked($group_checkbox); } diff --git a/core/modules/dblog/tests/src/Functional/DbLogTest.php b/core/modules/dblog/tests/src/Functional/DbLogTest.php index b582efc556f5c4b57f2a5c0dddd68c23b76ce6a7..0cf3ce96735ec519feb60068d6629a003a9d36a4 100644 --- a/core/modules/dblog/tests/src/Functional/DbLogTest.php +++ b/core/modules/dblog/tests/src/Functional/DbLogTest.php @@ -3,7 +3,6 @@ namespace Drupal\Tests\dblog\Functional; use Drupal\Component\Render\FormattableMarkup; -use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Unicode; use Drupal\Core\Database\Database; use Drupal\Core\Logger\RfcLogLevel; @@ -455,14 +454,14 @@ private function doUser() { // Add user. // Default display includes name and email address; if too long, the email // address is replaced by three periods. - $this->assertLogMessage(t('New user: %name %email.', ['%name' => $name, '%email' => '<' . $user->getEmail() . '>']), 'DBLog event was recorded: [add user]'); + $this->assertLogMessage("New user: $name <{$user->getEmail()}>.", 'DBLog event was recorded: [add user]'); // Log in user. - $this->assertLogMessage(t('Session opened for %name.', ['%name' => $name]), 'DBLog event was recorded: [login user]'); + $this->assertLogMessage("Session opened for $name.", 'DBLog event was recorded: [login user]'); // Log out user. - $this->assertLogMessage(t('Session closed for %name.', ['%name' => $name]), 'DBLog event was recorded: [logout user]'); + $this->assertLogMessage("Session closed for $name.", 'DBLog event was recorded: [logout user]'); // Delete user. - $message = t('Deleted user: %name %email.', ['%name' => $name, '%email' => '<' . $user->getEmail() . '>']); - $message_text = Unicode::truncate(Html::decodeEntities(strip_tags($message)), 56, TRUE, TRUE); + $message = "Deleted user: $name <{$user->getEmail()}>."; + $message_text = Unicode::truncate($message, 56, TRUE, TRUE); // Verify that the full message displays on the details page. $link = FALSE; if ($links = $this->xpath('//a[text()="' . $message_text . '"]')) { @@ -474,7 +473,7 @@ private function doUser() { $link = mb_substr($value, strpos($value, 'admin/reports/dblog/event/')); $this->drupalGet($link); // Check for full message text on the details page. - $this->assertSession()->responseContains($message); + $this->assertSession()->pageTextContains($message); } $this->assertNotEmpty($link, 'DBLog event was recorded: [delete user]'); // Visit random URL (to generate page not found event). @@ -535,11 +534,11 @@ private function doNode($type) { // Verify that node events were recorded. // Was node content added? - $this->assertLogMessage(t('@type: added %title.', ['@type' => $type, '%title' => $title]), 'DBLog event was recorded: [content added]'); + $this->assertLogMessage("$type: added $title.", 'DBLog event was recorded: [content added]'); // Was node content updated? - $this->assertLogMessage(t('@type: updated %title.', ['@type' => $type, '%title' => $title]), 'DBLog event was recorded: [content updated]'); + $this->assertLogMessage("$type: updated $title.", 'DBLog event was recorded: [content updated]'); // Was node content deleted? - $this->assertLogMessage(t('@type: deleted %title.', ['@type' => $type, '%title' => $title]), 'DBLog event was recorded: [content deleted]'); + $this->assertLogMessage("$type: deleted $title.", 'DBLog event was recorded: [content deleted]'); // View the database log access-denied report page. $this->drupalGet('admin/reports/access-denied'); @@ -805,7 +804,7 @@ protected function getSeverityConstant($class) { * The message to pass to simpletest. */ protected function assertLogMessage($log_message, $message) { - $message_text = Unicode::truncate(Html::decodeEntities(strip_tags($log_message)), 56, TRUE, TRUE); + $message_text = Unicode::truncate($log_message, 56, TRUE, TRUE); $this->assertSession()->linkExists($message_text, 0, $message); } diff --git a/core/modules/field/tests/src/Functional/Boolean/BooleanFormatterSettingsTest.php b/core/modules/field/tests/src/Functional/Boolean/BooleanFormatterSettingsTest.php index 14d8ffccedc2a06733f966f42e047149934cb65e..5e7a3aaced55facd532339331ffee3761701f7c5 100644 --- a/core/modules/field/tests/src/Functional/Boolean/BooleanFormatterSettingsTest.php +++ b/core/modules/field/tests/src/Functional/Boolean/BooleanFormatterSettingsTest.php @@ -126,7 +126,7 @@ public function testBooleanFormatterSettings() { foreach ($options as $string) { $assert_session->pageTextContains($string); } - $assert_session->pageTextContains(t('Field settings (@on_label / @off_label)', ['@on_label' => $values[0], '@off_label' => $values[1]])); + $assert_session->pageTextContains("Field settings ({$values[0]} / {$values[1]})"); // Test that the settings summary are present in the correct format. $this->drupalGet('admin/structure/types/manage/' . $this->bundle . '/display'); diff --git a/core/modules/field/tests/src/FunctionalJavascript/Boolean/BooleanFormatterSettingsTest.php b/core/modules/field/tests/src/FunctionalJavascript/Boolean/BooleanFormatterSettingsTest.php index da92869b9290b3ad1009442aa88adbbc9cc9d0f4..583852beccdf8055d84b3237a35049b2d8ff56e3 100644 --- a/core/modules/field/tests/src/FunctionalJavascript/Boolean/BooleanFormatterSettingsTest.php +++ b/core/modules/field/tests/src/FunctionalJavascript/Boolean/BooleanFormatterSettingsTest.php @@ -126,7 +126,7 @@ public function testBooleanFormatterSettings() { foreach ($options as $string) { $assert_session->pageTextContains($string); } - $assert_session->pageTextContains(t('Field settings (@on_label / @off_label)', ['@on_label' => $values[0], '@off_label' => $values[1]])); + $assert_session->pageTextContains("Field settings ({$values[0]} / {$values[1]})"); } } diff --git a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldTest.php b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldTest.php index c74e203b74647119985d6e4161c882743b98adb9..e78c3506cc74f465d24ef0af12a2625a79eb0502 100644 --- a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldTest.php +++ b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldTest.php @@ -33,22 +33,22 @@ public function testFields() { // Integer field. $field_storage = FieldStorageConfig::load('node.field_test_two'); - $this->assertSame("integer", $field_storage->getType(), t('Field type is @fieldtype. It should be integer.', ['@fieldtype' => $field_storage->getType()])); + $this->assertSame("integer", $field_storage->getType()); // Float field. $field_storage = FieldStorageConfig::load('node.field_test_three'); - $this->assertSame("decimal", $field_storage->getType(), t('Field type is @fieldtype. It should be decimal.', ['@fieldtype' => $field_storage->getType()])); + $this->assertSame("decimal", $field_storage->getType()); // Link field. $field_storage = FieldStorageConfig::load('node.field_test_link'); - $this->assertSame("link", $field_storage->getType(), t('Field type is @fieldtype. It should be link.', ['@fieldtype' => $field_storage->getType()])); + $this->assertSame("link", $field_storage->getType()); // File field. $field_storage = FieldStorageConfig::load('node.field_test_filefield'); - $this->assertSame("file", $field_storage->getType(), t('Field type is @fieldtype. It should be file.', ['@fieldtype' => $field_storage->getType()])); + $this->assertSame("file", $field_storage->getType()); $field_storage = FieldStorageConfig::load('node.field_test_imagefield'); - $this->assertSame("image", $field_storage->getType(), t('Field type is @fieldtype. It should be image.', ['@fieldtype' => $field_storage->getType()])); + $this->assertSame("image", $field_storage->getType()); $settings = $field_storage->getSettings(); $this->assertSame('file', $settings['target_type']); $this->assertSame('public', $settings['uri_scheme']); @@ -56,51 +56,45 @@ public function testFields() { // Phone field. $field_storage = FieldStorageConfig::load('node.field_test_phone'); - $this->assertSame("telephone", $field_storage->getType(), t('Field type is @fieldtype. It should be telephone.', ['@fieldtype' => $field_storage->getType()])); + $this->assertSame("telephone", $field_storage->getType()); // Date field. $field_storage = FieldStorageConfig::load('node.field_test_datetime'); - $this->assertSame("datetime", $field_storage->getType(), t('Field type is @fieldtype. It should be datetime.', ['@fieldtype' => $field_storage->getType()])); + $this->assertSame("datetime", $field_storage->getType()); // Date fields. $field_storage = FieldStorageConfig::load('node.field_test_datetime'); - $this->assertSame("datetime", $field_storage->getType(), t('Field type is @fieldtype. It should be datetime.', ['@fieldtype' => $field_storage->getType()])); + $this->assertSame("datetime", $field_storage->getType()); $field_storage = FieldStorageConfig::load('node.field_test_datestamp'); - $this->assertSame("timestamp", $field_storage->getType(), t('Field type is @fieldtype. It should be timestamp.', ['@fieldtype' => $field_storage->getType()])); + $this->assertSame("timestamp", $field_storage->getType()); $field_storage = FieldStorageConfig::load('node.field_test_date'); - $this->assertSame("datetime", $field_storage->getType(), t('Field type is @fieldtype. It should be datetime.', ['@fieldtype' => $field_storage->getType()])); + $this->assertSame("datetime", $field_storage->getType()); // Decimal field with radio buttons. $field_storage = FieldStorageConfig::load('node.field_test_decimal_radio_buttons'); - $this->assertSame("list_float", $field_storage->getType(), t('Field type is @fieldtype. It should be list_float.', ['@fieldtype' => $field_storage->getType()])); - $this->assertNotNull($field_storage->getSetting('allowed_values')['1.2'], t('First allowed value key is set to 1.2')); - $this->assertNotNull($field_storage->getSetting('allowed_values')['2.1'], t('Second allowed value key is set to 2.1')); - $this->assertSame('1.2', $field_storage->getSetting('allowed_values')['1.2'], t('First allowed value is set to 1.2')); - $this->assertSame('2.1', $field_storage->getSetting('allowed_values')['2.1'], t('Second allowed value is set to 1.2')); + $this->assertSame("list_float", $field_storage->getType()); + $this->assertSame('1.2', $field_storage->getSetting('allowed_values')['1.2']); + $this->assertSame('2.1', $field_storage->getSetting('allowed_values')['2.1']); // Email field. $field_storage = FieldStorageConfig::load('node.field_test_email'); - $this->assertSame("email", $field_storage->getType(), t('Field type is @fieldtype. It should be email.', ['@fieldtype' => $field_storage->getType()])); + $this->assertSame("email", $field_storage->getType()); // Float field with a single checkbox. $field_storage = FieldStorageConfig::load('node.field_test_float_single_checkbox'); - $this->assertSame("boolean", $field_storage->getType(), t('Field type is @fieldtype. It should be boolean.', ['@fieldtype' => $field_storage->getType()])); + $this->assertSame("boolean", $field_storage->getType()); // Integer field with a select list. $field_storage = FieldStorageConfig::load('node.field_test_integer_selectlist'); - $this->assertSame("list_integer", $field_storage->getType(), t('Field type is @fieldtype. It should be list_integer.', ['@fieldtype' => $field_storage->getType()])); - $this->assertNotNull($field_storage->getSetting('allowed_values')['1234'], t('First allowed value key is set to 1234')); - $this->assertNotNull($field_storage->getSetting('allowed_values')['2341'], t('Second allowed value key is set to 2341')); - $this->assertNotNull($field_storage->getSetting('allowed_values')['3412'], t('Third allowed value key is set to 3412')); - $this->assertNotNull($field_storage->getSetting('allowed_values')['4123'], t('Fourth allowed value key is set to 4123')); - $this->assertSame('1234', $field_storage->getSetting('allowed_values')['1234'], t('First allowed value is set to 1234')); - $this->assertSame('2341', $field_storage->getSetting('allowed_values')['2341'], t('Second allowed value is set to 2341')); - $this->assertSame('3412', $field_storage->getSetting('allowed_values')['3412'], t('Third allowed value is set to 3412')); - $this->assertSame('4123', $field_storage->getSetting('allowed_values')['4123'], t('Fourth allowed value is set to 4123')); + $this->assertSame("list_integer", $field_storage->getType()); + $this->assertSame('1234', $field_storage->getSetting('allowed_values')['1234']); + $this->assertSame('2341', $field_storage->getSetting('allowed_values')['2341']); + $this->assertSame('3412', $field_storage->getSetting('allowed_values')['3412']); + $this->assertSame('4123', $field_storage->getSetting('allowed_values')['4123']); // Text field with a single checkbox. $field_storage = FieldStorageConfig::load('node.field_test_text_single_checkbox'); - $this->assertSame("boolean", $field_storage->getType(), t('Field type is @fieldtype. It should be boolean.', ['@fieldtype' => $field_storage->getType()])); + $this->assertSame("boolean", $field_storage->getType()); // Test a node reference field. $field_storage = FieldStorageConfig::load('node.field_company'); diff --git a/core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php b/core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php index d99b0021d413227ddb1c1fcc5ea981154ac4244f..dbd1b088169834c13cc1f70f3d7b8af88df1a6f7 100644 --- a/core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php +++ b/core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php @@ -456,7 +456,7 @@ public function fieldUIAddNewField($bundle_path, $field_name, $label = NULL, $fi $page->findButton(t('Save and continue'))->click(); - $assert_session->responseContains(t('These settings apply to the %label field everywhere it is used.', ['%label' => $label])); + $assert_session->pageTextContains("These settings apply to the $label field everywhere it is used."); $breadcrumb_link = $page->findLink($label); // Test breadcrumb. @@ -464,11 +464,11 @@ public function fieldUIAddNewField($bundle_path, $field_name, $label = NULL, $fi // Second step: 'Storage settings' form. $page->findButton('Save field settings')->click(); - $assert_session->responseContains(t('Updated field %label field settings.', ['%label' => $label])); + $assert_session->pageTextContains("Updated field $label field settings."); // Third step: 'Field settings' form. $page->findButton('Save settings')->click(); - $assert_session->responseContains(t('Saved %label configuration.', ['%label' => $label])); + $assert_session->pageTextContains("Saved $label configuration."); // Check that the field appears in the overview form. $row = $page->find('css', '#field-' . $field_name); diff --git a/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php b/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php index 3fada0cc8d6a5e1d8eda92847c609eb1506829a7..b85af5f2c82d95326fc511a5b9edd072627bd5da 100644 --- a/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php +++ b/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php @@ -34,23 +34,22 @@ protected function setUp(): void { * Tests the basic node submission for an anonymous visitor. */ public function testAnonymousNode() { - $bundle_label = 'Article'; - $node_title = 'test page'; + $type = 'Article'; + $title = 'test page'; // Load the node form. $this->drupalLogout(); $this->drupalGet('node/add/article'); $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->pageTextContains(strip_tags(t('Create @name', ['@name' => $bundle_label]))); + $this->assertSession()->pageTextContains("Create $type"); $edit = [ - 'title[0][value]' => $node_title, + 'title[0][value]' => $title, 'body[0][value]' => 'Test article', ]; $this->submitForm($edit, 'Save'); $this->assertSession()->statusCodeEquals(200); - $t_args = ['@type' => $bundle_label, '%title' => $node_title]; - $this->assertSession()->pageTextContains(strip_tags(t('@type %title has been created.', $t_args))); + $this->assertSession()->pageTextContains("$type $title has been created."); $matches = []; if (preg_match('@node/(\d+)$@', $this->getUrl(), $matches)) { $nid = end($matches); @@ -64,29 +63,28 @@ public function testAnonymousNode() { * Tests file submission for an anonymous visitor. */ public function testAnonymousNodeWithFile() { - $bundle_label = 'Article'; - $node_title = 'Test page'; + $type = 'Article'; + $title = 'Test page'; $this->createFileField('field_image', 'node', 'article', [], ['file_extensions' => 'txt png']); // Load the node form. $this->drupalLogout(); $this->drupalGet('node/add/article'); $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->pageTextContains(strip_tags(t('Create @name', ['@name' => $bundle_label]))); + $this->assertSession()->pageTextContains("Create $type"); // Generate an image file. $image = $this->getTestFile('image'); // Submit the form. $edit = [ - 'title[0][value]' => $node_title, + 'title[0][value]' => $title, 'body[0][value]' => 'Test article', 'files[field_image_0]' => $this->container->get('file_system')->realpath($image->getFileUri()), ]; $this->submitForm($edit, 'Save'); $this->assertSession()->statusCodeEquals(200); - $t_args = ['@type' => $bundle_label, '%title' => $node_title]; - $this->assertSession()->pageTextContains(strip_tags(t('@type %title has been created.', $t_args))); + $this->assertSession()->pageTextContains("$type $title has been created."); $matches = []; if (preg_match('@node/(\d+)$@', $this->getUrl(), $matches)) { $nid = end($matches); @@ -122,14 +120,14 @@ public function testAuthenticatedNodeWithFileWithoutTitle() { * Helper method to test file submissions with missing node titles. */ protected function doTestNodeWithFileWithoutTitle() { - $bundle_label = 'Article'; - $node_title = 'Test page'; + $type = 'Article'; + $title = 'Test page'; $this->createFileField('field_image', 'node', 'article', [], ['file_extensions' => 'txt png']); // Load the node form. $this->drupalGet('node/add/article'); $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->pageTextContains(strip_tags(t('Create @name', ['@name' => $bundle_label]))); + $this->assertSession()->pageTextContains("Create $type"); // Generate an image file. $image = $this->getTestFile('image'); @@ -147,20 +145,18 @@ protected function doTestNodeWithFileWithoutTitle() { } $this->submitForm($edit, $label); $this->assertSession()->statusCodeEquals(200); - $t_args = ['@type' => $bundle_label, '%title' => $node_title]; - $this->assertSession()->pageTextNotContains(strip_tags(t('@type %title has been created.', $t_args))); + $this->assertSession()->pageTextNotContains("$type $title has been created."); $this->assertSession()->pageTextContains('Title field is required.'); // Submit the form again but this time with the missing title field. This // should still work. $edit = [ - 'title[0][value]' => $node_title, + 'title[0][value]' => $title, ]; $this->submitForm($edit, $label); // Confirm the final submission actually worked. - $t_args = ['@type' => $bundle_label, '%title' => $node_title]; - $this->assertSession()->pageTextContains(strip_tags(t('@type %title has been created.', $t_args))); + $this->assertSession()->pageTextContains("$type $title has been created."); $matches = []; if (preg_match('@node/(\d+)$@', $this->getUrl(), $matches)) { $nid = end($matches); diff --git a/core/modules/file/tests/src/FunctionalJavascript/FileManagedFileElementTest.php b/core/modules/file/tests/src/FunctionalJavascript/FileManagedFileElementTest.php index f2d788a424cc3664e2fb9b788c203588e0d1cf9d..18c197746d66862367b1551b937de256e599720f 100644 --- a/core/modules/file/tests/src/FunctionalJavascript/FileManagedFileElementTest.php +++ b/core/modules/file/tests/src/FunctionalJavascript/FileManagedFileElementTest.php @@ -85,7 +85,7 @@ public function testManagedFile() { $this->getSession()->getPage()->pressButton($remove_button_title); $this->assertSession()->assertWaitOnAjaxRequest(); $this->submitForm([], 'Save'); - $this->assertSession()->responseContains(t('The file ids are %fids.', ['%fids' => ''])); + $this->assertSession()->pageTextContains('The file ids are .'); // Upload, then Remove, then Submit. $this->drupalGet($path); @@ -100,7 +100,7 @@ public function testManagedFile() { $this->assertSession()->assertWaitOnAjaxRequest(); $this->submitForm([], 'Save'); - $this->assertSession()->responseContains(t('The file ids are %fids.', ['%fids' => ''])); + $this->assertSession()->pageTextContains('The file ids are .'); } } } diff --git a/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php b/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php index 61d046a52e3ca9a0ae2018d602ded897708e830e..53012f3d9c7e05bb174bed75cddf5b805add035d 100644 --- a/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php +++ b/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php @@ -108,13 +108,13 @@ public function assertFileHookCalled($hook, $expected_count = 1, $message = NULL * File object to compare. */ public function assertFileUnchanged(FileInterface $before, FileInterface $after) { - $this->assertEquals($before->id(), $after->id(), t('File id is the same: %file1 == %file2.', ['%file1' => $before->id(), '%file2' => $after->id()])); - $this->assertEquals($before->getOwner()->id(), $after->getOwner()->id(), t('File owner is the same: %file1 == %file2.', ['%file1' => $before->getOwner()->id(), '%file2' => $after->getOwner()->id()])); - $this->assertEquals($before->getFilename(), $after->getFilename(), t('File name is the same: %file1 == %file2.', ['%file1' => $before->getFilename(), '%file2' => $after->getFilename()])); - $this->assertEquals($before->getFileUri(), $after->getFileUri(), t('File path is the same: %file1 == %file2.', ['%file1' => $before->getFileUri(), '%file2' => $after->getFileUri()])); - $this->assertEquals($before->getMimeType(), $after->getMimeType(), t('File MIME type is the same: %file1 == %file2.', ['%file1' => $before->getMimeType(), '%file2' => $after->getMimeType()])); - $this->assertEquals($before->getSize(), $after->getSize(), t('File size is the same: %file1 == %file2.', ['%file1' => $before->getSize(), '%file2' => $after->getSize()])); - $this->assertEquals($before->isPermanent(), $after->isPermanent(), t('File status is the same: %file1 == %file2.', ['%file1' => $before->isPermanent(), '%file2' => $after->isPermanent()])); + $this->assertEquals($before->id(), $after->id(), 'File id is the same'); + $this->assertEquals($before->getOwner()->id(), $after->getOwner()->id(), 'File owner is the same'); + $this->assertEquals($before->getFilename(), $after->getFilename(), 'File name is the same'); + $this->assertEquals($before->getFileUri(), $after->getFileUri(), 'File path is the same'); + $this->assertEquals($before->getMimeType(), $after->getMimeType(), 'File MIME type is the same'); + $this->assertEquals($before->getSize(), $after->getSize(), 'File size is the same'); + $this->assertEquals($before->isPermanent(), $after->isPermanent(), 'File status is the same'); } /** @@ -126,8 +126,8 @@ public function assertFileUnchanged(FileInterface $before, FileInterface $after) * File object to compare. */ public function assertDifferentFile(FileInterface $file1, FileInterface $file2) { - $this->assertNotEquals($file1->id(), $file2->id(), t('Files have different ids: %file1 != %file2.', ['%file1' => $file1->id(), '%file2' => $file2->id()])); - $this->assertNotEquals($file1->getFileUri(), $file2->getFileUri(), t('Files have different paths: %file1 != %file2.', ['%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri()])); + $this->assertNotEquals($file1->id(), $file2->id(), 'Files have different ids'); + $this->assertNotEquals($file1->getFileUri(), $file2->getFileUri(), 'Files have different paths'); } /** @@ -139,8 +139,8 @@ public function assertDifferentFile(FileInterface $file1, FileInterface $file2) * File object to compare. */ public function assertSameFile(FileInterface $file1, FileInterface $file2) { - $this->assertEquals($file1->id(), $file2->id(), t('Files have the same ids: %file1 == %file2.', ['%file1' => $file1->id(), '%file2-fid' => $file2->id()])); - $this->assertEquals($file1->getFileUri(), $file2->getFileUri(), t('Files have the same path: %file1 == %file2.', ['%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri()])); + $this->assertEquals($file1->id(), $file2->id(), 'Files have the same ids'); + $this->assertEquals($file1->getFileUri(), $file2->getFileUri(), 'Files have the same path'); } /** diff --git a/core/modules/file/tests/src/Kernel/Views/FileViewsFieldAccessTest.php b/core/modules/file/tests/src/Kernel/Views/FileViewsFieldAccessTest.php index 1b85a74409c8c841ec46f56acc3f13f72860c343..7480406bf83d2f47715994cb0d43199a436ff093 100644 --- a/core/modules/file/tests/src/Kernel/Views/FileViewsFieldAccessTest.php +++ b/core/modules/file/tests/src/Kernel/Views/FileViewsFieldAccessTest.php @@ -62,7 +62,7 @@ public function testFileFields() { $this->assertFieldAccess('file', 'uri', $file->getFileUri()); $this->assertFieldAccess('file', 'filemime', $file->filemime->value); $this->assertFieldAccess('file', 'filesize', '4 bytes'); - $this->assertFieldAccess('file', 'status', t('Permanent')); + $this->assertFieldAccess('file', 'status', 'Permanent'); // $this->assertFieldAccess('file', 'created', \Drupal::service('date.formatter')->format(123456)); // $this->assertFieldAccess('file', 'changed', \Drupal::service('date.formatter')->format(REQUEST_TIME)); } diff --git a/core/modules/forum/tests/src/Functional/ForumTest.php b/core/modules/forum/tests/src/Functional/ForumTest.php index 8480ab6706d5ed239bfb0c4c795713c53c058394..50d5a302c137b9667079afa897679de05e88cf3b 100644 --- a/core/modules/forum/tests/src/Functional/ForumTest.php +++ b/core/modules/forum/tests/src/Functional/ForumTest.php @@ -135,7 +135,8 @@ public function testForum() { // Check that the basic forum install creates a default forum topic $this->drupalGet('/forum'); // Look for the "General discussion" default forum - $this->assertSession()->responseContains(Link::createFromRoute(t('General discussion'), 'forum.page', ['taxonomy_term' => 1])->toString()); + $this->assertSession()->linkExists('General discussion'); + $this->assertSession()->linkByHrefExists('/forum/1'); // Check the presence of expected cache tags. $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:forum.settings'); diff --git a/core/modules/language/tests/src/Functional/AdminPathEntityConverterLanguageTest.php b/core/modules/language/tests/src/Functional/AdminPathEntityConverterLanguageTest.php index e5508896aab49b082aeb00be1c0c850cadd58a27..1f12ffa4244e517002f36da737a063c3fa3102c7 100644 --- a/core/modules/language/tests/src/Functional/AdminPathEntityConverterLanguageTest.php +++ b/core/modules/language/tests/src/Functional/AdminPathEntityConverterLanguageTest.php @@ -39,12 +39,12 @@ public function testConfigUsingCurrentLanguage() { ->save(); $this->drupalGet('es/admin/language_test/entity_using_current_language/es'); - $this->assertSession()->responseNotContains(t('Loaded %label.', ['%label' => 'Spanish'])); - $this->assertSession()->responseContains(t('Loaded %label.', ['%label' => 'Español'])); + $this->assertSession()->pageTextNotContains('Loaded Spanish.'); + $this->assertSession()->pageTextContains('Loaded Español.'); $this->drupalGet('es/admin/language_test/entity_using_original_language/es'); - $this->assertSession()->responseContains(t('Loaded %label.', ['%label' => 'Spanish'])); - $this->assertSession()->responseNotContains(t('Loaded %label.', ['%label' => 'Español'])); + $this->assertSession()->pageTextContains('Loaded Spanish.'); + $this->assertSession()->pageTextNotContains('Loaded Español.'); } } diff --git a/core/modules/path/tests/src/Functional/PathLanguageUiTest.php b/core/modules/path/tests/src/Functional/PathLanguageUiTest.php index 8d7b4fd4cccf924cb1f9aa59d99a30698565124f..f49788f9eae1404e84db0faf5687e446d1941205 100644 --- a/core/modules/path/tests/src/Functional/PathLanguageUiTest.php +++ b/core/modules/path/tests/src/Functional/PathLanguageUiTest.php @@ -127,7 +127,7 @@ public function testNotSpecifiedNode() { $node = $this->drupalCreateNode(); $this->drupalget($node->toUrl('edit-form')); $this->submitForm([], 'Save'); - $this->assertSession()->pageTextNotContains(t('The alias is already in use.')); + $this->assertSession()->pageTextNotContains('The alias is already in use.'); } } diff --git a/core/modules/search/tests/src/Functional/SearchCommentTest.php b/core/modules/search/tests/src/Functional/SearchCommentTest.php index 2c349779a59de31dd91a8a77d9e9235ee268909d..d0148ca933e7c98a449330cf3f7632b3c9f24aef 100644 --- a/core/modules/search/tests/src/Functional/SearchCommentTest.php +++ b/core/modules/search/tests/src/Functional/SearchCommentTest.php @@ -326,7 +326,7 @@ public function assertCommentAccess($assume_access, $message) { $this->assertSession()->pageTextContains($this->commentSubject); } else { - $this->assertSession()->pageTextContains(t('Your search yielded no results.')); + $this->assertSession()->pageTextContains('Your search yielded no results.'); } } catch (ResponseTextException $exception) { diff --git a/core/modules/search/tests/src/Functional/SearchNodeUpdateAndDeletionTest.php b/core/modules/search/tests/src/Functional/SearchNodeUpdateAndDeletionTest.php index 649bbfe6f05e5dd9b9f8ddf00611c0eed77e6317..66e90b39961582c4bcac6431a49fff22591b011b 100644 --- a/core/modules/search/tests/src/Functional/SearchNodeUpdateAndDeletionTest.php +++ b/core/modules/search/tests/src/Functional/SearchNodeUpdateAndDeletionTest.php @@ -109,7 +109,7 @@ public function testSearchIndexUpdateOnNodeDeletion() { ->condition('word', 'dragons') ->execute() ->fetchField(); - $this->assertNotFalse($search_index_dataset, t('Node info found on the search_index')); + $this->assertNotFalse($search_index_dataset, 'Node info found on the search_index'); // Delete the node. $node->delete(); diff --git a/core/modules/system/tests/src/Functional/Database/SelectTableSortDefaultTest.php b/core/modules/system/tests/src/Functional/Database/SelectTableSortDefaultTest.php index f5799f04c475a67968bc062d7deacbb4d1b2d505..f38ea7a2fca18e4cb23acf80a2479e5b0425b758 100644 --- a/core/modules/system/tests/src/Functional/Database/SelectTableSortDefaultTest.php +++ b/core/modules/system/tests/src/Functional/Database/SelectTableSortDefaultTest.php @@ -86,7 +86,7 @@ public function testTableSortDefaultSort() { // Verify that the table was displayed. Just the header is checked for // because if there were any fatal errors or exceptions in displaying the // sorted table, it would not print the table. - $assert->pageTextContains(t('Username')); + $assert->pageTextContains('Username'); // Verify that the header links are built properly. $assert->linkByHrefExists('database_test/tablesort_default_sort'); diff --git a/core/modules/system/tests/src/Functional/Form/ElementsVerticalTabsTest.php b/core/modules/system/tests/src/Functional/Form/ElementsVerticalTabsTest.php index 8ccb3bb07b4b2c68a634e8f2da4e5b2bcc3fa421..9beabcaf66fa285ce8a9d3c30011e69cdb810fd5 100644 --- a/core/modules/system/tests/src/Functional/Form/ElementsVerticalTabsTest.php +++ b/core/modules/system/tests/src/Functional/Form/ElementsVerticalTabsTest.php @@ -83,12 +83,7 @@ public function testWrapperNotShownWhenEmpty() { */ public function testDefaultTab() { $this->drupalGet('form_test/vertical-tabs'); - - $value = $this->assertSession() - ->elementExists('css', 'input[name="vertical_tabs__active_tab"]') - ->getValue(); - - $this->assertSame('edit-tab3', $value, t('The default vertical tab is correctly selected.')); + $this->assertSession()->elementAttributeContains('css', 'input[name="vertical_tabs__active_tab"]', 'value', 'edit-tab3'); } /** diff --git a/core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php b/core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php index 3dee461407e31c2e326f6cc67fc145bb4aba8b40..849399fd230b521953439c18a30bf9d7159bcd8f 100644 --- a/core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php +++ b/core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php @@ -323,7 +323,7 @@ public function testBreadCrumbs() { // Verify breadcrumb on user pages (without menu link) for anonymous user. $trail = $home; - $this->assertBreadcrumb('user', $trail, t('Log in')); + $this->assertBreadcrumb('user', $trail, 'Log in'); $this->assertBreadcrumb('user/' . $this->adminUser->id(), $trail, $this->adminUser->getAccountName()); // Verify breadcrumb on user pages (without menu link) for registered users. @@ -370,17 +370,17 @@ public function testBreadCrumbs() { // page title, and that the breadcrumb is just the Home link (because the // user is not able to access "Administer". $trail = $home; - $this->assertBreadcrumb('admin', $trail, t('Access denied')); + $this->assertBreadcrumb('admin', $trail, 'Access denied'); $this->assertSession()->statusCodeEquals(403); // Since the 'admin' path is not accessible, we still expect only the Home // link. - $this->assertBreadcrumb('admin/reports', $trail, t('Reports')); + $this->assertBreadcrumb('admin/reports', $trail, 'Reports'); $this->assertSession()->statusCodeNotEquals(403); // Since the Reports page is accessible, that will show. $trail += ['admin/reports' => t('Reports')]; - $this->assertBreadcrumb('admin/reports/dblog', $trail, t('Recent log messages')); + $this->assertBreadcrumb('admin/reports/dblog', $trail, 'Recent log messages'); $this->assertSession()->statusCodeNotEquals(403); // Ensure that the breadcrumb is safe against XSS. diff --git a/core/modules/system/tests/src/Functional/System/FrontPageTest.php b/core/modules/system/tests/src/Functional/System/FrontPageTest.php index d350dfe2d88b970bc0649d4e3548e61d9e335287..75714c38ecc261d70eaca990b3baea512d422390 100644 --- a/core/modules/system/tests/src/Functional/System/FrontPageTest.php +++ b/core/modules/system/tests/src/Functional/System/FrontPageTest.php @@ -84,7 +84,7 @@ public function testDrupalFrontPage() { $this->drupalGet('admin/config/system/site-information'); $this->submitForm($edit, 'Save configuration'); // Check that the front page path has been saved. - $this->assertSession()->pageTextContains(t('The configuration options have been saved.')); + $this->assertSession()->pageTextContains('The configuration options have been saved.'); // Check that path is the front page. $this->drupalGet(''); $this->assertSession()->pageTextContains('On front page.'); diff --git a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php index a88768a9271da1888b06ebd9ff88abe61ba8077a..8ba2ac6072b540e0dbdcabdd5ccb3660852ded88 100644 --- a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php +++ b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php @@ -50,7 +50,7 @@ public function testModuleList() { ]; $this->moduleHandler()->setModuleList($fixed_list); $new_module_list = array_combine(array_keys($fixed_list), array_keys($fixed_list)); - $this->assertModuleList($new_module_list, t('When using a fixed list')); + $this->assertModuleList($new_module_list, 'When using a fixed list'); } /** diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php index d94f17bd57e7b045baf78e45ad2e39dfe0149dc8..c96ec87df6ed2f20dd8703963a7e044425c81ad9 100644 --- a/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php +++ b/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php @@ -291,7 +291,7 @@ public function testVocabularyPermissionsTaxonomyTerm() { $edit['name[0][value]'] = $this->randomMachineName(); $this->submitForm($edit, 'Save'); - $assert_session->pageTextContains(t('Created new term @name.', ['@name' => $edit['name[0][value]']])); + $assert_session->pageTextContains("Created new term {$edit['name[0][value]']}."); $terms = \Drupal::entityTypeManager() ->getStorage('taxonomy_term') diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyTranslationTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyTranslationTest.php index ac321c34cbbbee00b51c313dcda8eca5ece3b6b3..9bcf06075f5e580e61878d5cf94590b428ce0168 100644 --- a/core/modules/taxonomy/tests/src/Functional/VocabularyTranslationTest.php +++ b/core/modules/taxonomy/tests/src/Functional/VocabularyTranslationTest.php @@ -103,18 +103,13 @@ public function testVocabularyTitleLabelTranslation(): void { $this->submitForm(["translation[config_names][taxonomy.vocabulary.$vid][name]" => $translated_vid_name], t('Save translation')); // Assert that the right name label is displayed on the taxonomy term - // overview page. The translations are created in this test; therefore, the - // assertions do not use t(). If t() were used then the correct langcodes - // would need to be provided. + // overview page. $this->drupalGet("admin/structure/taxonomy/manage/$vid/overview"); $this->assertSession()->pageTextContains($vid_name); $this->drupalGet("$langcode/admin/structure/taxonomy/manage/$vid/overview"); $this->assertSession()->pageTextContains($translated_vid_name); // Assert that the right name label is displayed on the taxonomy reset page. - // The translations are created in this test; therefore, the assertions do - // not use t(). If t() were used then the correct langcodes would need to be - // provided. $this->drupalGet("admin/structure/taxonomy/manage/$vid/reset"); $this->assertSession()->pageTextContains($vid_name); $this->drupalGet("$langcode/admin/structure/taxonomy/manage/$vid/reset"); diff --git a/core/modules/update/tests/src/Functional/UpdateContribTest.php b/core/modules/update/tests/src/Functional/UpdateContribTest.php index e9ea3f7fc00f5b5b22b1fddc4980aed71b3136b0..3b07f69161d20c9b266598de52abd01d14e776e8 100644 --- a/core/modules/update/tests/src/Functional/UpdateContribTest.php +++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php @@ -2,8 +2,6 @@ namespace Drupal\Tests\update\Functional; -use Drupal\Core\Link; -use Drupal\Core\Url; use Drupal\Core\Utility\ProjectInfo; use Drupal\update\UpdateManagerInterface; @@ -69,12 +67,14 @@ public function testNoReleasesAvailable() { // Cannot use $this->standardTests() because we need to check for the // 'No available releases found' string. $this->assertSession()->responseContains('<h3>Drupal core</h3>'); - $this->assertSession()->responseContains(Link::fromTextAndUrl(t('Drupal'), Url::fromUri('http://example.com/project/drupal'))->toString()); + $this->assertSession()->linkExists('Drupal'); + $this->assertSession()->linkByHrefExists('http://example.com/project/drupal'); $this->assertSession()->pageTextContains('Up to date'); $this->assertSession()->responseContains('<h3>Modules</h3>'); $this->assertSession()->pageTextNotContains('Update available'); $this->assertSession()->pageTextContains('No available releases found'); - $this->assertSession()->responseNotContains(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString()); + $this->assertSession()->linkNotExists('AAA Update test'); + $this->assertSession()->linkByHrefNotExists('http://example.com/project/aaa_update_test'); $available = update_get_available(); $this->assertFalse(isset($available['aaa_update_test']['fetch_status']), 'Results are cached even if no releases are available.'); @@ -84,7 +84,6 @@ public function testNoReleasesAvailable() { * Tests the basic functionality of a contrib module on the status report. */ public function testUpdateContribBasic() { - $project_link = Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString(); $system_info = [ '#all' => [ 'version' => '8.0.0', @@ -106,7 +105,8 @@ public function testUpdateContribBasic() { $this->assertSession()->pageTextContains('Up to date'); $this->assertSession()->responseContains('<h3>Modules</h3>'); $this->assertSession()->pageTextNotContains('Update available'); - $this->assertSession()->responseContains($project_link); + $this->assertSession()->linkExists('AAA Update test'); + $this->assertSession()->linkByHrefExists('http://example.com/project/aaa_update_test'); // Since aaa_update_test is installed the fact it is hidden and in the // Testing package means it should not appear. @@ -118,7 +118,8 @@ public function testUpdateContribBasic() { 'aaa_update_test' => '1_0', ] ); - $this->assertSession()->responseNotContains($project_link); + $this->assertSession()->linkNotExists('AAA Update test'); + $this->assertSession()->linkByHrefNotExists('http://example.com/project/aaa_update_test'); // A hidden and installed project not in the Testing package should appear. $system_info['aaa_update_test']['package'] = 'aaa_update_test'; @@ -129,7 +130,8 @@ public function testUpdateContribBasic() { 'aaa_update_test' => '1_0', ] ); - $this->assertSession()->responseContains($project_link); + $this->assertSession()->linkExists('AAA Update test'); + $this->assertSession()->linkByHrefExists('http://example.com/project/aaa_update_test'); } /** @@ -190,10 +192,13 @@ public function testUpdateContribOrder() { $this->assertSession()->pageTextContains('CCC Update test'); // We want aaa_update_test included in the ccc_update_test project, not as // its own project on the report. - $this->assertSession()->responseNotContains(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString()); + $this->assertSession()->linkNotExists('AAA Update test'); + $this->assertSession()->linkByHrefNotExists('http://example.com/project/aaa_update_test'); // The other two should be listed as projects. - $this->assertSession()->responseContains(Link::fromTextAndUrl(t('BBB Update test'), Url::fromUri('http://example.com/project/bbb_update_test'))->toString()); - $this->assertSession()->responseContains(Link::fromTextAndUrl(t('CCC Update test'), Url::fromUri('http://example.com/project/ccc_update_test'))->toString()); + $this->assertSession()->linkExists('BBB Update test'); + $this->assertSession()->linkByHrefExists('http://example.com/project/bbb_update_test'); + $this->assertSession()->linkExists('CCC Update test'); + $this->assertSession()->linkByHrefExists('http://example.com/project/ccc_update_test'); // We want to make sure we see the BBB project before the CCC project. // Instead of just searching for 'BBB Update test' or something, we want @@ -389,8 +394,6 @@ public function testUpdateShowDisabledThemes() { 'update_test_subtheme' => '1_0', 'update_test_basetheme' => '1_1-sec', ]; - $base_theme_project_link = Link::fromTextAndUrl(t('Update test base theme'), Url::fromUri('http://example.com/project/update_test_basetheme'))->toString(); - $sub_theme_project_link = Link::fromTextAndUrl(t('Update test subtheme'), Url::fromUri('http://example.com/project/update_test_subtheme'))->toString(); foreach ([TRUE, FALSE] as $check_disabled) { $update_settings->set('check.disabled_extensions', $check_disabled)->save(); $this->refreshUpdateStatus($xml_mapping); @@ -400,13 +403,17 @@ public function testUpdateShowDisabledThemes() { $this->assertSession()->pageTextNotMatches('/Themes/'); if ($check_disabled) { $this->assertSession()->pageTextContains('Uninstalled themes'); - $this->assertSession()->responseContains($base_theme_project_link); - $this->assertSession()->responseContains($sub_theme_project_link); + $this->assertSession()->linkExists('Update test base theme'); + $this->assertSession()->linkByHrefExists('http://example.com/project/update_test_basetheme'); + $this->assertSession()->linkExists('Update test subtheme'); + $this->assertSession()->linkByHrefExists('http://example.com/project/update_test_subtheme'); } else { $this->assertSession()->pageTextNotContains('Uninstalled themes'); - $this->assertSession()->responseNotContains($base_theme_project_link); - $this->assertSession()->responseNotContains($sub_theme_project_link); + $this->assertSession()->linkNotExists('Update test base theme'); + $this->assertSession()->linkByHrefNotExists('http://example.com/project/update_test_basetheme'); + $this->assertSession()->linkNotExists('Update test subtheme'); + $this->assertSession()->linkByHrefNotExists('http://example.com/project/update_test_subtheme'); } } } @@ -496,9 +503,12 @@ public function testUpdateBrokenFetchURL() { $this->assertSession()->pageTextContainsOnce('Failed to get available update data for one project.'); // The other two should be listed as projects. - $this->assertSession()->responseContains(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString()); - $this->assertSession()->responseNotContains(Link::fromTextAndUrl(t('BBB Update test'), Url::fromUri('http://example.com/project/bbb_update_test'))->toString()); - $this->assertSession()->responseContains(Link::fromTextAndUrl(t('CCC Update test'), Url::fromUri('http://example.com/project/ccc_update_test'))->toString()); + $this->assertSession()->linkExists('AAA Update test'); + $this->assertSession()->linkByHrefExists('http://example.com/project/aaa_update_test'); + $this->assertSession()->linkNotExists('BBB Update test'); + $this->assertSession()->linkByHrefNotExists('http://example.com/project/bbb_update_test'); + $this->assertSession()->linkExists('CCC Update test'); + $this->assertSession()->linkByHrefExists('http://example.com/project/ccc_update_test'); } /** @@ -543,7 +553,8 @@ public function testHookUpdateStatusAlter() { $this->drupalGet('admin/reports/updates'); $this->assertSession()->responseContains('<h3>Modules</h3>'); $this->assertSession()->pageTextContains('Security update required!'); - $this->assertSession()->responseContains(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString()); + $this->assertSession()->linkExists('AAA Update test'); + $this->assertSession()->linkByHrefExists('http://example.com/project/aaa_update_test'); // Visit the reports page again without the altering and make sure the // status is back to normal. @@ -551,7 +562,8 @@ public function testHookUpdateStatusAlter() { $this->drupalGet('admin/reports/updates'); $this->assertSession()->responseContains('<h3>Modules</h3>'); $this->assertSession()->pageTextNotContains('Security update required!'); - $this->assertSession()->responseContains(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString()); + $this->assertSession()->linkExists('AAA Update test'); + $this->assertSession()->linkByHrefExists('http://example.com/project/aaa_update_test'); // Turn the altering back on and visit the Update manager UI. $update_test_config->set('update_status', $update_status)->save(); diff --git a/core/modules/update/tests/src/Functional/UpdateTestBase.php b/core/modules/update/tests/src/Functional/UpdateTestBase.php index d603aca4f6f8ec77b4090aa8a8ae45aaaadf48d2..69d1f9f865b1d9ed973f6d59da7280ad358bd276 100644 --- a/core/modules/update/tests/src/Functional/UpdateTestBase.php +++ b/core/modules/update/tests/src/Functional/UpdateTestBase.php @@ -3,7 +3,6 @@ namespace Drupal\Tests\update\Functional; use Drupal\Core\DrupalKernel; -use Drupal\Core\Link; use Drupal\Core\Url; use Drupal\Tests\BrowserTestBase; @@ -108,7 +107,8 @@ protected function refreshUpdateStatus($xml_map, $url = 'update-test') { protected function standardTests() { $this->assertSession()->responseContains('<h3>Drupal core</h3>'); // Verify that the link to the Drupal project appears. - $this->assertSession()->responseContains(Link::fromTextAndUrl(t('Drupal'), Url::fromUri('http://example.com/project/drupal'))->toString()); + $this->assertSession()->linkExists('Drupal'); + $this->assertSession()->linkByHrefExists('http://example.com/project/drupal'); $this->assertSession()->pageTextNotContains('No available releases found'); $this->assertSession()->pageTextContains('Last checked:'); } diff --git a/core/modules/update/tests/src/Functional/UpdateUploadTest.php b/core/modules/update/tests/src/Functional/UpdateUploadTest.php index ed2a4853106cbac39249e5194ad1e872eb6de2cd..4d447c17ead93d50adedb82669b6476651709ee4 100644 --- a/core/modules/update/tests/src/Functional/UpdateUploadTest.php +++ b/core/modules/update/tests/src/Functional/UpdateUploadTest.php @@ -60,7 +60,7 @@ public function testUploadModule() { $this->drupalGet('admin/modules/install'); $this->submitForm($edit, 'Continue'); $extensions = \Drupal::service('plugin.manager.archiver')->getExtensions(); - $this->assertSession()->pageTextContains(t('Only files with the following extensions are allowed: @archive_extensions.', ['@archive_extensions' => $extensions])); + $this->assertSession()->pageTextContains("Only files with the following extensions are allowed: $extensions."); $this->assertSession()->addressEquals('admin/modules/install'); // Check to ensure an existing module can't be reinstalled. Also checks that