diff --git a/core/modules/views/src/Tests/Plugin/ExposedFormTest.php b/core/modules/views/src/Tests/Plugin/ExposedFormTest.php index 9a07d52..2c7769e 100644 --- a/core/modules/views/src/Tests/Plugin/ExposedFormTest.php +++ b/core/modules/views/src/Tests/Plugin/ExposedFormTest.php @@ -41,6 +41,8 @@ public static function getInfo() { protected function setUp() { parent::setUp(); + $this->enableViewsTestModule(); + $this->drupalCreateContentType(array('type' => 'article')); // Create some random nodes. @@ -202,14 +204,16 @@ protected function getExpectedExposedFormId(ViewExecutable $view) { * Tests a view which is rendered after a form with a validation error. */ public function testFormErrorWithExposedForm() { - $nodes = array(); - $nodes[] = $this->drupalCreateNode(); - $nodes[] = $this->drupalCreateNode(); - - $this->drupalGet('test-form'); + $this->drupalGet('views_test_data_error_form_page'); + $this->assertResponse(200); + $form = $this->cssSelect('form.views-exposed-form'); + $this->assertTrue($form, 'The exposed form element was found.'); $this->assertRaw(t('Apply'), 'Ensure the exposed form is rendered before submitting the normal form.'); $this->drupalPostForm(NULL, array(), t('Submit')); + $this->assertResponse(200); + $form = $this->cssSelect('form.views-exposed-form'); + $this->assertTrue($form, 'The exposed form element was found.'); $this->assertRaw(t('Apply'), 'Ensure the exposed form is rendered after submitting the normal form.'); } diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_form.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_form.yml index f9646db..f87d3f9 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_form.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_form.yml @@ -1,5 +1,4 @@ base_table: node -base_field: nid core: '8' description: '' status: '1' @@ -11,17 +10,13 @@ display: cache: type: none exposed_form: + options: + reset_button: '1' type: basic - pager: - type: full - style: - type: default - row: - type: fields filters: status: id: status - table: node + table: node_field_data field: status relationship: none group_type: group @@ -57,17 +52,23 @@ display: default_group: All default_group_multiple: { } group_items: { } + pager: + type: full + query: + options: + query_comment: '0' + type: views_query + style: + type: default + row: + type: 'entity:node' + options: + comments: '0' + links: '1' display_plugin: default display_title: Master id: default - position: '0' - embed_1: - display_plugin: embed - id: embed_1 - display_title: Embed - position: '' - display_options: { } -human_name: '' + position: 0 label: '' id: test_exposed_form tag: '' diff --git a/core/modules/views/tests/modules/views_test_data/src/Controller/ViewsTestDataController.php b/core/modules/views/tests/modules/views_test_data/src/Controller/ViewsTestDataController.php index afd678c..1b75927 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Controller/ViewsTestDataController.php +++ b/core/modules/views/tests/modules/views_test_data/src/Controller/ViewsTestDataController.php @@ -7,6 +7,26 @@ namespace Drupal\views_test_data\Controller; +/** + * Controller class for views_test_data callbacks. + */ class ViewsTestDataController { -} + /** + * Renders an error form page. + * + * This contains a form that will contain an error and an embedded view with + * an exposed form. + */ + public function errorFormPage() { + $build = array(); + $build['error_form'] = \Drupal::formBuilder()->getForm('Drupal\views_test_data\Form\ViewsTestDataErrorForm'); + $build['view'] = array( + '#type' => 'view', + '#name' => 'test_exposed_form', + ); + + return $build; + } + +} diff --git a/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php b/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php index df84650..71d0c43 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php +++ b/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php @@ -1,7 +1,7 @@ 'view', - '#name' => 'test_view', - '#display_id' => 'default', - '#arguments' => array(25), + $form['text'] = array( + '#type' => 'textfield', + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit'), ); return $form; @@ -38,6 +39,7 @@ public function buildForm(array $form, array &$form_state) { * {@inheritdoc} */ public function validateForm(array &$form, array &$form_state) { + \Drupal::formBuilder()->setErrorByName('text', $form_state, t('Form validation error')); } /** diff --git a/core/modules/views/tests/modules/views_test_data/views_test_data.routing.yml b/core/modules/views/tests/modules/views_test_data/views_test_data.routing.yml index e1c25ea..c665f0a 100644 --- a/core/modules/views/tests/modules/views_test_data/views_test_data.routing.yml +++ b/core/modules/views/tests/modules/views_test_data/views_test_data.routing.yml @@ -4,3 +4,10 @@ views_test_data.element: _form: '\Drupal\views_test_data\Form\ViewsTestDataElementForm' requirements: _access: 'TRUE' + +views_test_data.error_form_page: + path: '/views_test_data_error_form_page' + defaults: + _content: '\Drupal\views_test_data\Controller\ViewsTestDataController::errorFormPage' + requirements: + _access: 'TRUE'