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() { ...@@ -37,7 +37,7 @@ public function testActionConfiguration() {
// Make a POST request to admin/config/system/actions. // Make a POST request to admin/config/system/actions.
$edit = []; $edit = [];
$edit['action'] = 'action_goto_action'; $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); $this->assertSession()->statusCodeEquals(200);
// Make a POST request to the individual action configuration page. // Make a POST request to the individual action configuration page.
...@@ -46,7 +46,7 @@ public function testActionConfiguration() { ...@@ -46,7 +46,7 @@ public function testActionConfiguration() {
$edit['label'] = $action_label; $edit['label'] = $action_label;
$edit['id'] = strtolower($action_label); $edit['id'] = strtolower($action_label);
$edit['url'] = 'admin'; $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); $this->assertSession()->statusCodeEquals(200);
$action_id = $edit['id']; $action_id = $edit['id'];
...@@ -62,7 +62,7 @@ public function testActionConfiguration() { ...@@ -62,7 +62,7 @@ public function testActionConfiguration() {
$new_action_label = $this->randomMachineName(); $new_action_label = $this->randomMachineName();
$edit['label'] = $new_action_label; $edit['label'] = $new_action_label;
$edit['url'] = 'admin'; $edit['url'] = 'admin';
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, 'Save');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
// Make sure that the action updated properly. // Make sure that the action updated properly.
...@@ -79,7 +79,7 @@ public function testActionConfiguration() { ...@@ -79,7 +79,7 @@ public function testActionConfiguration() {
$this->clickLink(t('Delete')); $this->clickLink(t('Delete'));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
$edit = []; $edit = [];
$this->drupalPostForm(NULL, $edit, t('Delete')); $this->drupalPostForm(NULL, $edit, 'Delete');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
// Make sure that the action was actually deleted. // Make sure that the action was actually deleted.
......
...@@ -45,7 +45,7 @@ public function testAddFeed() { ...@@ -45,7 +45,7 @@ public function testAddFeed() {
'url[0][value]' => $feed->getUrl(), 'url[0][value]' => $feed->getUrl(),
'refresh' => '900', '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 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()])); $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() { ...@@ -36,7 +36,7 @@ public function testSettingsPage() {
'aggregator_parser' => 'aggregator_test_parser', 'aggregator_parser' => 'aggregator_test_parser',
'aggregator_processors[aggregator_test_processor]' => 'aggregator_test_processor', '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.'); $this->assertText('The configuration options have been saved.');
// Check that settings have the correct default value. // Check that settings have the correct default value.
...@@ -50,7 +50,7 @@ public function testSettingsPage() { ...@@ -50,7 +50,7 @@ public function testSettingsPage() {
$edit = [ $edit = [
'dummy_length' => 100, '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->assertText('The configuration options have been saved.');
$this->assertSession()->fieldValueEquals('dummy_length', 100); $this->assertSession()->fieldValueEquals('dummy_length', 100);
......
...@@ -74,7 +74,7 @@ protected function setUp() { ...@@ -74,7 +74,7 @@ protected function setUp() {
*/ */
public function createFeed($feed_url = NULL, array $edit = []) { public function createFeed($feed_url = NULL, array $edit = []) {
$edit = $this->getFeedEditArray($feed_url, $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]']])); $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. // Verify that the creation message contains a link to a feed.
...@@ -92,7 +92,7 @@ public function createFeed($feed_url = NULL, array $edit = []) { ...@@ -92,7 +92,7 @@ public function createFeed($feed_url = NULL, array $edit = []) {
* Feed object representing the feed. * Feed object representing the feed.
*/ */
public function deleteFeed(FeedInterface $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()])); $this->assertRaw(t('The feed %title has been deleted.', ['%title' => $feed->label()]));
} }
...@@ -212,7 +212,7 @@ public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) { ...@@ -212,7 +212,7 @@ public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {
* Feed object representing the feed. * Feed object representing the feed.
*/ */
public function deleteFeedItems(FeedInterface $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()])); $this->assertRaw(t('The news items from %title have been deleted.', ['%title' => $feed->label()]));
} }
...@@ -376,7 +376,7 @@ public function createSampleNodes($count = 5) { ...@@ -376,7 +376,7 @@ public function createSampleNodes($count = 5) {
$edit = []; $edit = [];
$edit['title[0][value]'] = $this->randomMachineName(); $edit['title[0][value]'] = $this->randomMachineName();
$edit['body[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() { ...@@ -68,7 +68,7 @@ public function testFeedLanguage() {
$edit['entity_types[aggregator_feed]'] = TRUE; $edit['entity_types[aggregator_feed]'] = TRUE;
$edit['settings[aggregator_feed][aggregator_feed][settings][language][language_alterable]'] = 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 */ /** @var \Drupal\aggregator\FeedInterface[] $feeds */
$feeds = []; $feeds = [];
......
...@@ -61,7 +61,7 @@ public function validateImportFormFields() { ...@@ -61,7 +61,7 @@ public function validateImportFormFields() {
$before = $count_query->execute(); $before = $count_query->execute();
$edit = []; $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.')); $this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'));
$path = $this->getEmptyOpml(); $path = $this->getEmptyOpml();
...@@ -69,11 +69,11 @@ public function validateImportFormFields() { ...@@ -69,11 +69,11 @@ public function validateImportFormFields() {
'files[upload]' => $path, 'files[upload]' => $path,
'remote' => file_create_url($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.')); $this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'));
$edit = ['remote' => 'invalidUrl://empty']; $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.'); $this->assertText('The URL invalidUrl://empty is not valid.', 'Error if the URL is invalid.');
$after = $count_query->execute(); $after = $count_query->execute();
...@@ -88,11 +88,11 @@ protected function submitImportForm() { ...@@ -88,11 +88,11 @@ protected function submitImportForm() {
$before = $count_query->execute(); $before = $count_query->execute();
$form['files[upload]'] = $this->getInvalidOpml(); $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.'); $this->assertText('No new feed has been added.', 'Attempting to upload invalid XML.');
$edit = ['remote' => file_create_url($this->getEmptyOpml())]; $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.'); $this->assertText('No new feed has been added.', 'Attempting to load empty OPML from remote URL.');
$after = $count_query->execute(); $after = $count_query->execute();
...@@ -109,7 +109,7 @@ protected function submitImportForm() { ...@@ -109,7 +109,7 @@ protected function submitImportForm() {
'files[upload]' => $this->getValidOpml($feeds), 'files[upload]' => $this->getValidOpml($feeds),
'refresh' => '900', '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. // Verify that a duplicate URL was identified.
$this->assertRaw(t('A feed with the URL %url already exists.', ['%url' => $feeds[0]['url[0][value]']])); $this->assertRaw(t('A feed with the URL %url already exists.', ['%url' => $feeds[0]['url[0][value]']]));
// Verify that a duplicate title was identified. // Verify that a duplicate title was identified.
......
...@@ -43,7 +43,7 @@ public function testUpdateFeedItem() { ...@@ -43,7 +43,7 @@ public function testUpdateFeedItem() {
$this->drupalGet($edit['url[0][value]']); $this->drupalGet($edit['url[0][value]']);
$this->assertSession()->statusCodeEquals(200); $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]']])); $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. // Verify that the creation message contains a link to a feed.
......
...@@ -31,7 +31,7 @@ public function testUpdateFeed() { ...@@ -31,7 +31,7 @@ public function testUpdateFeed() {
if (isset($feed->{$same_field}->value)) { if (isset($feed->{$same_field}->value)) {
$edit[$same_field] = $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]']])); $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. // Verify that the creation message contains a link to a feed.
......
...@@ -38,7 +38,7 @@ public function testIPAddressValidation() { ...@@ -38,7 +38,7 @@ public function testIPAddressValidation() {
// Ban a valid IP address. // Ban a valid IP address.
$edit = []; $edit = [];
$edit['ip'] = '1.2.3.3'; $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(); $ip = $connection->select('ban_ip', 'bi')->fields('bi', ['iid'])->condition('ip', $edit['ip'])->execute()->fetchField();
$this->assertNotEmpty($ip, 'IP address found in database.'); $this->assertNotEmpty($ip, 'IP address found in database.');
$this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $edit['ip']])); $this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $edit['ip']]));
...@@ -46,30 +46,30 @@ public function testIPAddressValidation() { ...@@ -46,30 +46,30 @@ public function testIPAddressValidation() {
// Try to block an IP address that's already blocked. // Try to block an IP address that's already blocked.
$edit = []; $edit = [];
$edit['ip'] = '1.2.3.3'; $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.'); $this->assertText('This IP address is already banned.');
// Try to block a reserved IP address. // Try to block a reserved IP address.
$edit = []; $edit = [];
$edit['ip'] = '255.255.255.255'; $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.'); $this->assertText('Enter a valid IP address.');
// Try to block a reserved IP address. // Try to block a reserved IP address.
$edit = []; $edit = [];
$edit['ip'] = 'test.example.com'; $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.'); $this->assertText('Enter a valid IP address.');
// Submit an empty form. // Submit an empty form.
$edit = []; $edit = [];
$edit['ip'] = ''; $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.'); $this->assertText('Enter a valid IP address.');
// Pass an IP address as a URL parameter and submit it. // Pass an IP address as a URL parameter and submit it.
$submit_ip = '1.2.3.4'; $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(); $ip = $connection->select('ban_ip', 'bi')->fields('bi', ['iid'])->condition('ip', $submit_ip)->execute()->fetchField();
$this->assertNotEmpty($ip, 'IP address found in database'); $this->assertNotEmpty($ip, 'IP address found in database');
$this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $submit_ip])); $this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $submit_ip]));
...@@ -79,7 +79,7 @@ public function testIPAddressValidation() { ...@@ -79,7 +79,7 @@ public function testIPAddressValidation() {
// TODO: On some systems this test fails due to a bug/inconsistency in cURL. // TODO: On some systems this test fails due to a bug/inconsistency in cURL.
// $edit = array(); // $edit = array();
// $edit['ip'] = \Drupal::request()->getClientIP(); // $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.'); // $this->assertText('You may not ban your own IP address.');
// Test duplicate ip address are not present in the 'blocked_ips' table. // Test duplicate ip address are not present in the 'blocked_ips' table.
......
...@@ -42,7 +42,7 @@ public function testAdminTheme() { ...@@ -42,7 +42,7 @@ public function testAdminTheme() {
// Install admin theme and confirm that tab is accessible. // Install admin theme and confirm that tab is accessible.
\Drupal::service('theme_installer')->install(['bartik']); \Drupal::service('theme_installer')->install(['bartik']);
$edit['admin_theme'] = '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->drupalGet('admin/structure/block/list/bartik');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
} }
...@@ -63,7 +63,7 @@ public function testSevenAdminTheme() { ...@@ -63,7 +63,7 @@ public function testSevenAdminTheme() {
// Install admin theme and confirm that tab is accessible. // Install admin theme and confirm that tab is accessible.
\Drupal::service('theme_installer')->install(['seven']); \Drupal::service('theme_installer')->install(['seven']);
$edit['admin_theme'] = 'seven'; $edit['admin_theme'] = 'seven';
$this->drupalPostForm('admin/appearance', $edit, t('Save configuration')); $this->drupalPostForm('admin/appearance', $edit, 'Save configuration');
// Define our block settings. // Define our block settings.
$settings = [ $settings = [
......
...@@ -47,7 +47,7 @@ public function testCachePerPage() { ...@@ -47,7 +47,7 @@ public function testCachePerPage() {
// Make sure that we're currently still on /test-page after submitting the // Make sure that we're currently still on /test-page after submitting the
// form. // form.
$this->drupalPostForm(NULL, $form_values, t('Submit')); $this->drupalPostForm(NULL, $form_values, 'Submit');
$this->assertSession()->addressEquals('test-page'); $this->assertSession()->addressEquals('test-page');
$this->assertText('Your email address is test@example.com'); $this->assertText('Your email address is test@example.com');
...@@ -59,7 +59,7 @@ public function testCachePerPage() { ...@@ -59,7 +59,7 @@ public function testCachePerPage() {
// Make sure that submitting the form didn't redirect us to the first page // Make sure that submitting the form didn't redirect us to the first page
// we submitted the form from after submitting the form from // we submitted the form from after submitting the form from
// /test-render-title. // /test-render-title.
$this->drupalPostForm(NULL, $form_values, t('Submit')); $this->drupalPostForm(NULL, $form_values, 'Submit');
$this->assertSession()->addressEquals('test-render-title'); $this->assertSession()->addressEquals('test-render-title');