Commit 6d4eefc3 authored by catch's avatar catch

Issue #3184493 by longwave, ravi.shankar, Pooja Ganjage, mondrake: Remove use...

Issue #3184493 by longwave, ravi.shankar, Pooja Ganjage, mondrake: Remove use of concatenated t() in assertions

(cherry picked from commit 9e8c0511)
parent d2debc75
......@@ -68,7 +68,7 @@ public function testBlockNotInHiddenRegion() {
// Ensure that "block_test_theme" is set as the default theme.
$this->drupalGet('admin/structure/block');
$this->assertText('Block test theme(' . t('active tab') . ')', 'Default local task on blocks admin page is the block test theme.');
$this->assertSession()->pageTextContains('Block test theme(active tab)');
// Ensure that the search form block is displayed.
$this->drupalGet('');
......
......@@ -43,8 +43,9 @@ public function testNonDefaultBlockAdmin() {
$this->drupalLogin($admin_user);
$new_theme = 'bartik';
\Drupal::service('theme_installer')->install([$new_theme]);
// Ensure that the Bartik tab is shown.
$this->drupalGet('admin/structure/block/list/' . $new_theme);
$this->assertText('Bartik(' . t('active tab') . ')', 'Tab for non-default theme found.');
$this->assertSession()->pageTextContains('Bartik(active tab)');
}
}
......@@ -109,7 +109,7 @@ public function testCommentInterface() {
$this->drupalGet('comment/' . $comment->id() . '/edit');
$comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), ['name' => $random_name]);
$this->drupalGet('node/' . $this->node->id());
$this->assertText($random_name . ' (' . t('not verified') . ')', 'Comment author successfully changed to an unverified user.');
$this->assertSession()->pageTextContains($random_name . ' (not verified)');
// Test changing the comment author to a verified user.
$this->drupalGet('comment/' . $comment->id() . '/edit');
......
......@@ -110,7 +110,7 @@ protected function doBlockListTest() {
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->assertSession()->responseContains('<th>Language</th>');
}
/**
......@@ -157,7 +157,7 @@ protected function doMenuListTest() {
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->assertSession()->responseContains('<th>Language</th>');
}
/**
......@@ -182,7 +182,7 @@ protected function doVocabularyListTest() {
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->assertSession()->responseContains('<th>Language</th>');
}
/**
......@@ -207,7 +207,7 @@ public function doCustomContentTypeListTest() {
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->assertSession()->responseContains('<th>Language</th>');
}
/**
......@@ -231,7 +231,7 @@ public function doContactFormsListTest() {
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->assertSession()->responseContains('<th>Language</th>');
}
/**
......@@ -254,7 +254,7 @@ public function doContentTypeListTest() {
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->assertSession()->responseContains('<th>Language</th>');
}
/**
......@@ -278,7 +278,7 @@ public function doFormatsListTest() {
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->assertSession()->responseContains('<th>Language</th>');
}
/**
......@@ -302,7 +302,7 @@ public function doShortcutListTest() {
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->assertSession()->responseContains('<th>Language</th>');
}
/**
......@@ -323,7 +323,7 @@ public function doUserRoleListTest() {
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->assertSession()->responseContains('<th>Language</th>');
}
/**
......@@ -343,7 +343,7 @@ public function doLanguageListTest() {
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->assertSession()->responseContains('<th>Language</th>');
}
/**
......@@ -359,7 +359,7 @@ public function doImageStyleListTest() {
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->assertSession()->responseContains('<th>Language</th>');
}
/**
......@@ -383,7 +383,7 @@ public function doResponsiveImageListTest() {
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->assertSession()->responseContains('<th>Language</th>');
}
/**
......@@ -435,7 +435,7 @@ public function doFieldListTest() {
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->assertSession()->responseContains('<th>Language</th>');
}
}
......@@ -452,7 +452,7 @@ public function doDateFormatListTest() {
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->assertSession()->responseContains('<th>Language</th>');
}
/**
......@@ -471,7 +471,7 @@ public function doSettingsPageTest($link) {
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->assertSession()->responseContains('<th>Language</th>');
}
/**
......
......@@ -123,7 +123,7 @@ public function testMapperListPage() {
$title = $test_entity->label() . ' ' . $entity_type->getSingularLabel();
$title = 'Translations for <em class="placeholder">' . Html::escape($title) . '</em>';
$this->assertRaw($title);
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->assertSession()->responseContains('<th>Language</th>');
$this->drupalGet($base_url);
$this->assertSession()->linkExists('Translate test configuration');
......
......@@ -54,7 +54,7 @@ public function testTranslateOperationInViewListUi() {
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->assertSession()->responseContains('<th>Language</th>');
// Test that the 'Edit' tab appears.
$this->assertSession()->linkByHrefExists('admin/structure/views/view/test_view');
......
......@@ -436,7 +436,7 @@ protected function getFormSubmitActionForNewTranslation(EntityInterface $entity,
* Name of the button to hit.
*/
protected function getFormSubmitAction(EntityInterface $entity, $langcode) {
return t('Save') . $this->getFormSubmitSuffix($entity, $langcode);
return 'Save' . $this->getFormSubmitSuffix($entity, $langcode);
}
/**
......
......@@ -274,7 +274,6 @@ public function assertNodeViewTextHelper(EntityInterface $node, $view_mode, $tex
->getViewBuilder('node')
->view($clone, $view_mode);
$output = (string) \Drupal::service('renderer')->renderRoot($element);
$this->verbose(t('Rendered node - view mode: @view_mode', ['@view_mode' => $view_mode]) . '<hr />' . $output);
if ($not_exists) {
$this->assertStringNotContainsString((string) $text, $output, $message);
......
......@@ -166,8 +166,7 @@ public function testHandleExtension() {
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$message = t('Only files with the following extensions are allowed:') . ' <em class="placeholder">' . $extensions . '</em>';
$this->assertRaw($message);
$this->assertSession()->responseContains('Only files with the following extensions are allowed: <em class="placeholder">' . $extensions . '</em>');
$this->assertRaw(t('Epic upload FAIL!'));
// Check that the correct hooks were called.
......@@ -228,8 +227,7 @@ public function testHandleDangerousFile() {
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$message = t('For security reasons, your upload has been renamed to') . ' <em class="placeholder">' . $this->phpfile->filename . '_.txt' . '</em>';
$this->assertRaw($message);
$this->assertSession()->responseContains('For security reasons, your upload has been renamed to <em class="placeholder">' . $this->phpfile->filename . '_.txt' . '</em>');
$this->assertRaw(t('File MIME type is text/plain.'));
$this->assertRaw(t('You WIN!'));
......@@ -522,7 +520,7 @@ public function testCombinedErrorMessages() {
$this->assertRaw(t('Epic upload FAIL!'));
// Search for combined error message followed by a formatted list of messages.
$this->assertRaw(t('One or more files could not be uploaded.') . '<div class="item-list">');
$this->assertSession()->responseContains('One or more files could not be uploaded.<div class="item-list">');
}
/**
......
......@@ -187,8 +187,7 @@ public function testHandleExtension() {
$this->drupalPostForm('file-test/upload', $edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$message = t('Only files with the following extensions are allowed:') . ' <em class="placeholder">' . $extensions . '</em>';
$this->assertRaw($message);
$this->assertSession()->responseContains('Only files with the following extensions are allowed: <em class="placeholder">' . $extensions . '</em>');
$this->assertRaw(t('Epic upload FAIL!'));
// Check that the correct hooks were called.
......@@ -243,8 +242,7 @@ public function testHandleExtension() {
];
$this->drupalPostForm('file-test/upload', $edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$message = t('For security reasons, your upload has been renamed to') . ' <em class="placeholder">' . $this->phpfile->filename . '_.txt' . '</em>';
$this->assertRaw($message);
$this->assertSession()->responseContains('For security reasons, your upload has been renamed to <em class="placeholder">' . $this->phpfile->filename . '_.txt' . '</em>');
$this->assertSession()->pageTextContains('File name is php-2.php_.txt.');
$this->assertRaw(t('File MIME type is text/plain.'));
$this->assertRaw(t('You WIN!'));
......@@ -268,8 +266,7 @@ public function testHandleDangerousFile() {
$this->drupalPostForm('file-test/upload', $edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$message = t('For security reasons, your upload has been renamed to') . ' <em class="placeholder">' . $this->phpfile->filename . '_.txt' . '</em>';
$this->assertRaw($message);
$this->assertSession()->responseContains('For security reasons, your upload has been renamed to <em class="placeholder">' . $this->phpfile->filename . '_.txt' . '</em>');
$this->assertSession()->pageTextContains('File name is php-2.php_.txt.');
$this->assertRaw(t('File MIME type is text/plain.'));
$this->assertRaw(t('You WIN!'));
......@@ -300,8 +297,7 @@ public function testHandleDangerousFile() {
$edit['extensions'] = 'foo';
$this->drupalPostForm('file-test/upload', $edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$message = t('Only files with the following extensions are allowed:') . ' <em class="placeholder">' . $edit['extensions'] . '</em>';
$this->assertRaw($message);
$this->assertSession()->responseContains('Only files with the following extensions are allowed: <em class="placeholder">' . $edit['extensions'] . '</em>');
$this->assertRaw(t('Epic upload FAIL!'));
// Check that the correct hooks were called.
......@@ -316,8 +312,7 @@ public function testHandleDangerousFile() {
$config->set('allow_insecure_uploads', 0)->save();
$this->drupalPostForm('file-test/upload', $edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$message = t('Only files with the following extensions are allowed:') . ' <em class="placeholder">' . $edit['extensions'] . '</em>';
$this->assertRaw($message);
$this->assertSession()->responseContains('Only files with the following extensions are allowed: <em class="placeholder">' . $edit['extensions'] . '</em>');
$this->assertRaw(t('Epic upload FAIL!'));
// Check that the correct hooks were called.
......
......@@ -76,12 +76,12 @@ public function testHelp() {
$this->assertRaw(t('For more information, refer to the help listed on this page or to the <a href=":docs">online documentation</a> and <a href=":support">support</a> pages at <a href=":drupal">drupal.org</a>.', [':docs' => 'https://www.drupal.org/documentation', ':support' => 'https://www.drupal.org/support', ':drupal' => 'https://www.drupal.org']));
// Verify that hook_help() section title and description appear.
$this->assertRaw('<h2>' . t('Module overviews') . '</h2>');
$this->assertRaw('<p>' . t('Module overviews are provided by modules. Overviews available for your installed modules:') . '</p>');
$this->assertSession()->responseContains('<h2>Module overviews</h2>');
$this->assertSession()->responseContains('<p>Module overviews are provided by modules. Overviews available for your installed modules:</p>');
// Verify that an empty section is handled correctly.
$this->assertRaw('<h2>' . t('Empty section') . '</h2>');
$this->assertRaw('<p>' . t('This description should appear.') . '</p>');
$this->assertSession()->responseContains('<h2>Empty section</h2>');
$this->assertSession()->responseContains('<p>This description should appear.</p>');
$this->assertText('There is currently nothing in this section.');
// Make sure links are properly added for modules implementing hook_help().
......
......@@ -124,8 +124,7 @@ public function testInterface() {
$this->drupalGet('admin/reports/translations');
$this->assertText('Updates for: Drupal core', 'Translations found');
$this->assertText('Drupal core (' . $this->container->get('date.formatter')->format(REQUEST_TIME, 'html_date') . ')', 'Core translation update');
$update_button = $this->xpath('//input[@type="submit"][@value="' . t('Update translations') . '"]');
$this->assertNotEmpty($update_button, 'Update translations button');
$this->assertSession()->buttonExists('Update translations');
}
}
......@@ -90,10 +90,8 @@ public function testFormLabels() {
$this->assertTrue(isset($elements[0]), 'Properly places the #suffix element before the form item.');
// Check title attribute for radios and checkboxes.
$elements = $this->xpath('//div[@id="edit-form-checkboxes-title-attribute"]');
$this->assertEqual($elements[0]->getAttribute('title'), 'Checkboxes test' . ' (' . t('Required') . ')', 'Title attribute found.');
$elements = $this->xpath('//div[@id="edit-form-radios-title-attribute"]');
$this->assertEqual($elements[0]->getAttribute('title'), 'Radios test' . ' (' . t('Required') . ')', 'Title attribute found.');
$this->assertSession()->elementAttributeContains('css', '#edit-form-checkboxes-title-attribute', 'title', 'Checkboxes test (Required)');
$this->assertSession()->elementAttributeContains('css', '#edit-form-radios-title-attribute', 'title', 'Radios test (Required)');
$elements = $this->xpath('//fieldset[@id="edit-form-checkboxes-title-invisible--wrapper"]/legend/span[contains(@class, "visually-hidden")]');
$this->assertTrue(!empty($elements), "Title/Label not displayed when 'visually-hidden' attribute is set in checkboxes.");
......
......@@ -365,13 +365,13 @@ public function testSwitchDefaultTheme() {
// Test the default theme on the secondary links (blocks admin page).
$this->drupalGet('admin/structure/block');
$this->assertText('Bartik(' . t('active tab') . ')', 'Default local task on blocks admin page is the default theme.');
$this->assertSession()->pageTextContains('Bartik(active tab)');
// Switch back to Stark and test again to test that the menu cache is cleared.
$this->drupalGet('admin/appearance');
// Stark is the first 'Set as default' link.
$this->clickLink(t('Set as default'));
$this->drupalGet('admin/structure/block');
$this->assertText('Stark(' . t('active tab') . ')', 'Default local task on blocks admin page has changed.');
$this->assertSession()->pageTextContains('Stark(active tab)');
}
/**
......
......@@ -68,10 +68,10 @@ public function testNoReleasesAvailable() {
$this->drupalGet('admin/reports/updates');
// Cannot use $this->standardTests() because we need to check for the
// 'No available releases found' string.
$this->assertRaw('<h3>' . t('Drupal core') . '</h3>');
$this->assertSession()->responseContains('<h3>Drupal core</h3>');
$this->assertRaw(Link::fromTextAndUrl(t('Drupal'), Url::fromUri('http://example.com/project/drupal'))->toString());
$this->assertText('Up to date');
$this->assertRaw('<h3>' . t('Modules') . '</h3>');
$this->assertSession()->responseContains('<h3>Modules</h3>');
$this->assertNoText('Update available');
$this->assertText('No available releases found');
$this->assertNoRaw(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString());
......@@ -104,7 +104,7 @@ public function testUpdateContribBasic() {
);
$this->standardTests();
$this->assertText('Up to date');
$this->assertRaw('<h3>' . t('Modules') . '</h3>');
$this->assertSession()->responseContains('<h3>Modules</h3>');
$this->assertNoText('Update available');
$this->assertRaw($project_link);
......@@ -487,7 +487,7 @@ public function testUpdateBrokenFetchURL() {
// We need to check that this string is found as part of a project row, not
// just in the "Failed to get available update data" message at the top of
// the page.
$this->assertRaw('<div class="project-update__status">' . t('Failed to get available update data'));
$this->assertSession()->responseContains('<div class="project-update__status">Failed to get available update data');
// We should see the output messages from fetching manually.
$this->assertSession()->pageTextContainsOnce('Checked available update data for 3 projects.');
......@@ -539,7 +539,7 @@ public function testHookUpdateStatusAlter() {
]
);
$this->drupalGet('admin/reports/updates');
$this->assertRaw('<h3>' . t('Modules') . '</h3>');
$this->assertSession()->responseContains('<h3>Modules</h3>');
$this->assertText('Security update required!');
$this->assertRaw(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString());
......@@ -547,7 +547,7 @@ public function testHookUpdateStatusAlter() {
// status is back to normal.
$update_test_config->set('update_status', [])->save();
$this->drupalGet('admin/reports/updates');
$this->assertRaw('<h3>' . t('Modules') . '</h3>');
$this->assertSession()->responseContains('<h3>Modules</h3>');
$this->assertNoText('Security update required!');
$this->assertRaw(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString());
......
......@@ -748,11 +748,7 @@ public function testModulePageSecurityUpdate() {
// Make sure duplicate messages don't appear on Update status pages.
$this->drupalGet('admin/reports/status');
// We're expecting "There is a security update..." inside the status report
// itself, but the message from
// \Drupal\Core\Messenger\MessengerInterface::addStatus() appears as an li
// so we can prefix with that and search for the raw HTML.
$this->assertNoRaw('<li>' . t('There is a security update available for your version of Drupal.'));
$this->assertSession()->pageTextContainsOnce('There is a security update available for your version of Drupal.');
$this->drupalGet('admin/reports/updates');
$this->assertNoText('There is a security update available for your version of Drupal.');
......
......@@ -106,7 +106,7 @@ protected function refreshUpdateStatus($xml_map, $url = 'update-test') {
* Runs a series of assertions that are applicable to all update statuses.
*/
protected function standardTests() {
$this->assertRaw('<h3>' . t('Drupal core') . '</h3>');
$this->assertSession()->responseContains('<h3>Drupal core</h3>');
// Verify that the link to the Drupal project appears.
$this->assertRaw(Link::fromTextAndUrl(t('Drupal'), Url::fromUri('http://example.com/project/drupal'))->toString());
$this->assertNoText('No available releases found');
......
......@@ -63,8 +63,8 @@ public function testViewsGetHandler() {
],
];
$form_state = new FormState();
$description_top = '<p>' . t('The handler for this item is broken or missing. The following details are available:') . '</p>';
$description_bottom = '<p>' . t('Enabling the appropriate module may solve this issue. Otherwise, check to see if there is a module update available.') . '</p>';
$description_top = '<p>The handler for this item is broken or missing. The following details are available:</p>';
$description_bottom = '<p>Enabling the appropriate module may solve this issue. Otherwise, check to see if there is a module update available.</p>';
foreach ($types as $type => $class) {
foreach ($items as $item) {
$handler = $this->container->get('plugin.manager.views.' . $type)
......
......@@ -32,13 +32,13 @@ public function testFieldUI() {
// Ensure the field is not marked as hidden on the first run.
$this->drupalGet('admin/structure/views/view/test_view/edit');
$this->assertText('Views test: Name');
$this->assertNoText('Views test: Name [' . t('hidden') . ']');
$this->assertSession()->pageTextNotContains('Views test: Name [hidden]');
// Hides the field and check whether the hidden label is appended.
$edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/name';
$this->drupalPostForm($edit_handler_url, ['options[exclude]' => TRUE], 'Apply');
$this->assertText('Views test: Name [' . t('hidden') . ']');
$this->assertSession()->pageTextContains('Views test: Name [hidden]');
// Ensure that the expected tokens appear in the UI.
$edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/age';
......
......@@ -336,11 +336,11 @@ public function testEntityAutocompleteAccess() {
// Rebuild the form.
$form = $form_builder->getForm($this);
$expected = t('- Restricted access -') . ' (' . $this->referencedEntities[0]->id() . ')';
$this->assertEqual($form['single_access']['#value'], $expected);
$expected = '- Restricted access - (' . $this->referencedEntities[0]->id() . ')';
$this->assertEquals($expected, $form['single_access']['#value']);
$expected .= ', ' . t('- Restricted access -') . ' (' . $this->referencedEntities[1]->id() . ')';
$this->assertEqual($form['tags_access']['#value'], $expected);
$expected .= ', - Restricted access - (' . $this->referencedEntities[1]->id() . ')';
$this->assertEquals($expected, $form['tags_access']['#value']);
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment