Chris@0: profile != 'standard') { Chris@0: $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']); Chris@0: $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']); Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Simulates submission of a form using GET instead of POST. Chris@0: * Chris@0: * Forms that use the GET method cannot be submitted with Chris@0: * WebTestBase::drupalPostForm(), which explicitly uses POST to submit the Chris@0: * form. So this method finds the form, verifies that it has input fields and Chris@0: * a submit button matching the inputs to this method, and then calls Chris@0: * WebTestBase::drupalGet() to simulate the form submission to the 'action' Chris@0: * URL of the form (if set, or the current URL if not). Chris@0: * Chris@0: * See WebTestBase::drupalPostForm() for more detailed documentation of the Chris@0: * function parameters. Chris@0: * Chris@0: * @param string $path Chris@0: * Location of the form to be submitted: either a Drupal path, absolute Chris@0: * path, or NULL to use the current page. Chris@0: * @param array $edit Chris@0: * Form field data to submit. Unlike drupalPostForm(), this does not support Chris@0: * file uploads. Chris@0: * @param string $submit Chris@0: * Value of the submit button to submit clicking. Unlike drupalPostForm(), Chris@0: * this does not support AJAX. Chris@0: * @param string $form_html_id Chris@0: * (optional) HTML ID of the form, to disambiguate. Chris@0: */ Chris@0: protected function submitGetForm($path, $edit, $submit, $form_html_id = NULL) { Chris@0: if (isset($path)) { Chris@0: $this->drupalGet($path); Chris@0: } Chris@0: Chris@0: if ($this->parse()) { Chris@0: // Iterate over forms to find one that matches $edit and $submit. Chris@0: $edit_save = $edit; Chris@0: $xpath = '//form'; Chris@0: if (!empty($form_html_id)) { Chris@0: $xpath .= "[@id='" . $form_html_id . "']"; Chris@0: } Chris@0: $forms = $this->xpath($xpath); Chris@0: foreach ($forms as $form) { Chris@0: // Try to set the fields of this form as specified in $edit. Chris@0: $edit = $edit_save; Chris@0: $post = []; Chris@0: $upload = []; Chris@0: $submit_matches = $this->handleForm($post, $edit, $upload, $submit, $form); Chris@0: if (!$edit && $submit_matches) { Chris@0: // Everything matched, so "submit" the form. Chris@0: $action = isset($form['action']) ? $this->getAbsoluteUrl((string) $form['action']) : NULL; Chris@0: $this->drupalGet($action, ['query' => $post]); Chris@0: return; Chris@0: } Chris@0: } Chris@0: Chris@0: // We have not found a form which contained all fields of $edit and Chris@0: // the submit button. Chris@0: foreach ($edit as $name => $value) { Chris@17: $this->fail(new FormattableMarkup('Failed to set field @name to @value', ['@name' => $name, '@value' => $value])); Chris@0: } Chris@0: $this->assertTrue($submit_matches, format_string('Found the @submit button', ['@submit' => $submit])); Chris@0: $this->fail(format_string('Found the requested form fields at @path', ['@path' => $path])); Chris@0: } Chris@0: } Chris@0: Chris@0: }