Commit cfbe5da7 authored by larowlan's avatar larowlan

Issue #2867154 by Manuel Garcia, vaplas, naveenvalecha, Lendude, phenaproxima,...

Issue #2867154 by Manuel Garcia, vaplas, naveenvalecha, Lendude, phenaproxima, dawehner: Form: Convert system functional tests to phpunit
parent 36099473
......@@ -4,6 +4,7 @@
use Drupal\Core\Form\FormState;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\system\Functional\Form\StubForm;
/**
* Tests the tableselect form element for expected behavior.
......
......@@ -33,10 +33,29 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#type' => 'submit',
'#value' => t('Submit'),
];
$form['#post_render'][] = [static::class, 'postRender'];
return $form;
}
/**
* Alters the rendered form to simulate input forgery.
*
* It's necessary to alter the rendered form here because Mink does not
* support manipulating the DOM tree.
*
* @param string $rendered_form
* The rendered form.
*
* @return string
* The modified rendered form.
*
* @see \Drupal\Tests\system\Functional\Form\FormTest::testInputForgery()
*/
public static function postRender($rendered_form) {
return str_replace('value="two"', 'value="FORGERY"', $rendered_form);
}
/**
* {@inheritdoc}
*/
......
<?php
namespace Drupal\system\Tests\Form;
namespace Drupal\Tests\system\Functional\Form;
use Drupal\Component\Utility\Xss;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests hook_form_alter() and hook_form_FORM_ID_alter().
*
* @group Form
*/
class AlterTest extends WebTestBase {
class AlterTest extends BrowserTestBase {
/**
* Modules to enable.
......@@ -32,7 +32,7 @@ public function testExecutionOrder() {
'form_test_form_form_test_alter_form_alter() executed.',
'system_form_form_test_alter_form_alter() executed.',
];
$content = preg_replace('/\s+/', ' ', Xss::filter($this->content, []));
$content = preg_replace('/\s+/', ' ', Xss::filter($this->getSession()->getPage()->getContent(), []));
$this->assert(strpos($content, implode(' ', $expected)) !== FALSE, 'Form alter hooks executed in the expected order.');
}
......
<?php
namespace Drupal\system\Tests\Form;
namespace Drupal\Tests\system\Functional\Form;
use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Tests\BrowserTestBase;
/**
* Tests altering forms to be rebuilt so there are multiple steps.
*
* @group Form
*/
class ArbitraryRebuildTest extends WebTestBase {
class ArbitraryRebuildTest extends BrowserTestBase {
/**
* Modules to enable.
......
<?php
namespace Drupal\system\Tests\Form;
namespace Drupal\Tests\system\Functional\Form;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests form API checkbox handling of various combinations of #default_value
......@@ -10,7 +10,7 @@
*
* @group Form
*/
class CheckboxTest extends WebTestBase {
class CheckboxTest extends BrowserTestBase {
/**
* Modules to enable.
......@@ -55,12 +55,18 @@ public function testFormCheckbox() {
// Ensure that $form_state->getValues() is populated correctly for a
// checkboxes group that includes a 0-indexed array of options.
$results = json_decode($this->drupalPostForm('form-test/checkboxes-zero/1', [], 'Save'));
$this->drupalPostForm('form-test/checkboxes-zero/1', [], 'Save');
$results = json_decode($this->getSession()->getPage()->getContent());
$this->assertIdentical($results->checkbox_off, [0, 0, 0], 'All three in checkbox_off are zeroes: off.');
$this->assertIdentical($results->checkbox_zero_default, ['0', 0, 0], 'The first choice is on in checkbox_zero_default');
$this->assertIdentical($results->checkbox_string_zero_default, ['0', 0, 0], 'The first choice is on in checkbox_string_zero_default');
$edit = ['checkbox_off[0]' => '0'];
$results = json_decode($this->drupalPostForm('form-test/checkboxes-zero/1', $edit, 'Save'));
// Due to Mink driver differences, we cannot submit an empty checkbox value
// to drupalPostForm(), even if that empty value is the 'true' value for
// the checkbox.
$this->drupalGet('form-test/checkboxes-zero/1');
$this->assertSession()->fieldExists('checkbox_off[0]')->check();
$this->drupalPostForm(NULL, NULL, 'Save');
$results = json_decode($this->getSession()->getPage()->getContent());
$this->assertIdentical($results->checkbox_off, ['0', 0, 0], 'The first choice is on in checkbox_off but the rest is not');
// Ensure that each checkbox is rendered correctly for a checkboxes group
......@@ -70,18 +76,22 @@ public function testFormCheckbox() {
$this->assertIdentical(count($checkboxes), 9, 'Correct number of checkboxes found.');
foreach ($checkboxes as $checkbox) {
$checked = isset($checkbox['checked']);
$name = (string) $checkbox['name'];
$checked = $checkbox->isChecked();
$name = $checkbox->getAttribute('name');
$this->assertIdentical($checked, $name == 'checkbox_zero_default[0]' || $name == 'checkbox_string_zero_default[0]', format_string('Checkbox %name correctly checked', ['%name' => $name]));
}
$edit = ['checkbox_off[0]' => '0'];
$this->drupalPostForm('form-test/checkboxes-zero/0', $edit, 'Save');
// Due to Mink driver differences, we cannot submit an empty checkbox value
// to drupalPostForm(), even if that empty value is the 'true' value for
// the checkbox.
$this->drupalGet('form-test/checkboxes-zero/0');
$this->assertSession()->fieldExists('checkbox_off[0]')->check();
$this->drupalPostForm(NULL, NULL, 'Save');
$checkboxes = $this->xpath('//input[@type="checkbox"]');
$this->assertIdentical(count($checkboxes), 9, 'Correct number of checkboxes found.');
foreach ($checkboxes as $checkbox) {
$checked = isset($checkbox['checked']);
$name = (string) $checkbox['name'];
$checked = $checkbox->isChecked();
$name = (string) $checkbox->getAttribute('name');
$this->assertIdentical($checked, $name == 'checkbox_off[0]' || $name == 'checkbox_zero_default[0]' || $name == 'checkbox_string_zero_default[0]', format_string('Checkbox %name correctly checked', ['%name' => $name]));
}
}
......
<?php
namespace Drupal\system\Tests\Form;
namespace Drupal\Tests\system\Functional\Form;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Url;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests confirmation forms.
*
* @group Form
*/
class ConfirmFormTest extends WebTestBase {
class ConfirmFormTest extends BrowserTestBase {
/**
* Modules to enable.
......
<?php
namespace Drupal\system\Tests\Form;
namespace Drupal\Tests\system\Functional\Form;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests building and processing of core form elements.
*
* @group Form
*/
class ElementTest extends WebTestBase {
class ElementTest extends BrowserTestBase {
/**
* Modules to enable.
......@@ -53,7 +53,7 @@ public function testOptions() {
$expected_values = ['0', 'foo', '1', 'bar', '>'];
foreach ($elements as $element) {
$expected = array_shift($expected_values);
$this->assertIdentical((string) $element['value'], $expected);
$this->assertIdentical((string) $element->getAttribute('value'), $expected);
}
}
......@@ -73,7 +73,7 @@ public function testOptions() {
$expected_values = ['0', 'foo', 'bar', '>', '1'];
foreach ($elements as $element) {
$expected = array_shift($expected_values);
$this->assertIdentical((string) $element['value'], $expected);
$this->assertIdentical((string) $element->getAttribute('value'), $expected);
}
}
// Verify that custom #description properties are output.
......
<?php
namespace Drupal\system\Tests\Form;
namespace Drupal\Tests\system\Functional\Form;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests form element labels, required markers and associated output.
*
* @group Form
*/
class ElementsLabelsTest extends WebTestBase {
class ElementsLabelsTest extends BrowserTestBase {
/**
* Modules to enable.
......@@ -85,9 +85,9 @@ public function testFormLabels() {
// Check title attribute for radios and checkboxes.
$elements = $this->xpath('//div[@id="edit-form-checkboxes-title-attribute"]');
$this->assertEqual($elements[0]['title'], 'Checkboxes test' . ' (' . t('Required') . ')', 'Title attribute found.');
$this->assertEqual($elements[0]->getAttribute('title'), 'Checkboxes test' . ' (' . t('Required') . ')', 'Title attribute found.');
$elements = $this->xpath('//div[@id="edit-form-radios-title-attribute"]');
$this->assertEqual($elements[0]['title'], 'Radios test' . ' (' . t('Required') . ')', 'Title attribute found.');
$this->assertEqual($elements[0]->getAttribute('title'), 'Radios test' . ' (' . t('Required') . ')', 'Title attribute found.');
$elements = $this->xpath('//fieldset[@id="edit-form-checkboxes-title-invisible--wrapper"]/legend/span[contains(@class, "visually-hidden")]');
$this->assertTrue(!empty($elements), "Title/Label not displayed when 'visually-hidden' attribute is set in checkboxes.");
......
<?php
namespace Drupal\system\Tests\Form;
namespace Drupal\Tests\system\Functional\Form;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\simpletest\WebTestBase;
use Drupal\Component\Serialization\Json;
use Drupal\Tests\BrowserTestBase;
/**
* Tests the vertical_tabs form element for expected behavior.
*
* @group Form
*/
class ElementsVerticalTabsTest extends WebTestBase {
class ElementsVerticalTabsTest extends BrowserTestBase {
/**
* Modules to enable.
......@@ -49,8 +49,9 @@ protected function setUp() {
*/
public function testJavaScriptOrdering() {
$this->drupalGet('form_test/vertical-tabs');
$position1 = strpos($this->content, 'core/misc/vertical-tabs.js');
$position2 = strpos($this->content, 'core/misc/collapse.js');
$content = $this->getSession()->getPage()->getContent();
$position1 = strpos($content, 'core/misc/vertical-tabs.js');
$position2 = strpos($content, 'core/misc/collapse.js');
$this->assertTrue($position1 !== FALSE && $position2 !== FALSE && $position1 < $position2, 'vertical-tabs.js is included before collapse.js');
}
......@@ -75,7 +76,12 @@ public function testWrapperNotShownWhenEmpty() {
*/
public function testDefaultTab() {
$this->drupalGet('form_test/vertical-tabs');
$this->assertFieldByName('vertical_tabs__active_tab', 'edit-tab3', t('The default vertical tab is correctly selected.'));
$value = $this->assertSession()
->elementExists('css', 'input[name="vertical_tabs__active_tab"]')
->getValue();
$this->assertSame('edit-tab3', $value, t('The default vertical tab is correctly selected.'));
}
/**
......
<?php
namespace Drupal\system\Tests\Form;
namespace Drupal\Tests\system\Functional\Form;
use Drupal\Component\Serialization\Json;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests the form API email element.
*
* @group Form
*/
class EmailTest extends WebTestBase {
class EmailTest extends BrowserTestBase {
/**
* Modules to enable.
......@@ -19,8 +19,6 @@ class EmailTest extends WebTestBase {
*/
public static $modules = ['form_test'];
protected $profile = 'testing';
/**
* Tests that #type 'email' fields are properly validated.
*/
......@@ -34,14 +32,16 @@ public function testFormEmail() {
$edit = [];
$edit['email_required'] = ' foo.bar@example.com ';
$values = Json::decode($this->drupalPostForm('form-test/email', $edit, 'Submit'));
$this->drupalPostForm('form-test/email', $edit, 'Submit');
$values = Json::decode($this->getSession()->getPage()->getContent());
$this->assertIdentical($values['email'], '');
$this->assertEqual($values['email_required'], 'foo.bar@example.com');
$edit = [];
$edit['email'] = 'foo@example.com';
$edit['email_required'] = 'example@drupal.org';
$values = Json::decode($this->drupalPostForm('form-test/email', $edit, 'Submit'));
$this->drupalPostForm('form-test/email', $edit, 'Submit');
$values = Json::decode($this->getSession()->getPage()->getContent());
$this->assertEqual($values['email'], 'foo@example.com');
$this->assertEqual($values['email_required'], 'example@drupal.org');
}
......
<?php
namespace Drupal\system\Tests\Form;
namespace Drupal\Tests\system\Functional\Form;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests form storage from cached pages.
*
* @group Form
*/
class FormStoragePageCacheTest extends WebTestBase {
class FormStoragePageCacheTest extends BrowserTestBase {
/**
* @var array
......@@ -33,7 +33,7 @@ protected function setUp() {
protected function getFormBuildId() {
$build_id_fields = $this->xpath('//input[@name="form_build_id"]');
$this->assertEqual(count($build_id_fields), 1, 'One form build id field on the page');
return (string) $build_id_fields[0]['value'];
return (string) $build_id_fields[0]->getAttribute('value');
}
/**
......
<?php
namespace Drupal\system\Tests\Form;
namespace Drupal\Tests\system\Functional\Form;
use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\Html;
......@@ -9,7 +9,7 @@
use Drupal\Core\Render\Element;
use Drupal\Core\Url;
use Drupal\form_test\Form\FormTestDisabledElementsForm;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
use Drupal\user\RoleInterface;
use Drupal\filter\Entity\FilterFormat;
......@@ -18,7 +18,7 @@
*
* @group Form
*/
class FormTest extends WebTestBase {
class FormTest extends BrowserTestBase {
/**
* Modules to enable.
......@@ -188,7 +188,7 @@ public function testRequiredCheckboxesRadio() {
// Check the page for error messages.
$errors = $this->xpath('//div[contains(@class, "error")]//li');
foreach ($errors as $error) {
$expected_key = array_search($error[0], $expected);
$expected_key = array_search($error->getText(), $expected);
// If the error message is not one of the expected messages, fail.
if ($expected_key === FALSE) {
$this->fail(format_string("Unexpected error message: @error", ['@error' => $error[0]]));
......@@ -240,14 +240,17 @@ public function testInputWithInvalidToken() {
$this->drupalLogin($account);
// Submit again with required fields set but an invalid form token and
// verify that all the values are retained.
$this->drupalGet(Url::fromRoute('form_test.validate_required'));
$this->assertSession()
->elementExists('css', 'input[name="form_token"]')
->setValue('invalid token');
$edit = [
'textfield' => $this->randomString(),
'checkboxes[bar]' => TRUE,
'select' => 'bar',
'radios' => 'foo',
'form_token' => 'invalid token',
];
$this->drupalPostForm(Url::fromRoute('form_test.validate_required'), $edit, 'Submit');
$this->drupalPostForm(NULL, $edit, 'Submit');
$this->assertFieldByXpath('//div[contains(@class, "error")]', NULL, 'Error message is displayed with invalid token even when required fields are filled.');
$this->assertText('The form has become outdated. Copy any unsaved work in the form below');
// Verify that input elements retained the posted values.
......@@ -258,33 +261,42 @@ public function testInputWithInvalidToken() {
$this->assertFieldChecked('edit-radios-foo');
// Check another form that has a textarea input.
$this->drupalGet(Url::fromRoute('form_test.required'));
$this->assertSession()
->elementExists('css', 'input[name="form_token"]')
->setValue('invalid token');
$edit = [
'textfield' => $this->randomString(),
'textarea' => $this->randomString() . "\n",
'form_token' => 'invalid token',
];
$this->drupalPostForm(Url::fromRoute('form_test.required'), $edit, 'Submit');
$this->drupalPostForm(NULL, $edit, 'Submit');
$this->assertFieldByXpath('//div[contains(@class, "error")]', NULL, 'Error message is displayed with invalid token even when required fields are filled.');
$this->assertText('The form has become outdated. Copy any unsaved work in the form below');
$this->assertFieldByName('textfield', $edit['textfield']);
$this->assertFieldByName('textarea', $edit['textarea']);
// Check another form that has a number input.
$this->drupalGet(Url::fromRoute('form_test.number'));
$this->assertSession()
->elementExists('css', 'input[name="form_token"]')
->setValue('invalid token');
$edit = [
'integer_step' => mt_rand(1, 100),
'form_token' => 'invalid token',
];
$this->drupalPostForm(Url::fromRoute('form_test.number'), $edit, 'Submit');
$this->drupalPostForm(NULL, $edit, 'Submit');
$this->assertFieldByXpath('//div[contains(@class, "error")]', NULL, 'Error message is displayed with invalid token even when required fields are filled.');
$this->assertText('The form has become outdated. Copy any unsaved work in the form below');
$this->assertFieldByName('integer_step', $edit['integer_step']);
// Check a form with a Url field
$this->drupalGet(Url::fromRoute('form_test.url'));
$this->assertSession()
->elementExists('css', 'input[name="form_token"]')
->setValue('invalid token');
$edit = [
'url' => $this->randomString(),
'form_token' => 'invalid token',
];
$this->drupalPostForm(Url::fromRoute('form_test.url'), $edit, 'Submit');
$this->drupalPostForm(NULL, $edit, 'Submit');
$this->assertFieldByXpath('//div[contains(@class, "error")]', NULL, 'Error message is displayed with invalid token even when required fields are filled.');
$this->assertText('The form has become outdated. Copy any unsaved work in the form below');
$this->assertFieldByName('url', $edit['url']);
......@@ -346,17 +358,18 @@ public function testCheckboxProcessing() {
$this->assertRaw(t('@name field is required.', ['@name' => 'required_checkbox']), 'A required checkbox is actually mandatory');
// Now try to submit the form correctly.
$values = Json::decode($this->drupalPostForm(NULL, ['required_checkbox' => 1], t('Submit')));
$this->drupalPostForm(NULL, ['required_checkbox' => 1], t('Submit'));
$values = Json::decode($this->getSession()->getPage()->getContent());
$expected_values = [
'disabled_checkbox_on' => 'disabled_checkbox_on',
'disabled_checkbox_off' => '',
'disabled_checkbox_off' => 0,
'checkbox_on' => 'checkbox_on',
'checkbox_off' => '',
'checkbox_off' => 0,
'zero_checkbox_on' => '0',
'zero_checkbox_off' => '',
'zero_checkbox_off' => 0,
];
foreach ($expected_values as $widget => $expected_value) {
$this->assertEqual($values[$widget], $expected_value, format_string('Checkbox %widget returns expected value (expected: %expected, got: %value)', [
$this->assertSame($values[$widget], $expected_value, format_string('Checkbox %widget returns expected value (expected: %expected, got: %value)', [
'%widget' => var_export($widget, TRUE),
'%expected' => var_export($expected_value, TRUE),
'%value' => var_export($values[$widget], TRUE),
......@@ -518,7 +531,8 @@ public function testNumber() {
* Tests default value handling of #type 'range' elements.
*/
public function testRange() {
$values = json_decode($this->drupalPostForm('form-test/range', [], 'Submit'));
$this->drupalPostForm('form-test/range', [], 'Submit');
$values = json_decode($this->getSession()->getPage()->getContent());
$this->assertEqual($values->with_default_value, 18);
$this->assertEqual($values->float, 10.5);
$this->assertEqual($values->integer, 6);
......@@ -548,7 +562,8 @@ public function testColorValidation() {
$edit = [
'color' => $input,
];
$result = json_decode($this->drupalPostForm('form-test/color', $edit, 'Submit'));
$this->drupalPostForm('form-test/color', $edit, 'Submit');
$result = json_decode($this->getSession()->getPage()->getContent());
$this->assertEqual($result->color, $expected);
}
......@@ -592,7 +607,7 @@ public function testDisabledElements() {
// Submit the form with no input, as the browser does for disabled elements,
// and fetch the $form_state->getValues() that is passed to the submit handler.
$this->drupalPostForm('form-test/disabled-elements', [], t('Submit'));
$returned_values['normal'] = Json::decode($this->content);
$returned_values['normal'] = Json::decode($this->getSession()->getPage()->getContent());
// Do the same with input, as could happen if JavaScript un-disables an
// element. drupalPostForm() emulates a browser by not submitting input for
......@@ -600,8 +615,7 @@ public function testDisabledElements() {
$this->drupalGet('form-test/disabled-elements');
$disabled_elements = [];
foreach ($this->xpath('//*[@disabled]') as $element) {
$disabled_elements[] = (string) $element['name'];
unset($element['disabled']);
$disabled_elements[] = (string) $element->getAttribute('name');
}
// All the elements should be marked as disabled, including the ones below
......@@ -613,8 +627,14 @@ public function testDisabledElements() {
'@expected' => $expected_count,
]));
// Mink does not "see" hidden elements, so we need to set the value of the
// hidden element directly.
$this->assertSession()
->elementExists('css', 'input[name="hidden"]')
->setValue($edit['hidden']);
unset($edit['hidden']);
$this->drupalPostForm(NULL, $edit, t('Submit'));
$returned_values['hijacked'] = Json::decode($this->content);
$returned_values['hijacked'] = Json::decode($this->getSession()->getPage()->getContent());
// Ensure that the returned values match the form's default values in both
// cases.
......@@ -687,6 +707,9 @@ public function testDisabledMarkup() {
if (isset($type_map[$item['#type']])) {
$type = $type_map[$item['#type']];
}
if (isset($item['#value']) && is_object($item['#value'])) {
$item['#value'] = (string) $item['#value'];
}
$path = strtr($path, ['!type' => $type]);
// Verify that the element exists.
$element = $this->xpath($path, [
......@@ -713,12 +736,13 @@ public function testDisabledMarkup() {
/**
* Test Form API protections against input forgery.
*
* @see _form_test_input_forgery()
* @see \Drupal\form_test\Form\FormTestInputForgeryForm
*/
public function testInputForgery() {
$this->drupalGet('form-test/input-forgery');
$checkbox = $this->xpath('//input[@name="checkboxes[two]"]');
$checkbox[0]['value'] = 'FORGERY';
// The value for checkboxes[two] was changed using post render to simulate
// an input forgery.
// @see \Drupal\form_test\Form\FormTestInputForgeryForm::postRender
$this->drupalPostForm(NULL, ['checkboxes[one]' => TRUE, 'checkboxes[two]' => TRUE], t('Submit'));
$this->assertText('An illegal choice has been detected.', 'Input forgery was detected.');
}
......
<?php
namespace Drupal\system\Tests\Form;
namespace Drupal\Tests\system\Functional\Form;
use Drupal\Component\Serialization\Json;
use Drupal\Core\Language\LanguageInterface;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests that the language select form element prints and submits the right
......@@ -13,7 +13,7 @@
*
* @group Form
*/
class LanguageSelectElementTest extends WebTestBase {
class LanguageSelectElementTest extends BrowserTestBase {
/**
* Modules to enable.
......@@ -105,10 +105,11 @@ protected function _testLanguageSelectElementOptions($id, $options) {
// including the order, as the languages sent as a parameter.
$elements = $this->xpath("//select[@id='" . $id . "']");
$count = 0;
foreach ($elements[0]->option as $option) {
/** @var \Behat\Mink\Element\NodeElement $option */
foreach ($elements[0]->findAll('css', 'option') as $option) {
$count++;
$option_title = current($options);
$this->assertEqual((string) $option, $option_title);
$this->assertEqual($option->getText(), $option_title);
next($options);
}
$this->assertEqual($count, count($options), format_string('The number of languages and the number of options shown by the language element are the same: @languages languages, @number options', ['@languages' => count($options), '@number' => $count]));
......
<?php
namespace Drupal\system\Tests\Form;
namespace Drupal\Tests\system\Functional\Form;
use Drupal\Component\Serialization\Json;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests the form API Response element.
*
* @group Form
*/
class ResponseTest extends WebTestBase {
class ResponseTest extends BrowserTestBase {
/**
* Modules to enable.
......@@ -27,7 +27,8 @@ public function testFormResponse() {
'content' => $this->randomString(),
'status' => 200,
];
$content = Json::decode($this->drupalPostForm('form-test/response', $edit, 'Submit'));
$this->drupalPostForm('form-test/response', $edit, 'Submit');
$content = Json::decode($this->getSession()->getPage()->getContent());
$this->assertResponse(200);
$this->assertIdentical($edit['content'], $content, 'Response content matches');
$this->assertIdentical('invoked', $this->drupalGetHeader('X-Form-Test-Response-Event'), 'Response handled by kernel response subscriber');
......@@ -37,7 +38,8 @@ public function testFormResponse() {
'content' => $this->randomString(),
'status' => 418,
];
$content = Json::decode($this->drupalPostForm('form-test/response', $edit, 'Submit'));
$this->drupalPostForm('form-test/response', $edit, 'Submit');
$content = Json::decode($this->getSession()->getPage()->getContent());
$this->assertResponse(418);
$this->assertIdentical($edit['content'], $content, 'Response content matches');
$this->assertIdentical('invoked', $this->drupalGetHeader('X-Form-Test-Response-Event'), 'Response handled by kernel response subscriber');
......
<?php
namespace Drupal\system\Tests\Form;
namespace Drupal\Tests\system\Functional\Form;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\TestFileCreationTrait;
/**
* Tests proper removal of submitted form values using
......@@ -11,7 +12,11 @@
*
* @group Form
*/
class StateValuesCleanAdvancedTest extends WebTestBase {
class StateValuesCleanAdvancedTest extends BrowserTestBase {
use TestFileCreationTrait {
getTestFiles as drupalGetTestFiles;
}
/**
* Modules to enable.
......
<?php
namespace Drupal\system\Tests\Form;
namespace Drupal\Tests\system\Functional\Form;
use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests proper removal of submitted form values using
......@@ -12,7 +12,7 @@
*
* @group Form
*/
class StateValuesCleanTest extends WebTestBase {
class StateValuesCleanTest extends BrowserTestBase {