X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fviews%2Ftests%2Fsrc%2FKernel%2FPlugin%2FExposedFormRenderTest.php;h=aa7b3cb33583f02595059f6a36cf110090dc611d;hb=1c1cb0980bfa6caf0c24cce671b6bb541dc87583;hp=6767fffe3caa6d56a3f5e2cd0fe8759138893280;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/views/tests/src/Kernel/Plugin/ExposedFormRenderTest.php b/web/core/modules/views/tests/src/Kernel/Plugin/ExposedFormRenderTest.php index 6767fffe3..aa7b3cb33 100644 --- a/web/core/modules/views/tests/src/Kernel/Plugin/ExposedFormRenderTest.php +++ b/web/core/modules/views/tests/src/Kernel/Plugin/ExposedFormRenderTest.php @@ -3,11 +3,12 @@ namespace Drupal\Tests\views\Kernel\Plugin; use Drupal\Component\Utility\Html; +use Drupal\node\Entity\NodeType; use Drupal\Tests\views\Kernel\ViewsKernelTestBase; use Drupal\views\Views; /** - * Tests the exposed form markup. + * Tests the exposed form. * * @group views * @see \Drupal\views_test_data\Plugin\views\display_extender\DisplayExtenderTest @@ -52,4 +53,92 @@ class ExposedFormRenderTest extends ViewsKernelTestBase { $this->assertEqual(count($result), 1, 'Filter description was found.'); } + /** + * Tests the exposed form raw input. + */ + public function testExposedFormRawInput() { + $node_type = NodeType::create(['type' => 'article']); + $node_type->save(); + + $view = Views::getView('test_exposed_form_buttons'); + $view->setDisplay(); + $view->displayHandlers->get('default')->overrideOption('filters', [ + 'type' => [ + 'exposed' => TRUE, + 'field' => 'type', + 'id' => 'type', + 'table' => 'node_field_data', + 'plugin_id' => 'in_operator', + 'entity_type' => 'node', + 'entity_field' => 'type', + 'expose' => [ + 'identifier' => 'type', + 'label' => 'Content: Type', + 'operator_id' => 'type_op', + 'reduce' => FALSE, + 'multiple' => FALSE, + ], + ], + 'type_with_default_value' => [ + 'exposed' => TRUE, + 'field' => 'type', + 'id' => 'type_with_default_value', + 'table' => 'node_field_data', + 'plugin_id' => 'in_operator', + 'entity_type' => 'node', + 'entity_field' => 'type', + 'value' => ['article', 'article'], + 'expose' => [ + 'identifier' => 'type_with_default_value', + 'label' => 'Content: Type with value', + 'operator_id' => 'type_op', + 'reduce' => FALSE, + 'multiple' => FALSE, + ], + ], + 'multiple_types' => [ + 'exposed' => TRUE, + 'field' => 'type', + 'id' => 'multiple_types', + 'table' => 'node_field_data', + 'plugin_id' => 'in_operator', + 'entity_type' => 'node', + 'entity_field' => 'type', + 'expose' => [ + 'identifier' => 'multiple_types', + 'label' => 'Content: Type (multiple)', + 'operator_id' => 'type_op', + 'reduce' => FALSE, + 'multiple' => TRUE, + ], + ], + 'multiple_types_with_default_value' => [ + 'exposed' => TRUE, + 'field' => 'type', + 'id' => 'multiple_types_with_default_value', + 'table' => 'node_field_data', + 'plugin_id' => 'in_operator', + 'entity_type' => 'node', + 'entity_field' => 'type', + 'value' => ['article', 'article'], + 'expose' => [ + 'identifier' => 'multiple_types_with_default_value', + 'label' => 'Content: Type with default value (multiple)', + 'operator_id' => 'type_op', + 'reduce' => FALSE, + 'multiple' => TRUE, + ], + ], + ]); + $view->save(); + $this->executeView($view); + + $expected = [ + 'type' => 'All', + 'type_with_default_value' => 'article', + 'multiple_types_with_default_value' => ['article'], + ]; + $this->assertSame($view->exposed_raw_input, $expected); + } + }