Commit 932db614 authored by catch's avatar catch

Issue #2900292 by vaplas, Manuel Garcia, Meenakshi Gupta, shashikant_chauhan,...

Issue #2900292 by vaplas, Manuel Garcia, Meenakshi Gupta, shashikant_chauhan, Lendude, dawehner: For BC purposes \Drupal\Tests\BrowserTestBase::drupalPostForm should return the HTML of the rendered page
parent d64ec77c
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\FunctionalTests; namespace Drupal\FunctionalTests;
use Behat\Mink\Exception\ExpectationException; use Behat\Mink\Exception\ExpectationException;
use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Html;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase; use Drupal\Tests\BrowserTestBase;
...@@ -98,13 +99,18 @@ public function testForm() { ...@@ -98,13 +99,18 @@ public function testForm() {
// Test drupalPostForm(). // Test drupalPostForm().
$edit = ['bananas' => 'red']; $edit = ['bananas' => 'red'];
$this->drupalPostForm('form-test/object-builder', $edit, 'Save'); $result = $this->drupalPostForm('form-test/object-builder', $edit, 'Save');
$this->assertSame($this->getSession()->getPage()->getContent(), $result);
$value = $config_factory->get('form_test.object')->get('bananas'); $value = $config_factory->get('form_test.object')->get('bananas');
$this->assertSame('red', $value); $this->assertSame('red', $value);
$this->drupalPostForm('form-test/object-builder', NULL, 'Save'); $this->drupalPostForm('form-test/object-builder', NULL, 'Save');
$value = $config_factory->get('form_test.object')->get('bananas'); $value = $config_factory->get('form_test.object')->get('bananas');
$this->assertSame('', $value); $this->assertSame('', $value);
// Test drupalPostForm() with no-html response.
$values = Json::decode($this->drupalPostForm('form_test/form-state-values-clean', [], t('Submit')));
$this->assertTrue(1000, $values['beer']);
} }
/** /**
......
...@@ -914,6 +914,11 @@ protected function submitForm(array $edit, $submit, $form_html_id = NULL) { ...@@ -914,6 +914,11 @@ protected function submitForm(array $edit, $submit, $form_html_id = NULL) {
* POST data. * POST data.
* @param array $options * @param array $options
* Options to be forwarded to the url generator. * Options to be forwarded to the url generator.
*
* @return string
* (deprecated) The response content after submit form. It is necessary for
* backwards compatibility and will be removed before Drupal 9.0. You should
* just use the webAssert object for your assertions.
*/ */
protected function drupalPostForm($path, $edit, $submit, array $options = []) { protected function drupalPostForm($path, $edit, $submit, array $options = []) {
if (is_object($submit)) { if (is_object($submit)) {
...@@ -932,6 +937,8 @@ protected function drupalPostForm($path, $edit, $submit, array $options = []) { ...@@ -932,6 +937,8 @@ protected function drupalPostForm($path, $edit, $submit, array $options = []) {
} }
$this->submitForm($edit, $submit); $this->submitForm($edit, $submit);
return $this->getSession()->getPage()->getContent();
} }
/** /**
......
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