Skip to content
Snippets Groups Projects
Commit fd83d88c authored by catch's avatar catch
Browse files

Issue #3184324 by mondrake, longwave: Convert calls to drupalPostForm() that...

Issue #3184324 by mondrake, longwave: Convert calls to drupalPostForm() that assign return value to a variable
parent e0b3795f
No related branches found
No related tags found
No related merge requests found
......@@ -97,7 +97,9 @@ public function testDefaultTab() {
* Ensures that vertical tab form values are cleaned.
*/
public function testDefaultTabCleaned() {
$values = Json::decode($this->drupalPostForm('form_test/form-state-values-clean', [], 'Submit'));
$this->drupalGet('form_test/form-state-values-clean');
$this->submitForm([], 'Submit');
$values = Json::decode($this->getSession()->getPage()->getContent());
$this->assertFalse(isset($values['vertical_tabs__active_tab']), new FormattableMarkup('%element was removed.', ['%element' => 'vertical_tabs__active_tab']));
}
......
......@@ -129,34 +129,32 @@ public function testForm() {
$value = $config_factory->get('form_test.object')->get('bananas');
$this->assertSame('green', $value);
// Test drupalPostForm().
$edit = ['bananas' => 'red'];
// Test submitForm().
$this->drupalGet('form-test/object-builder');
// Submit the form using the button label.
$result = $this->drupalPostForm('form-test/object-builder', $edit, 'Save');
$this->assertSame($this->getSession()->getPage()->getContent(), $result);
$this->submitForm(['bananas' => 'red'], 'Save');
$value = $config_factory->get('form_test.object')->get('bananas');
$this->assertSame('red', $value);
$this->drupalPostForm('form-test/object-builder', [], 'Save');
$this->submitForm([], 'Save');
$value = $config_factory->get('form_test.object')->get('bananas');
$this->assertSame('', $value);
// Submit the form using the button id.
$edit = ['bananas' => 'blue'];
$result = $this->drupalPostForm('form-test/object-builder', $edit, 'edit-submit');
$this->assertSame($this->getSession()->getPage()->getContent(), $result);
$this->submitForm(['bananas' => 'blue'], 'edit-submit');
$value = $config_factory->get('form_test.object')->get('bananas');
$this->assertSame('blue', $value);
// Submit the form using the button name.
$edit = ['bananas' => 'purple'];
$result = $this->drupalPostForm('form-test/object-builder', $edit, 'op');
$this->assertSame($this->getSession()->getPage()->getContent(), $result);
$this->submitForm(['bananas' => 'purple'], 'op');
$value = $config_factory->get('form_test.object')->get('bananas');
$this->assertSame('purple', $value);
// Test drupalPostForm() with no-html response.
$values = Json::decode($this->drupalPostForm('form_test/form-state-values-clean', [], 'Submit'));
// Test submitForm() with no-html response.
$this->drupalGet('form_test/form-state-values-clean');
$this->submitForm([], 'Submit');
$values = Json::decode($this->getSession()->getPage()->getContent());
$this->assertSame(1000, $values['beer']);
// Test submitForm() with form by HTML id.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment