Commit e6e52aa2 authored by catch's avatar catch
Browse files

Issue #3186661 by Spokje, longwave, mondrake, paulocs, daffie, catch: Remove...

Issue #3186661 by Spokje, longwave, mondrake, paulocs, daffie, catch: Remove usage of drupalPostForm
parent f3c3ef7c
......@@ -15,7 +15,7 @@ trait RefreshVariablesTrait {
* Useful after a page request is made that changes configuration or state in
* a different thread.
*
* In other words calling a settings page with $this->drupalPostForm() with a
* In other words calling a settings page with $this->submitForm() with a
* changed value would update configuration to reflect that change, but in the
* thread that made the call (thread running the test) the changed values
* would not be picked up.
......
......@@ -37,7 +37,8 @@ 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, 'Create');
$this->drupalGet('admin/config/system/actions');
$this->submitForm($edit, 'Create');
$this->assertSession()->statusCodeEquals(200);
// Make a POST request to the individual action configuration page.
......@@ -46,7 +47,8 @@ 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, 'Save');
$this->drupalGet('admin/config/system/actions/add/action_goto_action');
$this->submitForm($edit, 'Save');
$this->assertSession()->statusCodeEquals(200);
$action_id = $edit['id'];
......
......@@ -46,7 +46,8 @@ public function testAddFeed() {
'url[0][value]' => $feed->getUrl(),
'refresh' => '900',
];
$this->drupalPostForm('aggregator/sources/add', $edit, 'Save');
$this->drupalGet('aggregator/sources/add');
$this->submitForm($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,8 @@ public function testSettingsPage() {
'aggregator_parser' => 'aggregator_test_parser',
'aggregator_processors[aggregator_test_processor]' => 'aggregator_test_processor',
];
$this->drupalPostForm('admin/config/services/aggregator/settings', $edit, 'Save configuration');
$this->drupalGet('admin/config/services/aggregator/settings');
$this->submitForm($edit, 'Save configuration');
$this->assertSession()->pageTextContains('The configuration options have been saved.');
// Check that settings have the correct default value.
......@@ -50,7 +51,8 @@ public function testSettingsPage() {
$edit = [
'dummy_length' => 100,
];
$this->drupalPostForm('admin/config/services/aggregator/settings', $edit, 'Save configuration');
$this->drupalGet('admin/config/services/aggregator/settings');
$this->submitForm($edit, 'Save configuration');
$this->assertSession()->pageTextContains('The configuration options have been saved.');
$this->assertSession()->fieldValueEquals('dummy_length', 100);
......
......@@ -74,7 +74,8 @@ protected function setUp() {
*/
public function createFeed($feed_url = NULL, array $edit = []) {
$edit = $this->getFeedEditArray($feed_url, $edit);
$this->drupalPostForm('aggregator/sources/add', $edit, 'Save');
$this->drupalGet('aggregator/sources/add');
$this->submitForm($edit, 'Save');
$this->assertSession()->pageTextContains('The feed ' . $edit['title[0][value]'] . ' has been added.');
// Verify that the creation message contains a link to a feed.
......@@ -96,7 +97,8 @@ 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', [], 'Delete');
$this->drupalGet('aggregator/sources/' . $feed->id() . '/delete');
$this->submitForm([], 'Delete');
$this->assertRaw(t('The feed %title has been deleted.', ['%title' => $feed->label()]));
}
......@@ -219,7 +221,8 @@ 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(), [], 'Delete items');
$this->drupalGet('admin/config/services/aggregator/delete/' . $feed->id());
$this->submitForm([], 'Delete items');
$this->assertRaw(t('The news items from %title have been deleted.', ['%title' => $feed->label()]));
}
......@@ -391,7 +394,8 @@ public function createSampleNodes($count = 5) {
$edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$edit['body[0][value]'] = $this->randomMachineName();
$this->drupalPostForm('node/add/article', $edit, 'Save');
$this->drupalGet('node/add/article');
$this->submitForm($edit, 'Save');
}
}
......
......@@ -68,7 +68,8 @@ 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, 'Save configuration');
$this->drupalGet('admin/config/regional/content-language');
$this->submitForm($edit, 'Save configuration');
/** @var \Drupal\aggregator\FeedInterface[] $feeds */
$feeds = [];
......
......@@ -61,7 +61,8 @@ public function validateImportFormFields() {
$before = $count_query->execute();
$edit = [];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, 'Import');
$this->drupalGet('admin/config/services/aggregator/add/opml');
$this->submitForm($edit, 'Import');
$this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'));
$path = $this->getEmptyOpml();
......@@ -69,12 +70,14 @@ public function validateImportFormFields() {
'files[upload]' => $path,
'remote' => file_create_url($path),
];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, 'Import');
$this->drupalGet('admin/config/services/aggregator/add/opml');
$this->submitForm($edit, 'Import');
$this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'));
// Error if the URL is invalid.
$edit = ['remote' => 'invalidUrl://empty'];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, 'Import');
$this->drupalGet('admin/config/services/aggregator/add/opml');
$this->submitForm($edit, 'Import');
$this->assertSession()->pageTextContains('The URL invalidUrl://empty is not valid.');
$after = $count_query->execute();
......@@ -90,12 +93,14 @@ protected function submitImportForm() {
// Attempting to upload invalid XML.
$form['files[upload]'] = $this->getInvalidOpml();
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $form, 'Import');
$this->drupalGet('admin/config/services/aggregator/add/opml');
$this->submitForm($form, 'Import');
$this->assertSession()->pageTextContains('No new feed has been added.');
// Attempting to load empty OPML from remote URL
$edit = ['remote' => file_create_url($this->getEmptyOpml())];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, 'Import');
$this->drupalGet('admin/config/services/aggregator/add/opml');
$this->submitForm($edit, 'Import');
$this->assertSession()->pageTextContains('No new feed has been added.');
$after = $count_query->execute();
......@@ -112,7 +117,8 @@ protected function submitImportForm() {
'files[upload]' => $this->getValidOpml($feeds),
'refresh' => '900',
];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, 'Import');
$this->drupalGet('admin/config/services/aggregator/add/opml');
$this->submitForm($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,8 @@ public function testUpdateFeedItem() {
$this->drupalGet($edit['url[0][value]']);
$this->assertSession()->statusCodeEquals(200);
$this->drupalPostForm('aggregator/sources/add', $edit, 'Save');
$this->drupalGet('aggregator/sources/add');
$this->submitForm($edit, 'Save');
$this->assertSession()->pageTextContains('The feed ' . $edit['title[0][value]'] . ' has been added.');
// Verify that the creation message contains a link to a feed.
......
......@@ -29,7 +29,8 @@ public function testUpdateFeed() {
if (isset($feed->{$same_field}->value)) {
$edit[$same_field] = $feed->{$same_field}->value;
}
$this->drupalPostForm('aggregator/sources/' . $feed->id() . '/configure', $edit, 'Save');
$this->drupalGet('aggregator/sources/' . $feed->id() . '/configure');
$this->submitForm($edit, 'Save');
$this->assertSession()->pageTextContains('The feed ' . $edit['title[0][value]'] . ' has been updated.');
// Verify that the creation message contains a link to a feed.
......
......@@ -38,7 +38,8 @@ public function testIPAddressValidation() {
// Ban a valid IP address.
$edit = [];
$edit['ip'] = '1.2.3.3';
$this->drupalPostForm('admin/config/people/ban', $edit, 'Add');
$this->drupalGet('admin/config/people/ban');
$this->submitForm($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 +47,35 @@ 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, 'Add');
$this->drupalGet('admin/config/people/ban');
$this->submitForm($edit, 'Add');
$this->assertSession()->pageTextContains('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, 'Add');
$this->drupalGet('admin/config/people/ban');
$this->submitForm($edit, 'Add');
$this->assertSession()->pageTextContains('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, 'Add');
$this->drupalGet('admin/config/people/ban');
$this->submitForm($edit, 'Add');
$this->assertSession()->pageTextContains('Enter a valid IP address.');
// Submit an empty form.
$edit = [];
$edit['ip'] = '';
$this->drupalPostForm('admin/config/people/ban', $edit, 'Add');
$this->drupalGet('admin/config/people/ban');
$this->submitForm($edit, 'Add');
$this->assertSession()->pageTextContains('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, [], 'Add');
$this->drupalGet('admin/config/people/ban/' . $submit_ip);
$this->submitForm([], '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 +85,8 @@ 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, 'Save');
// $this->drupalGet('admin/config/people/ban');
// $this->submitForm($edit, 'Save');
// $this->assertSession()->pageTextContains('You may not ban your own IP address.');
// Test duplicate ip address are not present in the 'blocked_ips' table.
......
......@@ -42,7 +42,8 @@ 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, 'Save configuration');
$this->drupalGet('admin/appearance');
$this->submitForm($edit, 'Save configuration');
$this->drupalGet('admin/structure/block/list/bartik');
$this->assertSession()->statusCodeEquals(200);
}
......@@ -63,7 +64,8 @@ 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, 'Save configuration');
$this->drupalGet('admin/appearance');
$this->submitForm($edit, 'Save configuration');
// Define our block settings.
$settings = [
......
......@@ -48,11 +48,13 @@ public function testBlockInInvalidRegion() {
$warning_message = t('The block %info was assigned to the invalid region %region and has been disabled.', ['%info' => $block->id(), '%region' => 'invalid_region']);
// Clearing the cache should disable the test block placed in the invalid region.
$this->drupalPostForm('admin/config/development/performance', [], 'Clear all caches');
$this->drupalGet('admin/config/development/performance');
$this->submitForm([], 'Clear all caches');
$this->assertRaw($warning_message);
// Clear the cache to check if the warning message is not triggered.
$this->drupalPostForm('admin/config/development/performance', [], 'Clear all caches');
$this->drupalGet('admin/config/development/performance');
$this->submitForm([], 'Clear all caches');
$this->assertNoRaw($warning_message);
// Place disabled test block in the invalid region of the default theme.
......@@ -60,7 +62,8 @@ public function testBlockInInvalidRegion() {
$block = Block::load($block->id());
// Clear the cache to check if the warning message is not triggered.
$this->drupalPostForm('admin/config/development/performance', [], 'Clear all caches');
$this->drupalGet('admin/config/development/performance');
$this->submitForm([], 'Clear all caches');
$this->assertNoRaw($warning_message);
}
......
......@@ -67,7 +67,8 @@ 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, 'Save');
$this->drupalGet('admin/structure/menu/add');
$this->submitForm($edit, 'Save');
$this->assertSession()->pageTextContains('Menu ' . $edit['label'] . ' has been added.');
// Check that the block is listed for all languages.
......
......@@ -43,7 +43,8 @@ protected function setUp(): void {
$edit = [
'predefined_langcode' => 'fr',
];
$this->drupalPostForm('admin/config/regional/language/add', $edit, 'Add language');
$this->drupalGet('admin/config/regional/language/add');
$this->submitForm($edit, 'Add language');
// Verify that language was added successfully.
$this->assertSession()->pageTextContains('French');
......@@ -67,13 +68,15 @@ public function testLanguageBlockVisibility() {
'id' => strtolower($this->randomMachineName(8)),
'region' => 'sidebar_first',
];
$this->drupalPostForm('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme, $edit, 'Save block');
$this->drupalGet('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme);
$this->submitForm($edit, 'Save block');
// Change the default language.
$edit = [
'site_default_language' => 'fr',
];
$this->drupalPostForm('admin/config/regional/language', $edit, 'Save configuration');
$this->drupalGet('admin/config/regional/language');
$this->submitForm($edit, 'Save configuration');
// Check that a page has a block.
$this->drupalGet('en');
......@@ -106,7 +109,8 @@ public function testLanguageBlockVisibilityLanguageDelete() {
$this->assertEquals('fr', $visibility['language']['langcodes']['fr'], 'Language is set in the block configuration.');
// Delete the language.
$this->drupalPostForm('admin/config/regional/language/delete/fr', [], 'Delete');
$this->drupalGet('admin/config/regional/language/delete/fr');
$this->submitForm([], 'Delete');
// Check that the language is no longer stored in the configuration after
// it is deleted.
......@@ -136,7 +140,8 @@ public function testMultipleLanguageTypes() {
'language_content[enabled][language-url]' => TRUE,
'language_content[enabled][language-interface]' => FALSE,
];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, 'Save settings');
$this->drupalGet('admin/config/regional/language/detection');
$this->submitForm($edit, 'Save settings');
// Check if the visibility setting is available with a type setting.
$default_theme = $this->config('system.theme')->get('default');
......@@ -152,7 +157,8 @@ public function testMultipleLanguageTypes() {
'id' => $block_id,
'region' => 'sidebar_first',
];
$this->drupalPostForm('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme, $edit, 'Save block');
$this->drupalGet('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme);
$this->submitForm($edit, 'Save block');
// Interface negotiation depends on request arguments.
$this->drupalGet('node', ['query' => ['language' => 'en']]);
......@@ -176,7 +182,8 @@ public function testMultipleLanguageTypes() {
$edit = [
'visibility[language][context_mapping][language]' => '@language.current_language_context:language_content',
];
$this->drupalPostForm('admin/structure/block/manage/' . $block_id, $edit, 'Save block');
$this->drupalGet('admin/structure/block/manage/' . $block_id);
$this->submitForm($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.
......
......@@ -85,7 +85,8 @@ 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, 'Save block');
$this->drupalGet('admin/structure/block/add/' . $block_name . '/' . $default_theme);
$this->submitForm($edit, 'Save block');
$this->clickLink('Configure');
$this->assertSession()->checkboxChecked('edit-visibility-user-role-roles-authenticated');
......@@ -121,7 +122,8 @@ 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, 'Save block');
$this->drupalGet('admin/structure/block/add/' . $block_name . '/' . $default_theme);
$this->submitForm($edit, 'Save block');
$this->assertSession()->pageTextContains('The block configuration has been saved.');
// Confirm that block was not displayed according to block visibility
......@@ -176,7 +178,8 @@ 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, 'Save block');
$this->drupalGet($this->getAbsoluteUrl($links[0]->getAttribute('href')));
$this->submitForm($edit, 'Save block');
// Ensure that the block was created with the expected weight.
/** @var \Drupal\block\BlockInterface $block */
......@@ -205,7 +208,13 @@ 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']], 'Save block');
$this->drupalGet('admin/structure/block/add/' . $block['id'] . '/' . $block['theme']);
$this->submitForm([
'settings[label]' => $block['settings[label]'],
'settings[label_display]' => $block['settings[label_display]'],
'id' => $block['id'],
'region' => $block['region'],
], 'Save block');
$this->assertSession()->pageTextContains('The block configuration has been saved.');
// Check to see if the block was created by checking its configuration.
$instance = Block::load($block['id']);
......@@ -265,7 +274,8 @@ 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, 'Save block');
$this->drupalGet('admin/structure/block/add/system_powered_by_block');
$this->submitForm($block, 'Save block');
$this->assertSession()->pageTextContains('The block configuration has been saved.');
$this->assertSession()->addressEquals('admin/structure/block/list/' . $theme . '?block-placement=' . Html::getClass($block['id']));
......@@ -308,7 +318,8 @@ public function testHideBlockTitle() {
'region' => 'sidebar_first',
'settings[label]' => $title,
];
$this->drupalPostForm('admin/structure/block/add/' . $block_name . '/' . $default_theme, $edit, 'Save block');
$this->drupalGet('admin/structure/block/add/' . $block_name . '/' . $default_theme);
$this->submitForm($edit, 'Save block');
$this->assertSession()->pageTextContains('The block configuration has been saved.');
// Confirm that the block is not displayed by default.
......@@ -318,7 +329,8 @@ public function testHideBlockTitle() {
$edit = [
'settings[label_display]' => TRUE,
];
$this->drupalPostForm('admin/structure/block/manage/' . $id, $edit, 'Save block');
$this->drupalGet('admin/structure/block/manage/' . $id);
$this->submitForm($edit, 'Save block');
$this->assertSession()->pageTextContains('The block configuration has been saved.');
$this->drupalGet('admin/structure/block/manage/' . $id);
......@@ -346,7 +358,8 @@ public function moveBlockToRegion(array $block, $region) {
$block += ['theme' => $this->config('system.theme')->get('default')];
$edit = [];
$edit['blocks[' . $block['id'] . '][region]'] = $region;
$this->drupalPostForm('admin/structure/block', $edit, 'Save blocks');
$this->drupalGet('admin/structure/block');
$this->submitForm($edit, 'Save blocks');
// Confirm that the block was moved to the proper region.
$this->assertSession()->pageTextContains('The block settings have been updated.');
......
......@@ -130,7 +130,8 @@ public function testBlockAdminUiPage() {
// Change the test block's weight.
$edit['blocks[' . $values['settings']['id'] . '][weight]'] = $values['test_weight'];
}
$this->drupalPostForm('admin/structure/block', $edit, 'Save blocks');
$this->drupalGet('admin/structure/block');
$this->submitForm($edit, 'Save blocks');
foreach ($this->blockValues as $values) {
// Check if the region and weight settings changes have persisted.
$this->assertTrue($this->assertSession()->optionExists('edit-blocks-' . $values['settings']['id'] . '-region', 'header')->isSelected());
......@@ -236,7 +237,8 @@ public function testContextAwareBlocks() {
'region' => 'content',
'settings[context_mapping][user]' => '@block_test.multiple_static_context:userB',
];
$this->drupalPostForm($block_url, $edit, 'Save block');
$this->drupalGet($block_url);
$this->submitForm($edit, 'Save block');
$this->drupalGet('');
$this->assertSession()->pageTextContains('Test context-aware block');
......@@ -276,13 +278,15 @@ public function testMachineNameSuggestion() {
$this->drupalGet($url);
$this->assertSession()->fieldValueEquals('id', 'displaymessage');
$edit = ['region' => 'content'];
$this->drupalPostForm($url, $edit, 'Save block');
$this->drupalGet($url);
$this->submitForm($edit, 'Save block');
$this->assertSession()->pageTextContains('The block configuration has been saved.');
// Now, check to make sure the form starts by autoincrementing correctly.
$this->drupalGet($url);
$this->assertSession()->fieldValueEquals('id', 'displaymessage_2');
$this->drupalPostForm($url, $edit, 'Save block');
$this->drupalGet($url);
$this->submitForm($edit, 'Save block');
$this->assertSession()->pageTextContains('The block configuration has been saved.');
// And verify that it continues working beyond just the first two.
......@@ -319,7 +323,8 @@ public function testBlockPlacementIndicator() {
$block['region'] = 'content';
// After adding a block, it will indicate which block was just added.
$this->drupalPostForm('admin/structure/block/add/system_powered_by_block', $block, 'Save block');
$this->drupalGet('admin/structure/block/add/system_powered_by_block');
$this->submitForm($block, 'Save block');
$this->assertSession()->addressEquals('admin/structure/block/list/classy?block-placement=' . Html::getClass($block['id']));
// Resaving the block page will remove the block placement indicator.
......@@ -349,7 +354,11 @@ public function testBlockPlacementIndicator() {
* Tests if validation errors are passed plugin form to the parent form.
*/
public function testBlockValidateErrors() {
$this->drupalPostForm('admin/structure/block/add/test_settings_validation/classy', ['region' => 'content', 'settings[digits]' => 'abc'], 'Save block');
$this->drupalGet('admin/structure/block/add/test_settings_validation/classy');
$this->submitForm([
'region' => 'content',
'settings[digits]' => 'abc',
], 'Save block');
$arguments = [':message' => 'Only digits are allowed'];
$pattern = '//div[contains(@class,"messages messages--error")]/div[contains(text()[2],:message)]';
......
......@@ -77,7 +77,8 @@ public function testBlockCategory() {
$edit['description'] = $this->randomString();
$edit['block[create]'] = TRUE;
$edit['block[style][row_plugin]'] = 'fields';
$this->drupalPostForm('admin/structure/views/add', $edit, 'Save and edit');
$this->drupalGet('admin/structure/views/add');
$this->submitForm($edit, 'Save and edit');
$pattern = '//tr[.//td[text()=:category] and .//td//a[contains(@href, :href)]]';
......@@ -96,7 +97,8 @@ public function testBlockCategory() {
$this->assertTrue(!empty($elements), 'The test block appears in the category for its base table.');
// Duplicate the block before changing the category.
$this->drupalPostForm('admin/structure/views/view/' . $edit['id'] . '/edit/block_1', [], 'Duplicate Block');
$this->drupalGet('admin/structure/views/view/' . $edit['id'] . '/edit/block_1');
$this->submitForm([], 'Duplicate Block');
$this->assertSession()->addressEquals('admin/structure/views/view/' . $edit['id'] . '/edit/block_2');
// Change the block category to a random string.
......@@ -217,7 +219,8 @@ public function testViewsBlockForm() {
for ($i = 2; $i <= 3; $i++) {
// Place the same block again and make sure we have a new ID.
$this->drupalPostForm('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme, $edit, 'Save block');
$this->drupalGet('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme);
$this->submitForm($edit, 'Save block');
$block = $storage->load('views_block__test_view_block_block_1_' . $i);
// This will only return a result if our new block has been created with the
// expected machine name.
......@@ -229,14 +232,16 @@ public function testViewsBlockForm() {
$edit = ['region' => 'content'];
$edit['settings[override][items_per_page]'] = 10;
$this->drupalPostForm('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme, $edit, 'Save block');
$this->drupalGet('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme);
$this->submitForm($edit, 'Save block');
$block = $storage->load('views_block__test_view_block_block_1_4');
$config = $block->getPlugin()->getConfiguration();
$this->assertEquals(10, $config['items_per_page'], "'Items per page' is properly saved.");
$edit['settings[override][items_per_page]'] = 5;
$this->drupalPostForm('admin/structure/block/manage/views_block__test_view_block_block_1_4', $edit, 'Save block');
$this->drupalGet('admin/structure/block/manage/views_block__test_view_block_block_1_4');
$this->submitForm($edit, 'Save block');
$block = $storage->load('views_block__test_view_block_block_1_4');
......@@ -247,7 +252,8 @@ public function testViewsBlockForm() {
$edit = ['region' => 'content'];
$edit['settings[views_label_checkbox]'] = 1;
$edit['settings[views_label]'] = 'Custom title';
$this->drupalPostForm('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme, $edit, 'Save block');
$this->drupalGet('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme);
$this->submitForm($edit, 'Save block');
$block = $storage->load('views_block__test_view_block_block_1_5');
$config = $block->getPlugin()->getConfiguration();
......
......@@ -56,7 +56,8 @@ public function testBlockContentCreation() {
$edit = [];
$edit['info[0][value]'] = 'Test Block';
$edit['body[0][value]'] = $this->randomMachineName(16);