function ViewsModerationStateFilterTest::testFilterRenderCache
Same name in other branches
- 8.9.x core/modules/content_moderation/tests/src/Functional/ViewsModerationStateFilterTest.php \Drupal\Tests\content_moderation\Functional\ViewsModerationStateFilterTest::testFilterRenderCache()
- 10 core/modules/content_moderation/tests/src/Functional/ViewsModerationStateFilterTest.php \Drupal\Tests\content_moderation\Functional\ViewsModerationStateFilterTest::testFilterRenderCache()
- 11.x core/modules/content_moderation/tests/src/Functional/ViewsModerationStateFilterTest.php \Drupal\Tests\content_moderation\Functional\ViewsModerationStateFilterTest::testFilterRenderCache()
Tests the content moderation state filter caching is correct.
File
-
core/
modules/ content_moderation/ tests/ src/ Functional/ ViewsModerationStateFilterTest.php, line 278
Class
- ViewsModerationStateFilterTest
- Tests the views 'moderation_state_filter' filter plugin.
Namespace
Drupal\Tests\content_moderation\FunctionalCode
public function testFilterRenderCache() {
// Initially all states of the workflow are displayed.
$this->drupalGet('admin/config/workflow/workflows/manage/editorial/type/node');
$this->submitForm([
'bundles[example_a]' => TRUE,
], 'Save');
$this->assertFilterStates([
'All',
'editorial-draft',
'editorial-published',
'editorial-archived',
]);
// Adding a new state to the editorial workflow will display that state in
// the list of filters.
$this->drupalGet('admin/config/workflow/workflows/manage/editorial/add_state');
$this->submitForm([
'label' => 'Foo',
'id' => 'foo',
], 'Save');
$this->assertFilterStates([
'All',
'editorial-draft',
'editorial-published',
'editorial-archived',
'editorial-foo',
]);
// Adding a second workflow to nodes will also show new states.
$this->drupalGet('admin/config/workflow/workflows/manage/new_workflow/type/node');
$this->submitForm([
'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',
]);
// Add a few more states and change the exposed filter to allow multiple
// selections so we can check that the size of the select element does not
// exceed 8 options.
$this->drupalGet('admin/config/workflow/workflows/manage/editorial/add_state');
$this->submitForm([
'label' => 'Foo 2',
'id' => 'foo2',
], 'Save');
$this->drupalGet('admin/config/workflow/workflows/manage/editorial/add_state');
$this->submitForm([
'label' => 'Foo 3',
'id' => 'foo3',
], 'Save');
$view_id = 'test_content_moderation_state_filter_base_table';
$edit['options[expose][multiple]'] = TRUE;
$this->drupalGet("admin/structure/views/nojs/handler/{$view_id}/default/filter/moderation_state");
$this->submitForm($edit, 'Apply');
$this->drupalGet("admin/structure/views/view/{$view_id}");
$this->submitForm([], 'Save');
$this->assertFilterStates([
'editorial-draft',
'editorial-published',
'editorial-archived',
'editorial-foo',
'editorial-foo2',
'editorial-foo3',
'new_workflow-draft',
'new_workflow-published',
'new_workflow-bar',
], TRUE);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.