Commit 783e7eb8 authored by catch's avatar catch

Issue #3145005 by longwave, mondrake, cburschka, raman.b, Lal_, dww, xjm:...

Issue #3145005 by longwave, mondrake, cburschka, raman.b, Lal_, dww, xjm: [November 9, 2020] Remove uses of t() in drupalPostForm() calls
parent 4a477027
......@@ -37,7 +37,7 @@ public function testActionConfiguration() {
// Make a POST request to admin/config/system/actions.
$edit = [];
$edit['action'] = 'action_goto_action';
$this->drupalPostForm('admin/config/system/actions', $edit, t('Create'));
$this->drupalPostForm('admin/config/system/actions', $edit, 'Create');
$this->assertSession()->statusCodeEquals(200);
// Make a POST request to the individual action configuration page.
......@@ -46,7 +46,7 @@ public function testActionConfiguration() {
$edit['label'] = $action_label;
$edit['id'] = strtolower($action_label);
$edit['url'] = 'admin';
$this->drupalPostForm('admin/config/system/actions/add/action_goto_action', $edit, t('Save'));
$this->drupalPostForm('admin/config/system/actions/add/action_goto_action', $edit, 'Save');
$this->assertSession()->statusCodeEquals(200);
$action_id = $edit['id'];
......@@ -62,7 +62,7 @@ public function testActionConfiguration() {
$new_action_label = $this->randomMachineName();
$edit['label'] = $new_action_label;
$edit['url'] = 'admin';
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->drupalPostForm(NULL, $edit, 'Save');
$this->assertSession()->statusCodeEquals(200);
// Make sure that the action updated properly.
......@@ -79,7 +79,7 @@ public function testActionConfiguration() {
$this->clickLink(t('Delete'));
$this->assertSession()->statusCodeEquals(200);
$edit = [];
$this->drupalPostForm(NULL, $edit, t('Delete'));
$this->drupalPostForm(NULL, $edit, 'Delete');
$this->assertSession()->statusCodeEquals(200);
// Make sure that the action was actually deleted.
......
......@@ -45,7 +45,7 @@ public function testAddFeed() {
'url[0][value]' => $feed->getUrl(),
'refresh' => '900',
];
$this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
$this->drupalPostForm('aggregator/sources/add', $edit, 'Save');
$this->assertRaw(t('A feed named %feed already exists. Enter a unique title.', ['%feed' => $feed->label()]));
$this->assertRaw(t('A feed with this URL %url already exists. Enter a unique URL.', ['%url' => $feed->getUrl()]));
......
......@@ -36,7 +36,7 @@ public function testSettingsPage() {
'aggregator_parser' => 'aggregator_test_parser',
'aggregator_processors[aggregator_test_processor]' => 'aggregator_test_processor',
];
$this->drupalPostForm('admin/config/services/aggregator/settings', $edit, t('Save configuration'));
$this->drupalPostForm('admin/config/services/aggregator/settings', $edit, 'Save configuration');
$this->assertText('The configuration options have been saved.');
// Check that settings have the correct default value.
......@@ -50,7 +50,7 @@ public function testSettingsPage() {
$edit = [
'dummy_length' => 100,
];
$this->drupalPostForm('admin/config/services/aggregator/settings', $edit, t('Save configuration'));
$this->drupalPostForm('admin/config/services/aggregator/settings', $edit, 'Save configuration');
$this->assertText('The configuration options have been saved.');
$this->assertSession()->fieldValueEquals('dummy_length', 100);
......
......@@ -74,7 +74,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->drupalPostForm('aggregator/sources/add', $edit, 'Save');
$this->assertText('The feed ' . Html::escape($edit['title[0][value]']) . ' has been added.', new FormattableMarkup('The feed @name has been added.', ['@name' => $edit['title[0][value]']]));
// Verify that the creation message contains a link to a feed.
......@@ -92,7 +92,7 @@ public function createFeed($feed_url = NULL, array $edit = []) {
* Feed object representing the feed.
*/
public function deleteFeed(FeedInterface $feed) {
$this->drupalPostForm('aggregator/sources/' . $feed->id() . '/delete', [], t('Delete'));
$this->drupalPostForm('aggregator/sources/' . $feed->id() . '/delete', [], 'Delete');
$this->assertRaw(t('The feed %title has been deleted.', ['%title' => $feed->label()]));
}
......@@ -212,7 +212,7 @@ public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {
* Feed object representing the feed.
*/
public function deleteFeedItems(FeedInterface $feed) {
$this->drupalPostForm('admin/config/services/aggregator/delete/' . $feed->id(), [], t('Delete items'));
$this->drupalPostForm('admin/config/services/aggregator/delete/' . $feed->id(), [], 'Delete items');
$this->assertRaw(t('The news items from %title have been deleted.', ['%title' => $feed->label()]));
}
......@@ -376,7 +376,7 @@ public function createSampleNodes($count = 5) {
$edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$edit['body[0][value]'] = $this->randomMachineName();
$this->drupalPostForm('node/add/article', $edit, t('Save'));
$this->drupalPostForm('node/add/article', $edit, 'Save');
}
}
......
......@@ -68,7 +68,7 @@ public function testFeedLanguage() {
$edit['entity_types[aggregator_feed]'] = TRUE;
$edit['settings[aggregator_feed][aggregator_feed][settings][language][language_alterable]'] = TRUE;
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
$this->drupalPostForm('admin/config/regional/content-language', $edit, 'Save configuration');
/** @var \Drupal\aggregator\FeedInterface[] $feeds */
$feeds = [];
......
......@@ -61,7 +61,7 @@ public function validateImportFormFields() {
$before = $count_query->execute();
$edit = [];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, 'Import');
$this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'));
$path = $this->getEmptyOpml();
......@@ -69,11 +69,11 @@ public function validateImportFormFields() {
'files[upload]' => $path,
'remote' => file_create_url($path),
];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, 'Import');
$this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'));
$edit = ['remote' => 'invalidUrl://empty'];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, 'Import');
$this->assertText('The URL invalidUrl://empty is not valid.', 'Error if the URL is invalid.');
$after = $count_query->execute();
......@@ -88,11 +88,11 @@ protected function submitImportForm() {
$before = $count_query->execute();
$form['files[upload]'] = $this->getInvalidOpml();
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $form, t('Import'));
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $form, 'Import');
$this->assertText('No new feed has been added.', 'Attempting to upload invalid XML.');
$edit = ['remote' => file_create_url($this->getEmptyOpml())];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, 'Import');
$this->assertText('No new feed has been added.', 'Attempting to load empty OPML from remote URL.');
$after = $count_query->execute();
......@@ -109,7 +109,7 @@ protected function submitImportForm() {
'files[upload]' => $this->getValidOpml($feeds),
'refresh' => '900',
];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, 'Import');
// Verify that a duplicate URL was identified.
$this->assertRaw(t('A feed with the URL %url already exists.', ['%url' => $feeds[0]['url[0][value]']]));
// Verify that a duplicate title was identified.
......
......@@ -43,7 +43,7 @@ public function testUpdateFeedItem() {
$this->drupalGet($edit['url[0][value]']);
$this->assertSession()->statusCodeEquals(200);
$this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
$this->drupalPostForm('aggregator/sources/add', $edit, 'Save');
$this->assertText('The feed ' . $edit['title[0][value]'] . ' has been added.', new FormattableMarkup('The feed @name has been added.', ['@name' => $edit['title[0][value]']]));
// Verify that the creation message contains a link to a feed.
......
......@@ -31,7 +31,7 @@ public function testUpdateFeed() {
if (isset($feed->{$same_field}->value)) {
$edit[$same_field] = $feed->{$same_field}->value;
}
$this->drupalPostForm('aggregator/sources/' . $feed->id() . '/configure', $edit, t('Save'));
$this->drupalPostForm('aggregator/sources/' . $feed->id() . '/configure', $edit, 'Save');
$this->assertText('The feed ' . $edit['title[0][value]'] . ' has been updated.', new FormattableMarkup('The feed %name has been updated.', ['%name' => $edit['title[0][value]']]));
// Verify that the creation message contains a link to a feed.
......
......@@ -38,7 +38,7 @@ public function testIPAddressValidation() {
// Ban a valid IP address.
$edit = [];
$edit['ip'] = '1.2.3.3';
$this->drupalPostForm('admin/config/people/ban', $edit, t('Add'));
$this->drupalPostForm('admin/config/people/ban', $edit, 'Add');
$ip = $connection->select('ban_ip', 'bi')->fields('bi', ['iid'])->condition('ip', $edit['ip'])->execute()->fetchField();
$this->assertNotEmpty($ip, 'IP address found in database.');
$this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $edit['ip']]));
......@@ -46,30 +46,30 @@ public function testIPAddressValidation() {
// Try to block an IP address that's already blocked.
$edit = [];
$edit['ip'] = '1.2.3.3';
$this->drupalPostForm('admin/config/people/ban', $edit, t('Add'));
$this->drupalPostForm('admin/config/people/ban', $edit, 'Add');
$this->assertText('This IP address is already banned.');
// Try to block a reserved IP address.
$edit = [];
$edit['ip'] = '255.255.255.255';
$this->drupalPostForm('admin/config/people/ban', $edit, t('Add'));
$this->drupalPostForm('admin/config/people/ban', $edit, 'Add');
$this->assertText('Enter a valid IP address.');
// Try to block a reserved IP address.
$edit = [];
$edit['ip'] = 'test.example.com';
$this->drupalPostForm('admin/config/people/ban', $edit, t('Add'));
$this->drupalPostForm('admin/config/people/ban', $edit, 'Add');
$this->assertText('Enter a valid IP address.');
// Submit an empty form.
$edit = [];
$edit['ip'] = '';
$this->drupalPostForm('admin/config/people/ban', $edit, t('Add'));
$this->drupalPostForm('admin/config/people/ban', $edit, 'Add');
$this->assertText('Enter a valid IP address.');
// Pass an IP address as a URL parameter and submit it.
$submit_ip = '1.2.3.4';
$this->drupalPostForm('admin/config/people/ban/' . $submit_ip, [], t('Add'));
$this->drupalPostForm('admin/config/people/ban/' . $submit_ip, [], 'Add');
$ip = $connection->select('ban_ip', 'bi')->fields('bi', ['iid'])->condition('ip', $submit_ip)->execute()->fetchField();
$this->assertNotEmpty($ip, 'IP address found in database');
$this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $submit_ip]));
......@@ -79,7 +79,7 @@ public function testIPAddressValidation() {
// TODO: On some systems this test fails due to a bug/inconsistency in cURL.
// $edit = array();
// $edit['ip'] = \Drupal::request()->getClientIP();
// $this->drupalPostForm('admin/config/people/ban', $edit, t('Save'));
// $this->drupalPostForm('admin/config/people/ban', $edit, 'Save');
// $this->assertText('You may not ban your own IP address.');
// Test duplicate ip address are not present in the 'blocked_ips' table.
......
......@@ -42,7 +42,7 @@ public function testAdminTheme() {
// Install admin theme and confirm that tab is accessible.
\Drupal::service('theme_installer')->install(['bartik']);
$edit['admin_theme'] = 'bartik';
$this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
$this->drupalPostForm('admin/appearance', $edit, 'Save configuration');
$this->drupalGet('admin/structure/block/list/bartik');
$this->assertSession()->statusCodeEquals(200);
}
......@@ -63,7 +63,7 @@ public function testSevenAdminTheme() {
// Install admin theme and confirm that tab is accessible.
\Drupal::service('theme_installer')->install(['seven']);
$edit['admin_theme'] = 'seven';
$this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
$this->drupalPostForm('admin/appearance', $edit, 'Save configuration');
// Define our block settings.
$settings = [
......
......@@ -47,7 +47,7 @@ public function testCachePerPage() {
// Make sure that we're currently still on /test-page after submitting the
// form.
$this->drupalPostForm(NULL, $form_values, t('Submit'));
$this->drupalPostForm(NULL, $form_values, 'Submit');
$this->assertSession()->addressEquals('test-page');
$this->assertText('Your email address is test@example.com');
......@@ -59,7 +59,7 @@ public function testCachePerPage() {
// Make sure that submitting the form didn't redirect us to the first page
// we submitted the form from after submitting the form from
// /test-render-title.
$this->drupalPostForm(NULL, $form_values, t('Submit'));
$this->drupalPostForm(NULL, $form_values, 'Submit');
$this->assertSession()->addressEquals('test-render-title');
$this->assertText('Your email address is test@example.com');
}
......
......@@ -67,7 +67,7 @@ public function testBlockLinks() {
// Create a menu in the default language.
$edit['label'] = $this->randomMachineName();
$edit['id'] = mb_strtolower($edit['label']);
$this->drupalPostForm('admin/structure/menu/add', $edit, t('Save'));
$this->drupalPostForm('admin/structure/menu/add', $edit, 'Save');
$this->assertText('Menu ' . $edit['label'] . ' has been added.');
// Check that the block is listed for all languages.
......
......@@ -43,7 +43,7 @@ protected function setUp(): void {
$edit = [
'predefined_langcode' => 'fr',
];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
$this->drupalPostForm('admin/config/regional/language/add', $edit, 'Add language');
$this->assertText('French', 'Language added successfully.');
}
......@@ -65,13 +65,13 @@ public function testLanguageBlockVisibility() {
'id' => strtolower($this->randomMachineName(8)),
'region' => 'sidebar_first',
];
$this->drupalPostForm('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme, $edit, t('Save block'));
$this->drupalPostForm('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme, $edit, 'Save block');
// Change the default language.
$edit = [
'site_default_language' => 'fr',
];
$this->drupalPostForm('admin/config/regional/language', $edit, t('Save configuration'));
$this->drupalPostForm('admin/config/regional/language', $edit, 'Save configuration');
// Check that a page has a block.
$this->drupalGet('en');
......@@ -104,7 +104,7 @@ public function testLanguageBlockVisibilityLanguageDelete() {
$this->assertEqual('fr', $visibility['language']['langcodes']['fr'], 'Language is set in the block configuration.');
// Delete the language.
$this->drupalPostForm('admin/config/regional/language/delete/fr', [], t('Delete'));
$this->drupalPostForm('admin/config/regional/language/delete/fr', [], 'Delete');
// Check that the language is no longer stored in the configuration after
// it is deleted.
......@@ -134,7 +134,7 @@ public function testMultipleLanguageTypes() {
'language_content[enabled][language-url]' => TRUE,
'language_content[enabled][language-interface]' => FALSE,
];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
$this->drupalPostForm('admin/config/regional/language/detection', $edit, 'Save settings');
// Check if the visibility setting is available with a type setting.
$default_theme = $this->config('system.theme')->get('default');
......@@ -150,7 +150,7 @@ public function testMultipleLanguageTypes() {
'id' => $block_id,
'region' => 'sidebar_first',
];
$this->drupalPostForm('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme, $edit, t('Save block'));
$this->drupalPostForm('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme, $edit, 'Save block');
// Interface negotiation depends on request arguments.
$this->drupalGet('node', ['query' => ['language' => 'en']]);
......@@ -174,7 +174,7 @@ public function testMultipleLanguageTypes() {
$edit = [
'visibility[language][context_mapping][language]' => '@language.current_language_context:language_content',
];
$this->drupalPostForm('admin/structure/block/manage/' . $block_id, $edit, t('Save block'));
$this->drupalPostForm('admin/structure/block/manage/' . $block_id, $edit, 'Save block');
// Content language negotiation does not depend on request arguments.
// It will fall back on English (site default) and not display the block.
......
......@@ -44,7 +44,7 @@ public function testBlockVisibility() {
$this->drupalGet('admin/structure/block/add/' . $block_name . '/' . $default_theme);
$this->assertSession()->checkboxChecked('edit-visibility-request-path-negate-0');
$this->drupalPostForm(NULL, $edit, t('Save block'));
$this->drupalPostForm(NULL, $edit, 'Save block');
$this->assertText('The block configuration has been saved.', 'Block was saved');
$this->clickLink('Configure');
......@@ -83,7 +83,7 @@ public function testBlockToggleVisibility() {
$block_id = $edit['id'];
// Set the block to be shown only to authenticated users.
$edit['visibility[user_role][roles][' . RoleInterface::AUTHENTICATED_ID . ']'] = TRUE;
$this->drupalPostForm('admin/structure/block/add/' . $block_name . '/' . $default_theme, $edit, t('Save block'));
$this->drupalPostForm('admin/structure/block/add/' . $block_name . '/' . $default_theme, $edit, 'Save block');
$this->clickLink('Configure');
$this->assertSession()->checkboxChecked('edit-visibility-user-role-roles-authenticated');
......@@ -119,7 +119,7 @@ public function testBlockVisibilityListedEmpty() {
];
// Set the block to be hidden on any user path, and to be shown only to
// authenticated users.
$this->drupalPostForm('admin/structure/block/add/' . $block_name . '/' . $default_theme, $edit, t('Save block'));
$this->drupalPostForm('admin/structure/block/add/' . $block_name . '/' . $default_theme, $edit, 'Save block');
$this->assertText('The block configuration has been saved.', 'Block was saved');
$this->drupalGet('user');
......@@ -170,7 +170,7 @@ public function testAddBlockFromLibraryWithWeight() {
'settings[label]' => $title,
];
// Create the block using the link parsed from the library page.
$this->drupalPostForm($this->getAbsoluteUrl($links[0]->getAttribute('href')), $edit, t('Save block'));
$this->drupalPostForm($this->getAbsoluteUrl($links[0]->getAttribute('href')), $edit, 'Save block');
// Ensure that the block was created with the expected weight.
/** @var \Drupal\block\BlockInterface $block */
......@@ -199,7 +199,7 @@ public function testBlock() {
$block['region'] = 'header';
// Set block title to confirm that interface works and override any custom titles.
$this->drupalPostForm('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], ['settings[label]' => $block['settings[label]'], 'settings[label_display]' => $block['settings[label_display]'], 'id' => $block['id'], 'region' => $block['region']], t('Save block'));
$this->drupalPostForm('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], ['settings[label]' => $block['settings[label]'], 'settings[label_display]' => $block['settings[label_display]'], 'id' => $block['id'], 'region' => $block['region']], 'Save block');
$this->assertText('The block configuration has been saved.', 'Block title set.');
// Check to see if the block was created by checking its configuration.
$instance = Block::load($block['id']);
......@@ -230,7 +230,7 @@ public function testBlock() {
$this->drupalGet('admin/structure/block/manage/' . $block['id']);
$this->clickLink(t('Remove block'));
$this->assertRaw(t('Are you sure you want to remove the block @name?', ['@name' => $block['settings[label]']]));
$this->drupalPostForm(NULL, [], t('Remove'));
$this->drupalPostForm(NULL, [], 'Remove');
$this->assertRaw(t('The block %name has been removed.', ['%name' => $block['settings[label]']]));
// Test deleting a block via "Configure block" link.
......@@ -238,7 +238,7 @@ public function testBlock() {
$this->drupalGet('admin/structure/block/manage/' . $block->id(), ['query' => ['destination' => 'admin']]);
$this->clickLink(t('Remove block'));
$this->assertRaw(t('Are you sure you want to remove the block @name?', ['@name' => $block->label()]));
$this->drupalPostForm(NULL, [], t('Remove'));
$this->drupalPostForm(NULL, [], 'Remove');
$this->assertRaw(t('The block %name has been removed.', ['%name' => $block->label()]));
$this->assertSession()->addressEquals('admin');
$this->assertNoRaw($block->id());
......@@ -259,7 +259,7 @@ public function testBlockThemeSelector() {
$block['id'] = strtolower($this->randomMachineName());
$block['theme'] = $theme;
$block['region'] = 'content';
$this->drupalPostForm('admin/structure/block/add/system_powered_by_block', $block, t('Save block'));
$this->drupalPostForm('admin/structure/block/add/system_powered_by_block', $block, 'Save block');
$this->assertText('The block configuration has been saved.');
$this->assertSession()->addressEquals('admin/structure/block/list/' . $theme . '?block-placement=' . Html::getClass($block['id']));
......@@ -302,7 +302,7 @@ public function testHideBlockTitle() {
'region' => 'sidebar_first',
'settings[label]' => $title,
];
$this->drupalPostForm('admin/structure/block/add/' . $block_name . '/' . $default_theme, $edit, t('Save block'));
$this->drupalPostForm('admin/structure/block/add/' . $block_name . '/' . $default_theme, $edit, 'Save block');