summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2017-09-12 09:40:12 (GMT)
committerNathaniel Catchpole2017-09-12 09:40:12 (GMT)
commit932db614e6c883fc7c2b64754a21bf067bafb9ef (patch)
tree430fbb0b3520ec90b145faf27ff06ed42f53047d
parentd64ec77c951d7867a14a1ff813f95818aa60afcd (diff)
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
-rw-r--r--core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php8
-rw-r--r--core/tests/Drupal/Tests/BrowserTestBase.php7
2 files changed, 14 insertions, 1 deletions
diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
index c9f621a..20bf689 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;
@@ -98,13 +99,18 @@ class BrowserTestBaseTest extends BrowserTestBase {
// Test drupalPostForm().
$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');
$this->assertSame('red', $value);
$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 a5ec84e..2324316 100644
--- a/core/tests/Drupal/Tests/BrowserTestBase.php
+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -914,6 +914,11 @@ abstract class BrowserTestBase extends TestCase {
* POST data.
* @param array $options
* 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 = []) {
if (is_object($submit)) {
@@ -932,6 +937,8 @@ abstract class BrowserTestBase extends TestCase {
}
$this->submitForm($edit, $submit);
+
+ return $this->getSession()->getPage()->getContent();
}
/**