diff --git a/core/modules/content_moderation/src/Plugin/views/filter/ModerationStateFilter.php b/core/modules/content_moderation/src/Plugin/views/filter/ModerationStateFilter.php index 60697883e2..4778fbb8cd 100644 --- a/core/modules/content_moderation/src/Plugin/views/filter/ModerationStateFilter.php +++ b/core/modules/content_moderation/src/Plugin/views/filter/ModerationStateFilter.php @@ -118,9 +118,9 @@ public function ensureMyTable() { // Filter the moderation states of the content via the // ContentModerationState field revision table, joining either the entity - // field data or revision table. This allows filtering states against either - // the default or latest revision, depending on the relationship of the - // filter. + // field data or revision table. This allows filtering states against + // either the default or latest revision, depending on the relationship of + // the filter. $left_entity_type = $this->entityTypeManager->getDefinition($this->getEntityType()); $entity_type = $this->entityTypeManager->getDefinition('content_moderation_state'); $configuration = [ @@ -207,7 +207,7 @@ protected function opSimple() { $this->ensureMyTable(); - if ($this->operator == 'in') { + if ($this->operator === 'in') { $operator = "="; } else { diff --git a/core/modules/content_moderation/tests/modules/content_moderation_test_views/config/install/views.view.test_content_moderation_state_filter.yml b/core/modules/content_moderation/tests/modules/content_moderation_test_views/config/install/views.view.test_content_moderation_state_filter.yml index 11cd24c941..6e13b24073 100644 --- a/core/modules/content_moderation/tests/modules/content_moderation_test_views/config/install/views.view.test_content_moderation_state_filter.yml +++ b/core/modules/content_moderation/tests/modules/content_moderation_test_views/config/install/views.view.test_content_moderation_state_filter.yml @@ -151,7 +151,7 @@ display: identifier: default_revision_state required: false remember: false - multiple: false + multiple: true remember_roles: authenticated: authenticated anonymous: '0' diff --git a/core/modules/content_moderation/tests/src/Functional/ViewsModerationStateFilterTest.php b/core/modules/content_moderation/tests/src/Functional/ViewsModerationStateFilterTest.php index de5a3379e4..53216b2afc 100644 --- a/core/modules/content_moderation/tests/src/Functional/ViewsModerationStateFilterTest.php +++ b/core/modules/content_moderation/tests/src/Functional/ViewsModerationStateFilterTest.php @@ -199,7 +199,7 @@ public function testFilterRenderCache() { $this->drupalPostForm('admin/config/workflow/workflows/manage/editorial/type/node', [ 'bundles[example_a]' => TRUE, ], 'Save'); - $this->assertFilterStates(['All', 'editorial-draft', 'editorial-published', 'editorial-archived']); + $this->assertFilterStates(['editorial-draft', 'editorial-published', 'editorial-archived']); // Adding a new state to the editorial workflow will display that state in // the list of filters. @@ -207,13 +207,13 @@ public function testFilterRenderCache() { 'label' => 'Foo', 'id' => 'foo', ], 'Save'); - $this->assertFilterStates(['All', 'editorial-draft', 'editorial-published', 'editorial-archived', 'editorial-foo']); + $this->assertFilterStates(['editorial-draft', 'editorial-published', 'editorial-archived', 'editorial-foo']); // Adding a second workflow to nodes will also show new states. $this->drupalPostForm('admin/config/workflow/workflows/manage/new_workflow/type/node', [ 'bundles[example_b]' => TRUE, ], 'Save'); - $this->assertFilterStates(['All', 'editorial-draft', 'editorial-published', 'editorial-archived', 'editorial-foo', 'new_workflow-draft', 'new_workflow-published', 'new_workflow-bar']); + $this->assertFilterStates(['editorial-draft', 'editorial-published', 'editorial-archived', 'editorial-foo', 'new_workflow-draft', 'new_workflow-published', 'new_workflow-bar']); } /** @@ -225,9 +225,15 @@ public function testFilterRenderCache() { protected function assertFilterStates($states) { $this->drupalGet('/filter-test-path'); - $this->assertSession()->elementsCount('css', '#edit-default-revision-state option', count($states)); + $assert_session = $this->assertSession(); + // Checks the select contains the correct number of options. + $assert_session->elementsCount('css', '#edit-default-revision-state option', count($states)); + // Checks the size of the select is correct based on the number of states, + // plus one for the optgroup label. + $assert_session->elementAttributeContains('css', '#edit-default-revision-state', 'size', min(count($states, COUNT_RECURSIVE)+1, 8)); + // Checks an option exists for each of the expected states. foreach ($states as $state) { - $this->assertSession()->optionExists('default_revision_state', $state); + $assert_session->optionExists('Default Revision State', $state); } }