diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php index d9df046..7c3b3a9 100644 --- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php @@ -3,6 +3,7 @@ namespace Drupal\FunctionalTests; use Behat\Mink\Exception\ExpectationException; +use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\Html; use Drupal\Core\Url; use Drupal\Tests\BrowserTestBase; @@ -106,6 +107,10 @@ public function testForm() { $this->drupalPostForm('form-test/object-builder', NULL, 'Save'); $value = $config_factory->get('form_test.object')->get('bananas'); $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']); } /** diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php index 91a10cd..9a754ad 100644 --- a/core/tests/Drupal/Tests/BrowserTestBase.php +++ b/core/tests/Drupal/Tests/BrowserTestBase.php @@ -922,7 +922,7 @@ protected function submitForm(array $edit, $submit, $form_html_id = NULL) { * Options to be forwarded to the url generator. * * @return string - * The HTML of the rendered page. + * The response content after submit form. */ protected function drupalPostForm($path, $edit, $submit, array $options = []) { if (is_object($submit)) { @@ -942,6 +942,9 @@ protected function drupalPostForm($path, $edit, $submit, array $options = []) { $this->submitForm($edit, $submit); + // Returns response content for BC purposes. Feel free to use the webAssert + // object for your assertions. + // @see \Drupal\simpletest\WebTestBase::drupalPostForm() return $this->getSession()->getPage()->getContent(); }