Commit bb08449a authored by alexpott's avatar alexpott

Issue #2797947 by jmuzz: Allow NULL as second parameter in BTB->drupalPostForm()

parent 0cf01aef
......@@ -79,6 +79,16 @@ public function testForm() {
$config_factory = $this->container->get('config.factory');
$value = $config_factory->get('form_test.object')->get('bananas');
$this->assertSame('green', $value);
// Test drupalPostForm().
$edit = ['bananas' => 'red'];
$this->drupalPostForm('form-test/object-builder', $edit, 'Save');
$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);
}
/**
......
......@@ -924,6 +924,8 @@ protected function submitForm(array $edit, $submit, $form_html_id = NULL) {
* $edit = array();
* $edit['name[]'] = array('value1', 'value2');
* @endcode
* @todo change $edit to disallow NULL as a value for Drupal 9.
* https://www.drupal.org/node/2802401
* @param string $submit
* Value of the submit button whose click is to be emulated. For example,
* t('Save'). The processing of the request depends on this value. For
......@@ -949,11 +951,14 @@ protected function submitForm(array $edit, $submit, $form_html_id = NULL) {
* @param array $options
* Options to be forwarded to the url generator.
*/
protected function drupalPostForm($path, array $edit, $submit, array $options = array()) {
protected function drupalPostForm($path, $edit, $submit, array $options = array()) {
if (is_object($submit)) {
// Cast MarkupInterface objects to string.
$submit = (string) $submit;
}
if ($edit === NULL) {
$edit = [];
}
if (is_array($edit)) {
$edit = $this->castSafeStrings($edit);
}
......
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