update drupal
This commit is contained in:
+4
@@ -35,6 +35,10 @@ trait ModerationStateJoinViewsHandlerTrait {
|
||||
'field' => 'content_entity_type_id',
|
||||
'value' => $left_entity_type->id(),
|
||||
],
|
||||
[
|
||||
'field' => 'content_entity_id',
|
||||
'left_field' => $left_entity_type->getKey('id'),
|
||||
],
|
||||
],
|
||||
];
|
||||
if ($left_entity_type->isTranslatable()) {
|
||||
|
||||
+12
-3
@@ -123,6 +123,7 @@ class ModerationStateFilter extends InOperator implements DependentWithRemovalPl
|
||||
$this->ensureMyTable();
|
||||
|
||||
$entity_type = $this->entityTypeManager->getDefinition($this->getEntityType());
|
||||
$bundle_condition = NULL;
|
||||
if ($entity_type->hasKey('bundle')) {
|
||||
// Get a list of bundles that are being moderated by the workflows
|
||||
// configured in this filter.
|
||||
@@ -137,7 +138,7 @@ class ModerationStateFilter extends InOperator implements DependentWithRemovalPl
|
||||
// If we have a list of moderated bundles, restrict the query to show only
|
||||
// entities in those bundles.
|
||||
if ($moderated_bundles) {
|
||||
$entity_base_table_alias = $this->table;
|
||||
$entity_base_table_alias = $this->relationship ?: $this->table;
|
||||
|
||||
// The bundle field of an entity type is not revisionable so we need to
|
||||
// join the base table.
|
||||
@@ -156,7 +157,8 @@ class ModerationStateFilter extends InOperator implements DependentWithRemovalPl
|
||||
$entity_base_table_alias = $this->query->addRelationship($entity_base_table, $join, $entity_revision_base_table);
|
||||
}
|
||||
|
||||
$this->query->addWhere($this->options['group'], "$entity_base_table_alias.{$entity_type->getKey('bundle')}", $moderated_bundles, 'IN');
|
||||
$bundle_condition = new Condition('AND');
|
||||
$bundle_condition->condition("$entity_base_table_alias.{$entity_type->getKey('bundle')}", $moderated_bundles, 'IN');
|
||||
}
|
||||
// Otherwise, force the query to return an empty result.
|
||||
else {
|
||||
@@ -186,7 +188,14 @@ class ModerationStateFilter extends InOperator implements DependentWithRemovalPl
|
||||
$field->condition($and);
|
||||
}
|
||||
|
||||
$this->query->addWhere($this->options['group'], $field);
|
||||
if ($bundle_condition) {
|
||||
// The query must match the bundle AND the workflow/state conditions.
|
||||
$bundle_condition->condition($field);
|
||||
$this->query->addWhere($this->options['group'], $bundle_condition);
|
||||
}
|
||||
else {
|
||||
$this->query->addWhere($this->options['group'], $field);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+348
@@ -0,0 +1,348 @@
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- content_moderation
|
||||
- node
|
||||
- user
|
||||
id: test_content_moderation_filter_via_relationship
|
||||
label: test_content_moderation_filter_via_relationship
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: users_field_data
|
||||
base_field: uid
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 0
|
||||
display_options:
|
||||
access:
|
||||
type: perm
|
||||
options:
|
||||
perm: 'access user profiles'
|
||||
cache:
|
||||
type: tag
|
||||
options: { }
|
||||
query:
|
||||
type: views_query
|
||||
options:
|
||||
disable_sql_rewrite: false
|
||||
distinct: false
|
||||
replica: false
|
||||
query_comment: ''
|
||||
query_tags: { }
|
||||
exposed_form:
|
||||
type: basic
|
||||
options:
|
||||
submit_button: Apply
|
||||
reset_button: false
|
||||
reset_button_label: Reset
|
||||
exposed_sorts_label: 'Sort by'
|
||||
expose_sort_order: true
|
||||
sort_asc_label: Asc
|
||||
sort_desc_label: Desc
|
||||
pager:
|
||||
type: none
|
||||
options:
|
||||
offset: 0
|
||||
style:
|
||||
type: default
|
||||
row:
|
||||
type: fields
|
||||
fields:
|
||||
name:
|
||||
id: name
|
||||
table: users_field_data
|
||||
field: name
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: ''
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: false
|
||||
ellipsis: false
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: false
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
click_sort_column: value
|
||||
type: user_name
|
||||
settings:
|
||||
link_to_entity: false
|
||||
group_column: value
|
||||
group_columns: { }
|
||||
group_rows: true
|
||||
delta_limit: 0
|
||||
delta_offset: 0
|
||||
delta_reversed: false
|
||||
delta_first_last: false
|
||||
multi_type: separator
|
||||
separator: ', '
|
||||
field_api_classes: false
|
||||
entity_type: user
|
||||
entity_field: name
|
||||
plugin_id: field
|
||||
title:
|
||||
id: title
|
||||
table: node_field_data
|
||||
field: title
|
||||
relationship: uid
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: ''
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: false
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
click_sort_column: value
|
||||
type: string
|
||||
settings:
|
||||
link_to_entity: false
|
||||
group_column: value
|
||||
group_columns: { }
|
||||
group_rows: true
|
||||
delta_limit: 0
|
||||
delta_offset: 0
|
||||
delta_reversed: false
|
||||
delta_first_last: false
|
||||
multi_type: separator
|
||||
separator: ', '
|
||||
field_api_classes: false
|
||||
entity_type: node
|
||||
entity_field: title
|
||||
plugin_id: field
|
||||
moderation_state:
|
||||
id: moderation_state
|
||||
table: node_field_data
|
||||
field: moderation_state
|
||||
relationship: uid
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: ''
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: false
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
click_sort_column: value
|
||||
type: content_moderation_state
|
||||
settings: { }
|
||||
group_column: value
|
||||
group_columns: { }
|
||||
group_rows: true
|
||||
delta_limit: 0
|
||||
delta_offset: 0
|
||||
delta_reversed: false
|
||||
delta_first_last: false
|
||||
multi_type: separator
|
||||
separator: ', '
|
||||
field_api_classes: false
|
||||
entity_type: node
|
||||
plugin_id: moderation_state_field
|
||||
filters:
|
||||
moderation_state:
|
||||
id: moderation_state
|
||||
table: node_field_data
|
||||
field: moderation_state
|
||||
relationship: uid
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: in
|
||||
value: { }
|
||||
group: 1
|
||||
exposed: true
|
||||
expose:
|
||||
operator_id: moderation_state_op
|
||||
label: 'Moderation state'
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: moderation_state_op
|
||||
identifier: moderation_state
|
||||
required: false
|
||||
remember: false
|
||||
multiple: false
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
anonymous: '0'
|
||||
administrator: '0'
|
||||
reduce: false
|
||||
is_grouped: false
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: true
|
||||
widget: select
|
||||
multiple: false
|
||||
remember: false
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
entity_type: node
|
||||
plugin_id: moderation_state_filter
|
||||
sorts:
|
||||
vid:
|
||||
id: vid
|
||||
table: node_field_data
|
||||
field: vid
|
||||
relationship: uid
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
order: ASC
|
||||
exposed: false
|
||||
expose:
|
||||
label: ''
|
||||
entity_type: node
|
||||
entity_field: vid
|
||||
plugin_id: standard
|
||||
title: test_content_moderation_filter_via_relationship
|
||||
header: { }
|
||||
footer: { }
|
||||
empty: { }
|
||||
relationships:
|
||||
uid:
|
||||
id: uid
|
||||
table: users_field_data
|
||||
field: uid
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: nodes
|
||||
required: true
|
||||
entity_type: user
|
||||
entity_field: uid
|
||||
plugin_id: standard
|
||||
arguments: { }
|
||||
display_extenders: { }
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- url
|
||||
- user.permissions
|
||||
tags:
|
||||
- 'config:workflow_list'
|
||||
page_1:
|
||||
display_plugin: page
|
||||
id: page_1
|
||||
display_title: Page
|
||||
position: 1
|
||||
display_options:
|
||||
display_extenders: { }
|
||||
path: test-content-moderation-filter-relationship
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- url
|
||||
- user.permissions
|
||||
tags:
|
||||
- 'config:workflow_list'
|
||||
+268
@@ -0,0 +1,268 @@
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- content_moderation
|
||||
- node
|
||||
- user
|
||||
id: test_content_moderation_state_filter_base_table_filter_group_or
|
||||
label: test_content_moderation_state_filter_base_table_filter_group_or
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: node_field_data
|
||||
base_field: nid
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 0
|
||||
display_options:
|
||||
access:
|
||||
type: perm
|
||||
options:
|
||||
perm: 'access content'
|
||||
cache:
|
||||
type: tag
|
||||
options: { }
|
||||
query:
|
||||
type: views_query
|
||||
options:
|
||||
disable_sql_rewrite: false
|
||||
distinct: false
|
||||
replica: false
|
||||
query_comment: ''
|
||||
query_tags: { }
|
||||
exposed_form:
|
||||
type: basic
|
||||
options:
|
||||
submit_button: Apply
|
||||
reset_button: false
|
||||
reset_button_label: Reset
|
||||
exposed_sorts_label: 'Sort by'
|
||||
expose_sort_order: true
|
||||
sort_asc_label: Asc
|
||||
sort_desc_label: Desc
|
||||
pager:
|
||||
type: none
|
||||
options:
|
||||
offset: 0
|
||||
style:
|
||||
type: default
|
||||
options:
|
||||
grouping: { }
|
||||
row_class: ''
|
||||
default_row_class: true
|
||||
uses_fields: false
|
||||
row:
|
||||
type: fields
|
||||
options:
|
||||
inline: { }
|
||||
separator: ''
|
||||
hide_empty: false
|
||||
default_field_elements: true
|
||||
fields:
|
||||
nid:
|
||||
id: nid
|
||||
table: node_field_data
|
||||
field: nid
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: ''
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: false
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
click_sort_column: value
|
||||
type: number_integer
|
||||
settings:
|
||||
thousand_separator: ''
|
||||
prefix_suffix: false
|
||||
group_column: value
|
||||
group_columns: { }
|
||||
group_rows: true
|
||||
delta_limit: 0
|
||||
delta_offset: 0
|
||||
delta_reversed: false
|
||||
delta_first_last: false
|
||||
multi_type: separator
|
||||
separator: ', '
|
||||
field_api_classes: false
|
||||
entity_type: node
|
||||
entity_field: nid
|
||||
plugin_id: field
|
||||
filters:
|
||||
moderation_state:
|
||||
id: moderation_state
|
||||
table: node_field_data
|
||||
field: moderation_state
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: in
|
||||
value: { }
|
||||
group: 1
|
||||
exposed: true
|
||||
expose:
|
||||
operator_id: moderation_state_op
|
||||
label: 'Default Revision State'
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: moderation_state_op
|
||||
identifier: default_revision_state
|
||||
required: false
|
||||
remember: false
|
||||
multiple: false
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
anonymous: '0'
|
||||
administrator: '0'
|
||||
reduce: false
|
||||
operator_limit_selection: false
|
||||
operator_list: { }
|
||||
is_grouped: false
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: true
|
||||
widget: select
|
||||
multiple: false
|
||||
remember: false
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
entity_type: node
|
||||
plugin_id: moderation_state_filter
|
||||
moderation_state_1:
|
||||
id: moderation_state_1
|
||||
table: node_field_data
|
||||
field: moderation_state
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: 'not empty'
|
||||
value: { }
|
||||
group: 2
|
||||
exposed: false
|
||||
expose:
|
||||
operator_id: ''
|
||||
label: ''
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: ''
|
||||
identifier: ''
|
||||
required: false
|
||||
remember: false
|
||||
multiple: false
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
reduce: false
|
||||
operator_limit_selection: false
|
||||
operator_list: { }
|
||||
is_grouped: false
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: true
|
||||
widget: select
|
||||
multiple: false
|
||||
remember: false
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
entity_type: node
|
||||
plugin_id: moderation_state_filter
|
||||
sorts:
|
||||
nid:
|
||||
id: nid
|
||||
table: node_field_data
|
||||
field: nid
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
order: ASC
|
||||
exposed: false
|
||||
expose:
|
||||
label: ''
|
||||
entity_type: node
|
||||
entity_field: nid
|
||||
plugin_id: standard
|
||||
header: { }
|
||||
footer: { }
|
||||
empty: { }
|
||||
relationships: { }
|
||||
arguments: { }
|
||||
display_extenders: { }
|
||||
filter_groups:
|
||||
operator: AND
|
||||
groups:
|
||||
1: OR
|
||||
2: OR
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- url
|
||||
- 'user.node_grants:view'
|
||||
- user.permissions
|
||||
tags:
|
||||
- 'config:workflow_list'
|
||||
page_1:
|
||||
display_plugin: page
|
||||
id: page_1
|
||||
display_title: Page
|
||||
position: 1
|
||||
display_options:
|
||||
display_extenders: { }
|
||||
path: filter-test-path
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- url
|
||||
- 'user.node_grants:view'
|
||||
- user.permissions
|
||||
tags:
|
||||
- 'config:workflow_list'
|
||||
+1
-1
@@ -61,7 +61,7 @@ class ContentModerationAccessTest extends KernelTestBase {
|
||||
/**
|
||||
* Tests access cacheability.
|
||||
*/
|
||||
public function testAccessCacheablity() {
|
||||
public function testAccessCacheability() {
|
||||
$node = $this->createNode(['type' => 'page']);
|
||||
|
||||
/** @var \Drupal\user\RoleInterface $authenticated */
|
||||
|
||||
+71
-12
@@ -7,6 +7,7 @@ use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
use Drupal\Tests\user\Traits\UserCreationTrait;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views\Views;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
@@ -21,6 +22,7 @@ use Drupal\workflows\Entity\Workflow;
|
||||
class ViewsModerationStateFilterTest extends ViewsKernelTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
use UserCreationTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@@ -131,18 +133,26 @@ class ViewsModerationStateFilterTest extends ViewsKernelTestBase {
|
||||
$translated_forward_revision->moderation_state = 'translated_draft';
|
||||
$translated_forward_revision->save();
|
||||
|
||||
// The three default revisions are listed when no filter is specified.
|
||||
$this->assertNodesWithFilters([$node, $second_node, $third_node], []);
|
||||
// Test the filter within an AND filter group (the default) and an OR filter
|
||||
// group.
|
||||
$base_table_views = [
|
||||
'test_content_moderation_state_filter_base_table',
|
||||
'test_content_moderation_state_filter_base_table_filter_group_or',
|
||||
];
|
||||
foreach ($base_table_views as $view_id) {
|
||||
// The three default revisions are listed when no filter is specified.
|
||||
$this->assertNodesWithFilters([$node, $second_node, $third_node], [], $view_id);
|
||||
|
||||
// The default revision of node one and three are published.
|
||||
$this->assertNodesWithFilters([$node, $third_node], [
|
||||
'default_revision_state' => 'editorial-published',
|
||||
]);
|
||||
// The default revision of node one and three are published.
|
||||
$this->assertNodesWithFilters([$node, $third_node], [
|
||||
'default_revision_state' => 'editorial-published',
|
||||
], $view_id);
|
||||
|
||||
// The default revision of node two is draft.
|
||||
$this->assertNodesWithFilters([$second_node], [
|
||||
'default_revision_state' => 'editorial-draft',
|
||||
]);
|
||||
// The default revision of node two is draft.
|
||||
$this->assertNodesWithFilters([$second_node], [
|
||||
'default_revision_state' => 'editorial-draft',
|
||||
], $view_id);
|
||||
}
|
||||
|
||||
// Test the same three revisions on a view displaying content revisions.
|
||||
// Both nodes have one draft revision.
|
||||
@@ -183,6 +193,52 @@ class ViewsModerationStateFilterTest extends ViewsKernelTestBase {
|
||||
$this->assertIdenticalResultset($view, [['id' => $test_entity->id()]], ['id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the moderation state filter on an entity added via a relationship.
|
||||
*/
|
||||
public function testModerationStateFilterOnJoinedEntity() {
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
||||
$workflow->save();
|
||||
|
||||
// Create some sample content that will satisfy a view of users with a
|
||||
// relationship to an item of content.
|
||||
$user = $this->createUser([], 'Test user');
|
||||
$node = Node::create([
|
||||
'type' => 'example',
|
||||
'title' => 'Test node',
|
||||
'moderation_state' => 'published',
|
||||
'uid' => $user->id(),
|
||||
]);
|
||||
$node->save();
|
||||
|
||||
// When filtering by published nodes, the sample content will appear.
|
||||
$view = Views::getView('test_content_moderation_filter_via_relationship');
|
||||
$view->setExposedInput([
|
||||
'moderation_state' => 'editorial-published',
|
||||
]);
|
||||
$view->execute();
|
||||
$this->assertIdenticalResultset($view, [
|
||||
[
|
||||
'name' => 'Test user',
|
||||
'title' => 'Test node',
|
||||
'moderation_state' => 'published',
|
||||
],
|
||||
], [
|
||||
'name' => 'name',
|
||||
'title' => 'title',
|
||||
'moderation_state' => 'moderation_state',
|
||||
]);
|
||||
|
||||
// Filtering by the draft state will filter out the sample content.
|
||||
$view = Views::getView('test_content_moderation_filter_via_relationship');
|
||||
$view->setExposedInput([
|
||||
'moderation_state' => 'editorial-draft',
|
||||
]);
|
||||
$view->execute();
|
||||
$this->assertIdenticalResultset($view, [], ['name' => 'name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the list of states in the filter plugin.
|
||||
*/
|
||||
@@ -297,8 +353,11 @@ class ViewsModerationStateFilterTest extends ViewsKernelTestBase {
|
||||
$this->assertEquals('vid', $configuration['left_field']);
|
||||
$this->assertEquals('content_entity_type_id', $configuration['extra'][0]['field']);
|
||||
$this->assertEquals('node', $configuration['extra'][0]['value']);
|
||||
$this->assertEquals('langcode', $configuration['extra'][1]['field']);
|
||||
$this->assertEquals('langcode', $configuration['extra'][1]['left_field']);
|
||||
|
||||
$this->assertEquals('content_entity_id', $configuration['extra'][1]['field']);
|
||||
$this->assertEquals('nid', $configuration['extra'][1]['left_field']);
|
||||
$this->assertEquals('langcode', $configuration['extra'][2]['field']);
|
||||
$this->assertEquals('langcode', $configuration['extra'][2]['left_field']);
|
||||
|
||||
$expected_result = [];
|
||||
foreach ($nodes as $node) {
|
||||
|
||||
Reference in New Issue
Block a user