upgrades core to 8.4.2
This commit is contained in:
@@ -8,8 +8,8 @@ dependencies:
|
||||
- views
|
||||
- entity_test
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
@@ -12,7 +12,6 @@ use Drupal\Core\Field\FieldDefinitionInterface;
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_entity_bundle_field_info().
|
||||
*/
|
||||
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- entity_test
|
||||
id: computed_field_view
|
||||
label: 'Computed Field View'
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: entity_test_computed_field
|
||||
base_field: id
|
||||
core: 8.x
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 0
|
||||
display_options:
|
||||
access:
|
||||
type: none
|
||||
options: { }
|
||||
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: mini
|
||||
options:
|
||||
items_per_page: 10
|
||||
offset: 0
|
||||
id: 0
|
||||
total_pages: null
|
||||
expose:
|
||||
items_per_page: false
|
||||
items_per_page_label: 'Items per page'
|
||||
items_per_page_options: '5, 10, 25, 50'
|
||||
items_per_page_options_all: false
|
||||
items_per_page_options_all_label: '- All -'
|
||||
offset: false
|
||||
offset_label: Offset
|
||||
tags:
|
||||
previous: ‹‹
|
||||
next: ››
|
||||
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:
|
||||
computed_string_field:
|
||||
id: computed_string_field
|
||||
table: entity_test_computed_field
|
||||
field: computed_string_field
|
||||
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: 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: entity_test_computed_field
|
||||
plugin_id: field
|
||||
filters: { }
|
||||
sorts: { }
|
||||
header: { }
|
||||
footer: { }
|
||||
empty: { }
|
||||
relationships: { }
|
||||
arguments: { }
|
||||
display_extenders: { }
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- url.query_args
|
||||
tags: { }
|
||||
page_1:
|
||||
display_plugin: page
|
||||
id: page_1
|
||||
display_title: Page
|
||||
position: 1
|
||||
display_options:
|
||||
display_extenders: { }
|
||||
path: foo
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- url.query_args
|
||||
tags: { }
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- user.role.authenticated
|
||||
module:
|
||||
- node
|
||||
- rest
|
||||
- user
|
||||
id: rest_export_with_authorization_correction
|
||||
label: 'Rest Export'
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: node_field_data
|
||||
base_field: nid
|
||||
core: 8.x
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 0
|
||||
display_options:
|
||||
access:
|
||||
type: role
|
||||
options:
|
||||
role:
|
||||
authenticated: authenticated
|
||||
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: Filter
|
||||
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: full
|
||||
options:
|
||||
items_per_page: 10
|
||||
offset: 0
|
||||
id: 0
|
||||
total_pages: null
|
||||
expose:
|
||||
items_per_page: false
|
||||
items_per_page_label: 'Items per page'
|
||||
items_per_page_options: '5, 10, 25, 50'
|
||||
items_per_page_options_all: false
|
||||
items_per_page_options_all_label: '- All -'
|
||||
offset: false
|
||||
offset_label: Offset
|
||||
tags:
|
||||
previous: '‹ Previous'
|
||||
next: 'Next ›'
|
||||
first: '« First'
|
||||
last: 'Last »'
|
||||
quantity: 9
|
||||
style:
|
||||
type: default
|
||||
row:
|
||||
type: 'fields'
|
||||
fields:
|
||||
title:
|
||||
id: title
|
||||
table: node_field_data
|
||||
field: title
|
||||
entity_type: node
|
||||
entity_field: title
|
||||
label: ''
|
||||
alter:
|
||||
alter_text: false
|
||||
make_link: false
|
||||
absolute: false
|
||||
trim: false
|
||||
word_boundary: false
|
||||
ellipsis: false
|
||||
strip_tags: false
|
||||
html: false
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
settings:
|
||||
link_to_entity: true
|
||||
plugin_id: field
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
exclude: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: true
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_alter_empty: true
|
||||
click_sort_column: value
|
||||
type: string
|
||||
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
|
||||
filters:
|
||||
status:
|
||||
id: status
|
||||
table: node_field_data
|
||||
field: status
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: '='
|
||||
value: '0'
|
||||
group: 1
|
||||
exposed: false
|
||||
expose:
|
||||
operator_id: ''
|
||||
label: ''
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: ''
|
||||
identifier: ''
|
||||
required: false
|
||||
remember: false
|
||||
multiple: false
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
is_grouped: false
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: true
|
||||
widget: select
|
||||
multiple: false
|
||||
remember: false
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
plugin_id: boolean
|
||||
entity_type: node
|
||||
entity_field: status
|
||||
sorts:
|
||||
created:
|
||||
id: created
|
||||
table: node_field_data
|
||||
field: created
|
||||
order: DESC
|
||||
entity_type: node
|
||||
entity_field: created
|
||||
plugin_id: date
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
exposed: false
|
||||
expose:
|
||||
label: ''
|
||||
granularity: second
|
||||
title: 'Rest Export'
|
||||
header: { }
|
||||
footer: { }
|
||||
empty: { }
|
||||
relationships: { }
|
||||
arguments: { }
|
||||
display_extenders: { }
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- url.query_args
|
||||
- 'user.node_grants:view'
|
||||
- user.roles
|
||||
tags: { }
|
||||
rest_export_1:
|
||||
display_plugin: rest_export
|
||||
id: rest_export_1
|
||||
display_title: 'REST export'
|
||||
position: 2
|
||||
display_options:
|
||||
display_extenders: { }
|
||||
path: unpublished-content
|
||||
auth:
|
||||
- user
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- request_format
|
||||
- 'user.node_grants:view'
|
||||
- user.roles
|
||||
tags: { }
|
||||
+225
@@ -0,0 +1,225 @@
|
||||
uuid: b133bd43-c494-4db6-83f0-24380fe3964b
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- user
|
||||
id: test_entity_row_renderers_revisions_base
|
||||
label: test_entity_row_renderers_revisions_base
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: node_field_revision
|
||||
base_field: vid
|
||||
core: 8.x
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 0
|
||||
display_options:
|
||||
access:
|
||||
type: perm
|
||||
options:
|
||||
perm: 'view all revisions'
|
||||
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_revision
|
||||
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: true
|
||||
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
|
||||
uid:
|
||||
id: uid
|
||||
table: users_field_data
|
||||
field: uid
|
||||
relationship: revision_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: number_integer
|
||||
settings:
|
||||
thousand_separator: ''
|
||||
prefix_suffix: true
|
||||
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: uid
|
||||
plugin_id: field
|
||||
filters: { }
|
||||
sorts: { }
|
||||
header: { }
|
||||
footer: { }
|
||||
empty: { }
|
||||
relationships:
|
||||
revision_uid:
|
||||
id: revision_uid
|
||||
table: node_revision
|
||||
field: revision_uid
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: 'revision user'
|
||||
required: false
|
||||
entity_type: node
|
||||
entity_field: revision_uid
|
||||
plugin_id: standard
|
||||
arguments: { }
|
||||
display_extenders: { }
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- 'user.node_grants:view'
|
||||
- user.permissions
|
||||
tags: { }
|
||||
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- taxonomy.vocabulary.test_exposed_checkboxes
|
||||
module:
|
||||
- node
|
||||
- taxonomy
|
||||
id: test_exposed_form_checkboxes
|
||||
label: ''
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: node_field_data
|
||||
base_field: nid
|
||||
core: '8'
|
||||
display:
|
||||
default:
|
||||
display_options:
|
||||
access:
|
||||
type: none
|
||||
cache:
|
||||
type: tag
|
||||
exposed_form:
|
||||
options:
|
||||
reset_button: true
|
||||
type: basic
|
||||
filters:
|
||||
type:
|
||||
id: type
|
||||
table: node_field_data
|
||||
field: type
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: in
|
||||
value: { }
|
||||
group: 1
|
||||
exposed: true
|
||||
expose:
|
||||
operator_id: type_op
|
||||
label: 'Content: Type'
|
||||
description: 'Exposed description'
|
||||
use_operator: false
|
||||
operator: ''
|
||||
identifier: type
|
||||
required: false
|
||||
remember: false
|
||||
multiple: true
|
||||
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: { }
|
||||
plugin_id: in_operator
|
||||
entity_type: node
|
||||
entity_field: type
|
||||
tid:
|
||||
id: tid
|
||||
table: taxonomy_index
|
||||
field: tid
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: and
|
||||
value: { }
|
||||
group: 1
|
||||
exposed: true
|
||||
expose:
|
||||
operator_id: tid_op
|
||||
label: 'Has taxonomy term'
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: tid_op
|
||||
identifier: tid
|
||||
required: false
|
||||
remember: false
|
||||
multiple: true
|
||||
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: { }
|
||||
reduce_duplicates: false
|
||||
type: select
|
||||
limit: true
|
||||
vid: test_exposed_checkboxes
|
||||
hierarchy: false
|
||||
error_message: true
|
||||
plugin_id: taxonomy_index_tid
|
||||
pager:
|
||||
type: full
|
||||
query:
|
||||
options:
|
||||
query_comment: ''
|
||||
type: views_query
|
||||
style:
|
||||
type: default
|
||||
row:
|
||||
type: 'entity:node'
|
||||
display_extenders: { }
|
||||
display_plugin: default
|
||||
display_title: Master
|
||||
id: default
|
||||
position: 0
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_interface'
|
||||
- url
|
||||
- url.query_args
|
||||
- user
|
||||
- 'user.node_grants:view'
|
||||
tags: { }
|
||||
page_1:
|
||||
display_options:
|
||||
path: test_exposed_form_checkboxes
|
||||
display_extenders: { }
|
||||
display_plugin: page
|
||||
display_title: Page
|
||||
id: page_1
|
||||
position: 0
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_interface'
|
||||
- url
|
||||
- url.query_args
|
||||
- user
|
||||
- 'user.node_grants:view'
|
||||
tags: { }
|
||||
+187
@@ -0,0 +1,187 @@
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: test_field_config_translation_filter
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: node_field_data
|
||||
base_field: id
|
||||
core: '8'
|
||||
display:
|
||||
default:
|
||||
display_options:
|
||||
access:
|
||||
type: none
|
||||
cache:
|
||||
type: none
|
||||
fields:
|
||||
nid:
|
||||
id: nid
|
||||
field: nid
|
||||
table: node_field_data
|
||||
plugin_id: field
|
||||
entity_type: node
|
||||
entity_field: nid
|
||||
langcode:
|
||||
id: langcode
|
||||
field: langcode
|
||||
table: node_field_data
|
||||
plugin_id: field
|
||||
entity_type: node
|
||||
entity_field: langcode
|
||||
field_name_1:
|
||||
id: field_name_1
|
||||
table: node__field_name_1
|
||||
field: field_name_1
|
||||
plugin_id: field
|
||||
entity_type: node
|
||||
entity_field: field_name_1
|
||||
field_name_2:
|
||||
id: field_name_2
|
||||
table: node__field_name_2
|
||||
field: field_name_2
|
||||
plugin_id: field
|
||||
entity_type: node
|
||||
entity_field: field_name_2
|
||||
field_name_3:
|
||||
id: field_name_3
|
||||
table: node__field_name_3
|
||||
field: field_name_3
|
||||
plugin_id: field
|
||||
entity_type: node
|
||||
entity_field: field_name_3
|
||||
sorts:
|
||||
nid:
|
||||
id: nid
|
||||
table: node_field_data
|
||||
field: nid
|
||||
order: ASC
|
||||
plugin_id: standard
|
||||
entity_type: node
|
||||
entity_field: nid
|
||||
langcode:
|
||||
id: langcode
|
||||
table: node_field_data
|
||||
field: langcode
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
order: ASC
|
||||
exposed: false
|
||||
expose:
|
||||
label: ''
|
||||
entity_type: node
|
||||
entity_field: langcode
|
||||
plugin_id: standard
|
||||
style:
|
||||
type: html_list
|
||||
row:
|
||||
type: fields
|
||||
display_plugin: default
|
||||
display_title: Master
|
||||
id: default
|
||||
position: 0
|
||||
embed_1:
|
||||
display_options:
|
||||
defaults:
|
||||
fields: true
|
||||
filters: false
|
||||
filters:
|
||||
field_name_1_value:
|
||||
id: field_name_1_value
|
||||
table: node__field_name_1
|
||||
field: field_name_1_value
|
||||
value: 'field name 1: es'
|
||||
plugin_id: string
|
||||
entity_type: node
|
||||
entity_field: field_name_1
|
||||
display_plugin: embed
|
||||
display_title: Embed 1
|
||||
id: embed_1
|
||||
position: 1
|
||||
embed_2:
|
||||
display_options:
|
||||
defaults:
|
||||
filters: false
|
||||
filters:
|
||||
field_name_1_value:
|
||||
id: field_name_1_value
|
||||
table: node__field_name_1
|
||||
field: field_name_1_value
|
||||
value: 'field name 1: fr'
|
||||
plugin_id: string
|
||||
entity_type: node
|
||||
entity_field: field_name_1
|
||||
display_plugin: embed
|
||||
display_title: Embed 2
|
||||
id: embed_2
|
||||
position: 2
|
||||
embed_3:
|
||||
display_options:
|
||||
defaults:
|
||||
filters: false
|
||||
filters:
|
||||
field_name_2_value:
|
||||
id: field_name_2_value
|
||||
table: node__field_name_2
|
||||
field: field_name_2_value
|
||||
value: 'field name 2: es'
|
||||
plugin_id: string
|
||||
entity_type: node
|
||||
entity_field: field_name_2
|
||||
display_plugin: embed
|
||||
display_title: Embed 3
|
||||
id: embed_3
|
||||
position: 3
|
||||
embed_4:
|
||||
display_options:
|
||||
defaults:
|
||||
filters: false
|
||||
filters:
|
||||
field_name_2_value:
|
||||
id: field_name_2_value
|
||||
table: node__field_name_2
|
||||
field: field_name_2_value
|
||||
value: 'field name 2: fr'
|
||||
plugin_id: string
|
||||
entity_type: node
|
||||
entity_field: field_name_2
|
||||
display_plugin: embed
|
||||
display_title: Embed 4
|
||||
id: embed_4
|
||||
position: 4
|
||||
embed_5:
|
||||
display_options:
|
||||
defaults:
|
||||
filters: false
|
||||
filters:
|
||||
field_name_3_value:
|
||||
id: field_name_3_value
|
||||
table: node__field_name_3
|
||||
field: field_name_3_value
|
||||
value: 'field name 3: es'
|
||||
plugin_id: string
|
||||
entity_type: node
|
||||
entity_field: field_name_3
|
||||
display_plugin: embed
|
||||
display_title: Embed 5
|
||||
id: embed_5
|
||||
position: 5
|
||||
embed_6:
|
||||
display_options:
|
||||
defaults:
|
||||
filters: false
|
||||
filters:
|
||||
field_name_3_value:
|
||||
id: field_name_3_value
|
||||
table: node__field_name_3
|
||||
field: field_name_3_value
|
||||
value: 'field name 3: fr'
|
||||
plugin_id: string
|
||||
entity_type: node
|
||||
entity_field: field_name_3
|
||||
display_plugin: embed
|
||||
display_title: Embed 6
|
||||
id: embed_6
|
||||
position: 6
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- node
|
||||
id: test_latest_revision_filter
|
||||
label: ''
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: node_field_revision
|
||||
base_field: vid
|
||||
core: 8.x
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 0
|
||||
display_options:
|
||||
access:
|
||||
type: none
|
||||
options: { }
|
||||
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:
|
||||
title:
|
||||
id: title
|
||||
table: node_field_revision
|
||||
field: title
|
||||
entity_type: node
|
||||
entity_field: title
|
||||
label: ''
|
||||
alter:
|
||||
alter_text: false
|
||||
make_link: false
|
||||
absolute: false
|
||||
trim: false
|
||||
word_boundary: false
|
||||
ellipsis: false
|
||||
strip_tags: false
|
||||
html: false
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
settings:
|
||||
link_to_entity: false
|
||||
plugin_id: field
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
exclude: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: true
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_alter_empty: true
|
||||
click_sort_column: value
|
||||
type: string
|
||||
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
|
||||
filters:
|
||||
latest_revision:
|
||||
id: latest_revision
|
||||
table: node_revision
|
||||
field: latest_revision
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: '='
|
||||
value: ''
|
||||
group: 1
|
||||
exposed: false
|
||||
expose:
|
||||
operator_id: ''
|
||||
label: ''
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: ''
|
||||
identifier: ''
|
||||
required: false
|
||||
remember: false
|
||||
multiple: false
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
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: latest_revision
|
||||
sorts: { }
|
||||
header: { }
|
||||
footer: { }
|
||||
empty: { }
|
||||
relationships: { }
|
||||
arguments: { }
|
||||
display_extenders: { }
|
||||
show_admin_links: false
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- 'user.node_grants:view'
|
||||
tags: { }
|
||||
-1
@@ -59,7 +59,6 @@ display:
|
||||
type: string
|
||||
settings:
|
||||
link_to_entity: true
|
||||
plugin_id: field
|
||||
filters:
|
||||
type:
|
||||
id: type
|
||||
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: test_view_sort_translation
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: node_field_data
|
||||
base_field: id
|
||||
core: '8'
|
||||
display:
|
||||
default:
|
||||
display_options:
|
||||
fields:
|
||||
nid:
|
||||
id: nid
|
||||
field: nid
|
||||
table: node_field_data
|
||||
plugin_id: field
|
||||
entity_type: node
|
||||
entity_field: nid
|
||||
langcode:
|
||||
id: langcode
|
||||
field: langcode
|
||||
table: node_field_data
|
||||
plugin_id: field
|
||||
entity_type: node
|
||||
entity_field: langcode
|
||||
weight:
|
||||
id: weight
|
||||
table: node__weight
|
||||
field: weight
|
||||
plugin_id: numeric
|
||||
entity_type: node
|
||||
entity_field: weight
|
||||
filters:
|
||||
langcode:
|
||||
id: langcode
|
||||
table: node_field_data
|
||||
field: langcode
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: in
|
||||
value:
|
||||
'en': 'en'
|
||||
group: 1
|
||||
exposed: false
|
||||
entity_type: node
|
||||
entity_field: langcode
|
||||
plugin_id: language
|
||||
sorts:
|
||||
weight:
|
||||
id: weight
|
||||
table: node__weight
|
||||
field: weight_value
|
||||
order: ASC
|
||||
plugin_id: standard
|
||||
entity_type: node
|
||||
entity_field: weight
|
||||
display_plugin: default
|
||||
display_title: Master
|
||||
id: default
|
||||
position: 0
|
||||
display_de:
|
||||
display_plugin: embed
|
||||
id: display_de
|
||||
display_options:
|
||||
defaults:
|
||||
filters: false
|
||||
filters:
|
||||
langcode:
|
||||
id: langcode
|
||||
table: node_field_data
|
||||
field: langcode
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: in
|
||||
value:
|
||||
'de': 'de'
|
||||
group: 1
|
||||
exposed: false
|
||||
entity_type: node
|
||||
entity_field: langcode
|
||||
plugin_id: language
|
||||
@@ -7,8 +7,8 @@ package: Testing
|
||||
dependencies:
|
||||
- views
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\views_test_data\Plugin\views\argument_validator;
|
||||
|
||||
use Drupal\views\Plugin\views\argument_validator\ArgumentValidatorPluginBase;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* Just a placeholder file for the test.
|
||||
*
|
||||
* @see ViewsCacheTest::testHeaderStorage
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* @file
|
||||
* Just a placeholder file for the test.
|
||||
*
|
||||
* @see ViewsCacheTest::testHeaderStorage
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
@@ -7,8 +7,8 @@ package: Testing
|
||||
dependencies:
|
||||
- views
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
@@ -7,8 +7,8 @@ package: Testing
|
||||
dependencies:
|
||||
- views
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
@@ -8,8 +8,8 @@ dependencies:
|
||||
- views
|
||||
- language
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
@@ -100,6 +100,15 @@ class DefaultViewsTest extends ViewTestBase {
|
||||
'field_name' => 'comment'
|
||||
];
|
||||
Comment::create($comment)->save();
|
||||
|
||||
$unpublished_comment = [
|
||||
'uid' => $user->id(),
|
||||
'status' => CommentInterface::NOT_PUBLISHED,
|
||||
'entity_id' => $node->id(),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'comment',
|
||||
];
|
||||
Comment::create($unpublished_comment)->save();
|
||||
}
|
||||
|
||||
// Some views, such as the "Who's Online" view, only return results if at
|
||||
@@ -165,16 +174,19 @@ class DefaultViewsTest extends ViewTestBase {
|
||||
// Create additional nodes compared to the one in the setup method.
|
||||
// Create two nodes in the same month, and one in each following month.
|
||||
$node = [
|
||||
'created' => 280299600, // Sun, 19 Nov 1978 05:00:00 GMT
|
||||
// Sun, 19 Nov 1978 05:00:00 GMT.
|
||||
'created' => 280299600,
|
||||
];
|
||||
$this->drupalCreateNode($node);
|
||||
$this->drupalCreateNode($node);
|
||||
$node = [
|
||||
'created' => 282891600, // Tue, 19 Dec 1978 05:00:00 GMT
|
||||
// Tue, 19 Dec 1978 05:00:00 GMT.
|
||||
'created' => 282891600,
|
||||
];
|
||||
$this->drupalCreateNode($node);
|
||||
$node = [
|
||||
'created' => 285570000, // Fri, 19 Jan 1979 05:00:00 GMT
|
||||
// Fri, 19 Jan 1979 05:00:00 GMT.
|
||||
'created' => 285570000,
|
||||
];
|
||||
$this->drupalCreateNode($node);
|
||||
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Functional\Entity;
|
||||
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\Tests\views\Functional\ViewTestBase;
|
||||
use Drupal\views\ViewExecutable;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Tests the 'Latest revision' filter.
|
||||
*
|
||||
* @group views
|
||||
*/
|
||||
class LatestRevisionFilterTest extends ViewTestBase {
|
||||
|
||||
/**
|
||||
* An array of node revisions.
|
||||
*
|
||||
* @var \Drupal\node\NodeInterface[]
|
||||
*/
|
||||
protected $allRevisions = [];
|
||||
|
||||
/**
|
||||
* An array of node revisions.
|
||||
*
|
||||
* @var \Drupal\node\NodeInterface[]
|
||||
*/
|
||||
protected $latestRevisions = [];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = ['test_latest_revision_filter'];
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['node'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalCreateContentType(['type' => 'article']);
|
||||
|
||||
// Create a node that goes through various default/pending revision stages.
|
||||
$node = Node::create([
|
||||
'title' => 'First node - v1 - default',
|
||||
'type' => 'article',
|
||||
]);
|
||||
$node->save();
|
||||
$this->allRevisions[$node->getRevisionId()] = $node;
|
||||
|
||||
$node->setTitle('First node - v2 - pending');
|
||||
$node->setNewRevision(TRUE);
|
||||
$node->isDefaultRevision(FALSE);
|
||||
$node->save();
|
||||
$this->allRevisions[$node->getRevisionId()] = $node;
|
||||
|
||||
$node->setTitle('First node - v3 - default');
|
||||
$node->setNewRevision(TRUE);
|
||||
$node->isDefaultRevision(TRUE);
|
||||
$node->save();
|
||||
$this->allRevisions[$node->getRevisionId()] = $node;
|
||||
|
||||
$node->setTitle('First node - v4 - pending');
|
||||
$node->setNewRevision(TRUE);
|
||||
$node->isDefaultRevision(TRUE);
|
||||
$node->save();
|
||||
$this->allRevisions[$node->getRevisionId()] = $node;
|
||||
$this->latestRevisions[$node->getRevisionId()] = $node;
|
||||
|
||||
// Create a node that has a default and a pending revision.
|
||||
$node = Node::create([
|
||||
'title' => 'Second node - v1 - default',
|
||||
'type' => 'article',
|
||||
]);
|
||||
$node->save();
|
||||
$this->allRevisions[$node->getRevisionId()] = $node;
|
||||
|
||||
$node->setTitle('Second node - v2 - pending');
|
||||
$node->setNewRevision(TRUE);
|
||||
$node->isDefaultRevision(FALSE);
|
||||
$node->save();
|
||||
$this->allRevisions[$node->getRevisionId()] = $node;
|
||||
$this->latestRevisions[$node->getRevisionId()] = $node;
|
||||
|
||||
// Create a node that only has a default revision.
|
||||
$node = Node::create([
|
||||
'title' => 'Third node - v1 - default',
|
||||
'type' => 'article',
|
||||
]);
|
||||
$node->save();
|
||||
$this->allRevisions[$node->getRevisionId()] = $node;
|
||||
$this->latestRevisions[$node->getRevisionId()] = $node;
|
||||
|
||||
// Create a node that only has a pending revision.
|
||||
$node = Node::create([
|
||||
'title' => 'Fourth node - v1 - pending',
|
||||
'type' => 'article',
|
||||
]);
|
||||
$node->isDefaultRevision(FALSE);
|
||||
$node->save();
|
||||
$this->allRevisions[$node->getRevisionId()] = $node;
|
||||
$this->latestRevisions[$node->getRevisionId()] = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the 'Latest revision' filter.
|
||||
*/
|
||||
public function testLatestRevisionFilter() {
|
||||
$view = Views::getView('test_latest_revision_filter');
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
// Check that we have all the results.
|
||||
$this->assertCount(count($this->latestRevisions), $view->result);
|
||||
|
||||
$expected = $not_expected = [];
|
||||
foreach ($this->allRevisions as $revision_id => $revision) {
|
||||
if (isset($this->latestRevisions[$revision_id])) {
|
||||
$expected[] = [
|
||||
'vid' => $revision_id,
|
||||
'title' => $revision->label(),
|
||||
];
|
||||
}
|
||||
else {
|
||||
$not_expected[] = $revision_id;
|
||||
}
|
||||
}
|
||||
$this->assertIdenticalResultset($view, $expected, ['vid' => 'vid', 'title' => 'title'], 'The test view only shows the latest revisions.');
|
||||
$this->assertNotInResultSet($view, $not_expected, 'Non-latest revisions are not shown by the view.');
|
||||
$view->destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a list of revision IDs are not in the result.
|
||||
*
|
||||
* @param \Drupal\views\ViewExecutable $view
|
||||
* An executed View.
|
||||
* @param array $not_expected_revision_ids
|
||||
* An array of revision IDs which should not be part of the result set.
|
||||
* @param string $message
|
||||
* (optional) A custom message to display with the assertion.
|
||||
*/
|
||||
protected function assertNotInResultSet(ViewExecutable $view, array $not_expected_revision_ids, $message = '') {
|
||||
$found_revision_ids = array_filter($view->result, function ($row) use ($not_expected_revision_ids) {
|
||||
return in_array($row->vid, $not_expected_revision_ids);
|
||||
});
|
||||
$this->assertFalse($found_revision_ids, $message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,7 +7,7 @@ use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Component\Utility\UrlHelper;
|
||||
use Drupal\Core\Render\RenderContext;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
|
||||
use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
|
||||
use Drupal\Tests\views\Functional\ViewTestBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ use Drupal\views\Views;
|
||||
use Drupal\views_test_data\Plugin\views\argument_default\ArgumentDefaultTest as ArgumentDefaultTestPlugin;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
|
||||
/**
|
||||
* Tests pluggable argument_default for views.
|
||||
*
|
||||
@@ -131,7 +130,7 @@ class ArgumentDefaultTest extends ViewTestBase {
|
||||
/**
|
||||
* @todo Test php default argument.
|
||||
*/
|
||||
//function testArgumentDefaultPhp() {}
|
||||
// function testArgumentDefaultPhp() {}
|
||||
|
||||
/**
|
||||
* Test node default argument.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Drupal\Tests\views\Functional\Plugin;
|
||||
|
||||
use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
|
||||
use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
|
||||
use Drupal\Tests\views\Functional\ViewTestBase;
|
||||
use Drupal\views\Plugin\views\display\DisplayPluginBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
+1
-1
@@ -3,9 +3,9 @@
|
||||
namespace Drupal\Tests\views\Functional\Plugin;
|
||||
|
||||
use Drupal\Core\Plugin\Context\ContextDefinitionInterface;
|
||||
use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
|
||||
use Drupal\Tests\views\Functional\ViewTestBase;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
|
||||
|
||||
/**
|
||||
* A test for contextual filters exposed as block context.
|
||||
|
||||
@@ -249,6 +249,12 @@ class DisplayEntityReferenceTest extends ViewTestBase {
|
||||
$this->executeView($view);
|
||||
|
||||
$this->assertEqual(count($view->result), 2, 'Search returned two rows');
|
||||
|
||||
// Test that the render() return empty array for empty result.
|
||||
$view = Views::getView('test_display_entity_reference');
|
||||
$view->setDisplay('entity_reference_1');
|
||||
$render = $view->display_handler->render();
|
||||
$this->assertSame([], $render, 'Render returned empty array');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Drupal\Tests\views\Functional\Plugin;
|
||||
|
||||
use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
|
||||
use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
|
||||
use Drupal\Tests\views\Functional\ViewTestBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Functional\Plugin;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
use Drupal\Tests\views\Functional\ViewTestBase;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Tests exposed forms functionality.
|
||||
*
|
||||
* @group views
|
||||
*/
|
||||
class ExposedFormCheckboxesTest extends ViewTestBase {
|
||||
|
||||
use EntityReferenceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $testViews = ['test_exposed_form_checkboxes'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node', 'views_ui', 'taxonomy'];
|
||||
|
||||
/**
|
||||
* Test terms.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $terms = [];
|
||||
|
||||
/**
|
||||
* Vocabulary for testing checkbox options.
|
||||
*
|
||||
* @var \Drupal\taxonomy\Entity\Vocabulary
|
||||
*/
|
||||
public $vocabulary;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp(FALSE);
|
||||
|
||||
// Create a vocabulary and entity reference field so we can test the "is all
|
||||
// of" filter operator. Must be done ahead of the view import so the
|
||||
// vocabulary is in place to meet the view dependencies.
|
||||
$vocabulary = Vocabulary::create([
|
||||
'name' => 'test_exposed_checkboxes',
|
||||
'vid' => 'test_exposed_checkboxes',
|
||||
'nodes' => ['article' => 'article'],
|
||||
]);
|
||||
$vocabulary->save();
|
||||
$this->vocabulary = $vocabulary;
|
||||
|
||||
ViewTestData::createTestViews(self::class, ['views_test_config']);
|
||||
$this->enableViewsTestModule();
|
||||
|
||||
// Create two content types.
|
||||
$this->drupalCreateContentType(['type' => 'article']);
|
||||
$this->drupalCreateContentType(['type' => 'page']);
|
||||
|
||||
// Create some random nodes: 5 articles, one page.
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$this->drupalCreateNode(['type' => 'article']);
|
||||
}
|
||||
$this->drupalCreateNode(['type' => 'page']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests overriding the default render option with checkboxes.
|
||||
*/
|
||||
public function testExposedFormRenderCheckboxes() {
|
||||
// Use a test theme to convert multi-select elements into checkboxes.
|
||||
\Drupal::service('theme_handler')->install(['views_test_checkboxes_theme']);
|
||||
$this->config('system.theme')
|
||||
->set('default', 'views_test_checkboxes_theme')
|
||||
->save();
|
||||
|
||||
// Only display 5 items per page so we can test that paging works.
|
||||
$view = Views::getView('test_exposed_form_checkboxes');
|
||||
$display = &$view->storage->getDisplay('default');
|
||||
$display['display_options']['pager']['options']['items_per_page'] = 5;
|
||||
|
||||
$view->save();
|
||||
$this->drupalGet('test_exposed_form_checkboxes');
|
||||
|
||||
$actual = $this->xpath('//form//input[@type="checkbox" and @name="type[article]"]');
|
||||
$this->assertEqual(count($actual), 1, 'Article option renders as a checkbox.');
|
||||
$actual = $this->xpath('//form//input[@type="checkbox" and @name="type[page]"]');
|
||||
$this->assertEqual(count($actual), 1, 'Page option renders as a checkbox');
|
||||
|
||||
// Ensure that all results are displayed.
|
||||
$rows = $this->xpath("//div[contains(@class, 'views-row')]");
|
||||
$this->assertEqual(count($rows), 5, '5 rows are displayed by default on the first page when no options are checked.');
|
||||
|
||||
$this->clickLink('Page 2');
|
||||
$rows = $this->xpath("//div[contains(@class, 'views-row')]");
|
||||
$this->assertEqual(count($rows), 1, '1 row is displayed by default on the second page when no options are checked.');
|
||||
$this->assertNoText('An illegal choice has been detected. Please contact the site administrator.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that "is all of" filters work with checkboxes.
|
||||
*/
|
||||
public function testExposedIsAllOfFilter() {
|
||||
foreach (['Term 1', 'Term 2', 'Term 3'] as $term_name) {
|
||||
// Add a few terms to the new vocabulary.
|
||||
$term = Term::create([
|
||||
'name' => $term_name,
|
||||
'vid' => $this->vocabulary->id(),
|
||||
]);
|
||||
$term->save();
|
||||
$this->terms[] = $term;
|
||||
}
|
||||
|
||||
// Create a field.
|
||||
$field_name = Unicode::strtolower($this->randomMachineName());
|
||||
$handler_settings = [
|
||||
'target_bundles' => [
|
||||
$this->vocabulary->id() => $this->vocabulary->id(),
|
||||
],
|
||||
'auto_create' => FALSE,
|
||||
];
|
||||
$this->createEntityReferenceField('node', 'article', $field_name, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
|
||||
|
||||
// Add some test nodes.
|
||||
$this->createNode([
|
||||
'type' => 'article',
|
||||
$field_name => [$this->terms[0]->id(), $this->terms[1]->id()],
|
||||
]);
|
||||
$this->createNode([
|
||||
'type' => 'article',
|
||||
$field_name => [$this->terms[0]->id(), $this->terms[2]->id()],
|
||||
]);
|
||||
|
||||
// Use a test theme to convert multi-select elements into checkboxes.
|
||||
\Drupal::service('theme_handler')->install(['views_test_checkboxes_theme']);
|
||||
$this->config('system.theme')
|
||||
->set('default', 'views_test_checkboxes_theme')
|
||||
->save();
|
||||
|
||||
$this->drupalGet('test_exposed_form_checkboxes');
|
||||
|
||||
// Ensure that all results are displayed.
|
||||
$rows = $this->xpath("//div[contains(@class, 'views-row')]");
|
||||
$this->assertEqual(count($rows), 8, 'All rows are displayed by default on the first page when no options are checked.');
|
||||
$this->assertNoText('An illegal choice has been detected. Please contact the site administrator.');
|
||||
|
||||
// Select one option and ensure we still have results.
|
||||
$tid = $this->terms[0]->id();
|
||||
$this->drupalPostForm(NULL, ["tid[$tid]" => $tid], t('Apply'));
|
||||
|
||||
// Ensure only nodes tagged with $tid are displayed.
|
||||
$rows = $this->xpath("//div[contains(@class, 'views-row')]");
|
||||
$this->assertEqual(count($rows), 2, 'Correct rows are displayed when a tid is selected.');
|
||||
$this->assertNoText('An illegal choice has been detected. Please contact the site administrator.');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace Drupal\Tests\views\Functional\Plugin;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
|
||||
use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
|
||||
use Drupal\Tests\views\Functional\ViewTestBase;
|
||||
use Drupal\views\ViewExecutable;
|
||||
use Drupal\views\Views;
|
||||
@@ -191,48 +191,6 @@ class ExposedFormTest extends ViewTestBase {
|
||||
$this->helperButtonHasLabel('edit-reset', $expected_label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests overriding the default render option with checkboxes.
|
||||
*/
|
||||
public function testExposedFormRenderCheckboxes() {
|
||||
// Make sure we have at least two options for node type.
|
||||
$this->drupalCreateContentType(['type' => 'page']);
|
||||
$this->drupalCreateNode(['type' => 'page']);
|
||||
|
||||
// Use a test theme to convert multi-select elements into checkboxes.
|
||||
\Drupal::service('theme_handler')->install(['views_test_checkboxes_theme']);
|
||||
$this->config('system.theme')
|
||||
->set('default', 'views_test_checkboxes_theme')
|
||||
->save();
|
||||
|
||||
// Set the "type" filter to multi-select.
|
||||
$view = Views::getView('test_exposed_form_buttons');
|
||||
$filter = $view->getHandler('page_1', 'filter', 'type');
|
||||
$filter['expose']['multiple'] = TRUE;
|
||||
$view->setHandler('page_1', 'filter', 'type', $filter);
|
||||
|
||||
// Only display 5 items per page so we can test that paging works.
|
||||
$display = &$view->storage->getDisplay('default');
|
||||
$display['display_options']['pager']['options']['items_per_page'] = 5;
|
||||
|
||||
$view->save();
|
||||
$this->drupalGet('test_exposed_form_buttons');
|
||||
|
||||
$actual = $this->xpath('//form//input[@type="checkbox" and @name="type[article]"]');
|
||||
$this->assertEqual(count($actual), 1, 'Article option renders as a checkbox.');
|
||||
$actual = $this->xpath('//form//input[@type="checkbox" and @name="type[page]"]');
|
||||
$this->assertEqual(count($actual), 1, 'Page option renders as a checkbox');
|
||||
|
||||
// Ensure that all results are displayed.
|
||||
$rows = $this->xpath("//div[contains(@class, 'views-row')]");
|
||||
$this->assertEqual(count($rows), 5, '5 rows are displayed by default on the first page when no options are checked.');
|
||||
|
||||
$this->clickLink('Page 2');
|
||||
$rows = $this->xpath("//div[contains(@class, 'views-row')]");
|
||||
$this->assertEqual(count($rows), 1, '1 row is displayed by default on the second page when no options are checked.');
|
||||
$this->assertNoText('An illegal choice has been detected. Please contact the site administrator.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the exposed block functionality.
|
||||
*/
|
||||
@@ -320,8 +278,7 @@ class ExposedFormTest extends ViewTestBase {
|
||||
*/
|
||||
public function testExposedSortAndItemsPerPage() {
|
||||
for ($i = 0; $i < 50; $i++) {
|
||||
$entity = EntityTest::create([
|
||||
]);
|
||||
$entity = EntityTest::create([]);
|
||||
$entity->save();
|
||||
}
|
||||
$contexts = [
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Drupal\Tests\views\Functional\Plugin;
|
||||
|
||||
use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
|
||||
use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
|
||||
use Drupal\Tests\views\Functional\ViewTestBase;
|
||||
use Drupal\views\Views;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
@@ -93,7 +93,7 @@ class PagerTest extends ViewTestBase {
|
||||
$this->assertText('20 items');
|
||||
|
||||
// add new display and test the settings again, by override it.
|
||||
$edit = [ ];
|
||||
$edit = [];
|
||||
// Add a display and override the pager settings.
|
||||
$this->drupalPostForm('admin/structure/views/view/test_store_pager_settings/edit', $edit, t('Add Page'));
|
||||
$edit = [
|
||||
|
||||
@@ -54,6 +54,9 @@ class StyleSummaryTest extends ViewTestBase {
|
||||
public function testSummaryView() {
|
||||
$this->drupalGet('test-summary');
|
||||
|
||||
// Ensure styles are properly added for summary views.
|
||||
$this->assertRaw('stable/css/views/views.module.css');
|
||||
|
||||
$summary_list = $this->cssSelect('ul.views-summary li');
|
||||
$this->assertEqual(4, count($summary_list));
|
||||
|
||||
|
||||
@@ -70,9 +70,9 @@ class ViewsBulkTest extends ViewTestBase {
|
||||
|
||||
// Create third node now that the admin overview has been rendered.
|
||||
$node_3 = $this->drupalCreateNode([
|
||||
'type' => 'page',
|
||||
'title' => 'The third node']
|
||||
);
|
||||
'type' => 'page',
|
||||
'title' => 'The third node',
|
||||
]);
|
||||
|
||||
// Now click 'Apply to selected items' and assert the second node is
|
||||
// selected on the confirm form.
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Functional\Update;
|
||||
|
||||
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
use Drupal\views\Entity\View;
|
||||
|
||||
/**
|
||||
* Tests the argument placeholder update path.
|
||||
*
|
||||
* @see views_update_8002()
|
||||
*
|
||||
* @group views
|
||||
*/
|
||||
class ArgumentPlaceholderUpdatePathTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
|
||||
__DIR__ . '/../../../fixtures/update/argument-placeholder.php'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that %1 and !1 are converted to twig tokens in existing views.
|
||||
*/
|
||||
public function testArgumentPlaceholderUpdate() {
|
||||
$this->runUpdates();
|
||||
$view = View::load('test_token_view');
|
||||
|
||||
$data = $view->toArray();
|
||||
$this->assertEqual('{{ arguments.nid }}-test-class-{{ raw_arguments.nid }}', $data['display']['default']['display_options']['style']['options']['col_class_custom']);
|
||||
$this->assertEqual('{{ arguments.nid }}-test-class-{{ raw_arguments.nid }}', $data['display']['default']['display_options']['style']['options']['row_class_custom']);
|
||||
$this->assertEqual('{{ arguments.nid }}-description-{{ raw_arguments.nid }}', $data['display']['feed_1']['display_options']['style']['options']['description']);
|
||||
$this->assertEqual('{{ arguments.nid }}-custom-text-{{ raw_arguments.nid }}', $data['display']['default']['display_options']['fields']['title']['alter']['text']);
|
||||
$this->assertEqual('test_token_view {{ arguments.nid }} {{ raw_arguments.nid }}', $data['display']['default']['display_options']['title']);
|
||||
$this->assertEqual('{{ arguments.nid }}-custom-{{ raw_arguments.nid }}', $data['display']['default']['display_options']['header']['area_text_custom']['content']);
|
||||
$this->assertEqual('{{ arguments.nid }}-text-{{ raw_arguments.nid }}', $data['display']['default']['display_options']['footer']['area']['content']['value']);
|
||||
$this->assertEqual("Displaying @start - @end of @total\n\n{{ arguments.nid }}-result-{{ raw_arguments.nid }}", $data['display']['default']['display_options']['empty']['result']['content']);
|
||||
$this->assertEqual('{{ arguments.nid }}-title-{{ raw_arguments.nid }}', $data['display']['default']['display_options']['empty']['title']['title']);
|
||||
$this->assertEqual('{{ arguments.nid }}-entity-{{ raw_arguments.nid }}', $data['display']['default']['display_options']['empty']['entity_node']['target']);
|
||||
$this->assertEqual('{{ arguments.nid }} title {{ raw_arguments.nid }}', $data['display']['default']['display_options']['arguments']['nid']['title']);
|
||||
$this->assertEqual('{{ arguments.nid }} exception-title {{ raw_arguments.nid }}', $data['display']['default']['display_options']['arguments']['nid']['exception']['title']);
|
||||
$this->assertEqual('{{ arguments.nid }}-more-text-{{ raw_arguments.nid }}', $data['display']['default']['display_options']['use_more_text']);
|
||||
$this->assertEqual('{{ arguments.nid }}-custom-url-{{ raw_arguments.nid }}', $data['display']['default']['display_options']['link_url']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Functional\Update;
|
||||
|
||||
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
use Drupal\views\Entity\View;
|
||||
|
||||
/**
|
||||
* Tests the upgrade path for boolean field values.
|
||||
*
|
||||
* @see views_post_update_boolean_filter_values()
|
||||
*
|
||||
* @group Update
|
||||
*/
|
||||
class BooleanFilterValuesUpdateTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
|
||||
__DIR__ . '/../../../fixtures/update/boolean-filter-values.php',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that boolean filter values are updated properly.
|
||||
*/
|
||||
public function testViewsPostUpdateBooleanFilterValues() {
|
||||
$this->runUpdates();
|
||||
|
||||
// Load and initialize our test view.
|
||||
$view = View::load('test_boolean_filter_values');
|
||||
$data = $view->toArray();
|
||||
// Check that the field is using the expected string value.
|
||||
$this->assertIdentical('1', $data['display']['default']['display_options']['filters']['status']['value']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Functional\Update;
|
||||
|
||||
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Tests that views cacheability metadata post update hook runs properly.
|
||||
*
|
||||
* @see views_post_update_update_cacheability_metadata().
|
||||
*
|
||||
* @group Update
|
||||
*/
|
||||
class CacheabilityMetadataUpdateTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that views cacheability metadata updated properly.
|
||||
*/
|
||||
public function testUpdateHookN() {
|
||||
$this->runUpdates();
|
||||
foreach (Views::getAllViews() as $view) {
|
||||
$displays = $view->get('display');
|
||||
foreach (array_keys($displays) as $display_id) {
|
||||
$display = $view->getDisplay($display_id);
|
||||
$this->assertFalse(isset($display['cache_metadata']['cacheable']));
|
||||
$this->assertTrue(isset($display['cache_metadata']['contexts']));
|
||||
$this->assertTrue(isset($display['cache_metadata']['max-age']));
|
||||
$this->assertTrue(isset($display['cache_metadata']['tags']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Functional\Update;
|
||||
|
||||
/**
|
||||
* Runs EntityViewsDataUpdateTest with a dump filled with content.
|
||||
*
|
||||
* @group Update
|
||||
*/
|
||||
class EntityViewsDataUpdateFilledTest extends EntityViewsDataUpdateTest {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
parent::setDatabaseDumpFiles();
|
||||
$this->databaseDumpFiles[0] = __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.filled.standard.php.gz';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Functional\Update;
|
||||
|
||||
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Tests the upgrade path for views field plugins.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2455125
|
||||
*
|
||||
* @group Update
|
||||
*/
|
||||
class EntityViewsDataUpdateTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
|
||||
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.views-entity-views-data-2455125.php',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that field plugins are updated properly.
|
||||
*/
|
||||
public function testUpdateHookN() {
|
||||
$this->runUpdates();
|
||||
|
||||
// Load and initialize our test view.
|
||||
$view = Views::getView('update_test');
|
||||
$view->initHandlers();
|
||||
|
||||
// Extract the fields from the test view that were updated.
|
||||
/** @var \Drupal\views\Plugin\views\field\EntityField $field */
|
||||
$created = $view->field['created'];
|
||||
/** @var \Drupal\views\Plugin\views\field\EntityField $field */
|
||||
$created_1 = $view->field['created_1'];
|
||||
/** @var \Drupal\views\Plugin\views\field\EntityField $field */
|
||||
$created_2 = $view->field['created_2'];
|
||||
|
||||
// Make sure the plugins were converted from date to field.
|
||||
$this->assertEqual($created->getPluginId(), 'field', 'created has correct plugin_id');
|
||||
$this->assertEqual($created_1->getPluginId(), 'field', 'created has correct plugin_id');
|
||||
$this->assertEqual($created_2->getPluginId(), 'field', 'created has correct plugin_id');
|
||||
|
||||
// Check options on 'created'.
|
||||
$options = $created->options;
|
||||
$this->assertEqual($options['type'], 'timestamp');
|
||||
$this->assertFalse(array_key_exists('date_format', $options));
|
||||
$this->assertFalse(array_key_exists('custom_date_format', $options));
|
||||
$this->assertFalse(array_key_exists('timezone', $options));
|
||||
$this->assertEqual($options['settings']['date_format'], 'long');
|
||||
$this->assertEqual($options['settings']['custom_date_format'], '');
|
||||
$this->assertEqual($options['settings']['timezone'], 'Africa/Abidjan');
|
||||
|
||||
// Check options on 'created'.
|
||||
$options = $created_1->options;
|
||||
$this->assertEqual($options['type'], 'timestamp_ago');
|
||||
$this->assertFalse(array_key_exists('date_format', $options));
|
||||
$this->assertFalse(array_key_exists('custom_date_format', $options));
|
||||
$this->assertFalse(array_key_exists('timezone', $options));
|
||||
$this->assertEqual($options['settings']['future_format'], '@interval');
|
||||
$this->assertEqual($options['settings']['past_format'], '@interval');
|
||||
$this->assertEqual($options['settings']['granularity'], 2);
|
||||
|
||||
// Check options on 'created'.
|
||||
$options = $created_2->options;
|
||||
$this->assertEqual($options['type'], 'timestamp_ago');
|
||||
$this->assertFalse(array_key_exists('date_format', $options));
|
||||
$this->assertFalse(array_key_exists('custom_date_format', $options));
|
||||
$this->assertFalse(array_key_exists('timezone', $options));
|
||||
$this->assertEqual($options['settings']['future_format'], '@interval hence');
|
||||
$this->assertEqual($options['settings']['past_format'], '@interval ago');
|
||||
$this->assertEqual($options['settings']['granularity'], 2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Functional\Update;
|
||||
|
||||
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
use Drupal\views\Entity\View;
|
||||
|
||||
/**
|
||||
* Tests the upgrade path for views field handlers.
|
||||
*
|
||||
* @see views_post_update_cleanup_duplicate_views_data()
|
||||
*
|
||||
* @group Update
|
||||
*/
|
||||
class FieldHandlersUpdateTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
|
||||
__DIR__ . '/../../../fixtures/update/duplicate-field-handler.php',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that field handlers are updated properly.
|
||||
*/
|
||||
public function testViewsUpdate8004() {
|
||||
$this->runUpdates();
|
||||
|
||||
// Load and initialize our test view.
|
||||
$view = View::load('test_duplicate_field_handlers');
|
||||
$data = $view->toArray();
|
||||
// Check that the field is using the expected base table.
|
||||
$this->assertEqual('node_field_data', $data['display']['default']['display_options']['fields']['nid']['table']);
|
||||
$this->assertEqual('node_field_data', $data['display']['default']['display_options']['filters']['type']['table']);
|
||||
$this->assertEqual('node_field_data', $data['display']['default']['display_options']['sorts']['vid']['table']);
|
||||
$this->assertEqual('node_field_data', $data['display']['default']['display_options']['arguments']['nid']['table']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Functional\Update;
|
||||
|
||||
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
use Drupal\views\Entity\View;
|
||||
|
||||
/**
|
||||
* Tests Views image style dependencies update.
|
||||
*
|
||||
* @group views
|
||||
*/
|
||||
class ImageStyleDependencyUpdateTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz',
|
||||
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal8.views-image-style-dependency-2649914.php',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the updating of views dependencies to image styles.
|
||||
*/
|
||||
public function testUpdateImageStyleDependencies() {
|
||||
$config_dependencies = View::load('foo')->getDependencies()['config'];
|
||||
|
||||
// Checks that 'thumbnail' image style is not a dependency of view 'foo'.
|
||||
$this->assertFalse(in_array('image.style.thumbnail', $config_dependencies));
|
||||
|
||||
// We test the case the the field formatter image style doesn't exist.
|
||||
// Checks that 'nonexistent' image style is not a dependency of view 'foo'.
|
||||
$this->assertFalse(in_array('image.style.nonexistent', $config_dependencies));
|
||||
|
||||
// Run updates.
|
||||
$this->runUpdates();
|
||||
|
||||
$config_dependencies = View::load('foo')->getDependencies()['config'];
|
||||
|
||||
// Checks that 'thumbnail' image style is a dependency of view 'foo'.
|
||||
$this->assertTrue(in_array('image.style.thumbnail', $config_dependencies));
|
||||
|
||||
// The 'nonexistent' style doesn't exist, thus is not a dependency. Checks
|
||||
// that 'nonexistent' image style is a not dependency of view 'foo'.
|
||||
$this->assertFalse(in_array('image.style.nonexistent', $config_dependencies));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Functional;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Tests the view render element.
|
||||
*
|
||||
* @group views
|
||||
*/
|
||||
class ViewElementTest extends ViewTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = ['test_view_embed'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$this->enableViewsTestModule();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the rendered output and form output of a view element.
|
||||
*/
|
||||
public function testViewElement() {
|
||||
$view = Views::getView('test_view_embed');
|
||||
$view->setDisplay();
|
||||
// Test a form.
|
||||
$this->drupalGet('views_test_data_element_form');
|
||||
|
||||
$xpath = $this->xpath('//div[@class="views-element-container js-form-wrapper form-wrapper"]');
|
||||
$this->assertTrue($xpath, 'The view container has been found on the form.');
|
||||
|
||||
$xpath = $this->xpath('//div[@class="view-content"]');
|
||||
$this->assertTrue($xpath, 'The view content has been found on the form.');
|
||||
// There should be 5 rows in the results.
|
||||
$xpath = $this->xpath('//div[@class="view-content"]/div');
|
||||
$this->assertEqual(count($xpath), 5);
|
||||
|
||||
// Add an argument and save the view.
|
||||
$view->displayHandlers->get('default')->overrideOption('arguments', [
|
||||
'age' => [
|
||||
'default_action' => 'ignore',
|
||||
'title' => '',
|
||||
'default_argument_type' => 'fixed',
|
||||
'validate' => [
|
||||
'type' => 'none',
|
||||
'fail' => 'not found',
|
||||
],
|
||||
'break_phrase' => FALSE,
|
||||
'not' => FALSE,
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'plugin_id' => 'numeric',
|
||||
],
|
||||
]);
|
||||
$view->save();
|
||||
|
||||
// Test that the form has the expected result.
|
||||
$this->drupalGet('views_test_data_element_form');
|
||||
$xpath = $this->xpath('//div[@class="view-content"]/div');
|
||||
$this->assertEqual(count($xpath), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the rendered output and form output of a view element, using the
|
||||
* embed display plugin.
|
||||
*/
|
||||
public function testViewElementEmbed() {
|
||||
$view = Views::getView('test_view_embed');
|
||||
$view->setDisplay();
|
||||
// Test a form.
|
||||
$this->drupalGet('views_test_data_element_embed_form');
|
||||
|
||||
$xpath = $this->xpath('//div[@class="views-element-container js-form-wrapper form-wrapper"]');
|
||||
$this->assertTrue($xpath, 'The view container has been found on the form.');
|
||||
|
||||
$xpath = $this->xpath('//div[@class="view-content"]');
|
||||
$this->assertTrue($xpath, 'The view content has been found on the form.');
|
||||
// There should be 5 rows in the results.
|
||||
$xpath = $this->xpath('//div[@class="view-content"]/div');
|
||||
$this->assertEqual(count($xpath), 5);
|
||||
|
||||
// Add an argument and save the view.
|
||||
$view->displayHandlers->get('default')->overrideOption('arguments', [
|
||||
'age' => [
|
||||
'default_action' => 'ignore',
|
||||
'title' => '',
|
||||
'default_argument_type' => 'fixed',
|
||||
'validate' => [
|
||||
'type' => 'none',
|
||||
'fail' => 'not found',
|
||||
],
|
||||
'break_phrase' => FALSE,
|
||||
'not' => FALSE,
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'plugin_id' => 'numeric',
|
||||
],
|
||||
]);
|
||||
$view->save();
|
||||
|
||||
// Test that the form has the same expected result.
|
||||
$this->drupalGet('views_test_data_element_embed_form');
|
||||
$xpath = $this->xpath('//div[@class="view-content"]/div');
|
||||
$this->assertEqual(count($xpath), 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -136,6 +136,8 @@ abstract class ViewTestBase extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Returns the schema definition.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function schemaDefinition() {
|
||||
return ViewTestData::schemaDefinition();
|
||||
|
||||
+25
-13
@@ -24,7 +24,6 @@ class ContextualFilterTest extends JavascriptTestBase {
|
||||
*/
|
||||
public static $testViews = ['test_field_body'];
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -33,9 +32,14 @@ class ContextualFilterTest extends JavascriptTestBase {
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), ['views_test_config']);
|
||||
|
||||
// Disable automatic live preview to make the sequence of calls clearer.
|
||||
// Always show advanced column.
|
||||
\Drupal::configFactory()->getEditable('views.settings')->set('ui.show.advanced_column', TRUE)->save();
|
||||
|
||||
// Disable automatic live preview to make the sequence of calls clearer. And
|
||||
// prevent errors on saving the view with the preview ajax load that are
|
||||
// cancelled.
|
||||
\Drupal::configFactory()->getEditable('views.settings')->set('ui.always_live_preview', FALSE)->save();
|
||||
|
||||
$account = $this->drupalCreateUser(['administer views']);
|
||||
$this->drupalLogin($account);
|
||||
}
|
||||
@@ -44,32 +48,40 @@ class ContextualFilterTest extends JavascriptTestBase {
|
||||
* Test adding a contextual filter handler through the UI.
|
||||
*/
|
||||
public function testAddContextualFilterUI() {
|
||||
$web_assert = $this->assertSession();
|
||||
|
||||
$this->drupalGet('/admin/structure/views/view/test_field_body');
|
||||
$web_assert->assertWaitOnAjaxRequest();
|
||||
|
||||
$web_assert = $this->assertSession();
|
||||
$page = $this->getSession()->getPage();
|
||||
|
||||
$page->clickLink('views-add-argument');
|
||||
$web_assert->assertWaitOnAjaxRequest();
|
||||
|
||||
$page->checkField('name[node_field_data.nid]');
|
||||
$field = $web_assert->waitForField('name[node_field_data.nid]');
|
||||
$this->assertNotEmpty($field);
|
||||
$field->check();
|
||||
|
||||
$add_button = $page->find('css', '.ui-dialog-buttonset .button--primary');
|
||||
$add_button->click();
|
||||
$web_assert->assertWaitOnAjaxRequest();
|
||||
|
||||
$page->fillField('options[default_action]', 'default');
|
||||
$field_action = $web_assert->waitForField('options[default_action]');
|
||||
$this->assertNotEmpty($field_action);
|
||||
$field_action->setValue('default');
|
||||
|
||||
$page->selectFieldOption('options[default_argument_type]', 'node');
|
||||
$add_button = $page->find('css', '.ui-dialog-buttonset .button--primary');
|
||||
$add_button->click();
|
||||
$web_assert->assertWaitOnAjaxRequest();
|
||||
|
||||
// Wait for the dialog to close.
|
||||
$page->waitFor(10, function () use ($page) {
|
||||
$field = $page->find('css', '.ui-dialog-buttonset .button--primary');
|
||||
return empty($field);
|
||||
});
|
||||
|
||||
$page->pressButton('edit-actions-submit');
|
||||
$web_assert->assertWaitOnAjaxRequest();
|
||||
|
||||
$page->clickLink('Content: ID');
|
||||
// Check that the dialog opens.
|
||||
$web_assert->assertWaitOnAjaxRequest();
|
||||
$page->pressButton('Close');
|
||||
$field_action = $web_assert->waitForField('options[default_action]');
|
||||
$this->assertNotEmpty($field_action);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Drupal\Tests\views\Kernel\Entity;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\user\Entity\User;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
@@ -27,7 +28,10 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = ['test_entity_row_renderers'];
|
||||
public static $testViews = [
|
||||
'test_entity_row_renderers',
|
||||
'test_entity_row_renderers_revisions_base',
|
||||
];
|
||||
|
||||
/**
|
||||
* An array of added languages.
|
||||
@@ -43,6 +47,20 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
|
||||
*/
|
||||
protected $expected;
|
||||
|
||||
/**
|
||||
* The author of the test content.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $testAuthor;
|
||||
|
||||
/**
|
||||
* An array of IDs of the test content.
|
||||
*
|
||||
* @var array[]
|
||||
*/
|
||||
protected $testIds;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -64,19 +82,25 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
|
||||
ConfigurableLanguage::createFromLangcode($langcode)->save();
|
||||
}
|
||||
|
||||
$this->testAuthor = User::create([
|
||||
'name' => 'foo',
|
||||
]);
|
||||
$this->testAuthor->save();
|
||||
|
||||
// Make sure we do not try to render non-existing user data.
|
||||
$node_type = NodeType::create(['type' => 'test']);
|
||||
$node_type->setDisplaySubmitted(FALSE);
|
||||
$node_type->save();
|
||||
|
||||
$this->values = [];
|
||||
$this->ids = [];
|
||||
$controller = \Drupal::entityManager()->getStorage('node');
|
||||
$langcode_index = 0;
|
||||
|
||||
for ($i = 0; $i < count($this->langcodes); $i++) {
|
||||
// Create a node with a different default language each time.
|
||||
$default_langcode = $this->langcodes[$langcode_index++];
|
||||
$node = $controller->create(['type' => 'test', 'uid' => 0, 'langcode' => $default_langcode]);
|
||||
$node = $controller->create(['type' => 'test', 'uid' => $this->testAuthor->id(), 'langcode' => $default_langcode]);
|
||||
// Ensure the default language is processed first.
|
||||
$langcodes = array_merge([$default_langcode], array_diff($this->langcodes, [$default_langcode]));
|
||||
|
||||
@@ -92,6 +116,11 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
|
||||
}
|
||||
|
||||
$node->save();
|
||||
|
||||
$this->ids[] = [
|
||||
'nid' => $node->id(),
|
||||
'uid' => $this->testAuthor->id(),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,6 +139,15 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
|
||||
$this->checkLanguageRenderers('page_2', $this->values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the row renderer with a revision base table.
|
||||
*/
|
||||
public function testRevisionBaseTable() {
|
||||
$view = Views::getView('test_entity_row_renderers_revisions_base');
|
||||
$view->execute();
|
||||
$this->assertIdenticalResultset($view, $this->ids, ['nid' => 'nid', 'uid' => 'uid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the language renderer configurations work as expected.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Kernel\Handler;
|
||||
|
||||
use Drupal\entity_test\Entity\EntityTestComputedField;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Provides some integration tests for the Field handler.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\field\EntityField
|
||||
* @group views
|
||||
*/
|
||||
class ComputedFieldTest extends ViewsKernelTestBase {
|
||||
|
||||
/**
|
||||
* Views to be enabled.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = ['computed_field_view'];
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['entity_test'];
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$this->installEntitySchema('entity_test_computed_field');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the computed field handler.
|
||||
*/
|
||||
public function testComputedFieldHandler() {
|
||||
\Drupal::state()->set('entity_test_computed_field_item_list_value', ['computed string']);
|
||||
|
||||
$entity = EntityTestComputedField::create([]);
|
||||
$entity->save();
|
||||
|
||||
$view = Views::getView('computed_field_view');
|
||||
|
||||
$rendered_view = $view->preview();
|
||||
$output = $this->container->get('renderer')->renderRoot($rendered_view);
|
||||
$this->assertContains('computed string', (string) $output);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Kernel\Handler;
|
||||
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
|
||||
/**
|
||||
|
||||
@@ -290,6 +290,8 @@ class FilterCombineTest extends ViewsKernelTestBase {
|
||||
|
||||
/**
|
||||
* Allow {views_test_data}.job to be NULL.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function schemaDefinition() {
|
||||
$schema = parent::schemaDefinition();
|
||||
|
||||
@@ -288,8 +288,7 @@ class FilterNumericTest extends ViewsKernelTestBase {
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = [
|
||||
];
|
||||
$resultset = [];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
|
||||
$view->destroy();
|
||||
@@ -345,8 +344,7 @@ class FilterNumericTest extends ViewsKernelTestBase {
|
||||
$this->container->get('router.builder')->rebuild();
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = [
|
||||
];
|
||||
$resultset = [];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,9 @@ class FilterStringTest extends ViewsKernelTestBase {
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function schemaDefinition() {
|
||||
$schema = parent::schemaDefinition();
|
||||
$schema['views_test_data']['fields']['description'] = [
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Kernel\Handler;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Tests sorting on translatable and not translatable fields.
|
||||
*
|
||||
* @group views
|
||||
*/
|
||||
class SortTranslationTest extends ViewsKernelTestBase {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'node',
|
||||
'field',
|
||||
'language',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $testViews = [
|
||||
'test_view_sort_translation',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
ConfigurableLanguage::createFromLangcode('de')->save();
|
||||
$this->installSchema('node', 'node_access');
|
||||
$this->installEntitySchema('node');
|
||||
$this->installEntitySchema('user');
|
||||
|
||||
// $this->installConfig('node');
|
||||
$this->container->get('kernel')->rebuildContainer();
|
||||
|
||||
$node_type = NodeType::create(['type' => 'article']);
|
||||
$node_type->save();
|
||||
|
||||
FieldStorageConfig::create([
|
||||
'field_name' => 'text',
|
||||
'entity_type' => 'node',
|
||||
'type' => 'string',
|
||||
])->save();
|
||||
|
||||
FieldConfig::create([
|
||||
'field_name' => 'text',
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'label' => 'Translated text',
|
||||
'translatable' => TRUE
|
||||
])->save();
|
||||
|
||||
FieldStorageConfig::create([
|
||||
'field_name' => 'weight',
|
||||
'entity_type' => 'node',
|
||||
'type' => 'integer',
|
||||
])->save();
|
||||
|
||||
FieldConfig::create([
|
||||
'field_name' => 'weight',
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'translatable' => FALSE,
|
||||
])->save();
|
||||
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$node = Node::create([
|
||||
'type' => 'article',
|
||||
'title' => 'Title en ' . $i,
|
||||
'weight' => ['value' => 3 - $i],
|
||||
'text' => ['value' => 'moo en ' . $i],
|
||||
'langcode' => 'en',
|
||||
]);
|
||||
$node->save();
|
||||
|
||||
$translation = $node->addTranslation('de');
|
||||
$translation->title->value = 'Title DE ' . $i;
|
||||
$translation->text->value = 'moo DE ' . $i;
|
||||
$translation->save();
|
||||
$nodes[] = $node;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test sorting on an untranslated field.
|
||||
*/
|
||||
public function testSortbyUntranslatedIntegerField() {
|
||||
$map = [
|
||||
'nid' => 'nid',
|
||||
'node_field_data_langcode' => 'langcode',
|
||||
];
|
||||
|
||||
$view = Views::getView('test_view_sort_translation');
|
||||
$view->setDisplay('default');
|
||||
$this->executeView($view);
|
||||
|
||||
// With ascending sort, the nodes should come out in reverse order.
|
||||
$expected = [
|
||||
[
|
||||
'nid' => 3,
|
||||
'langcode' => 'en',
|
||||
],
|
||||
[
|
||||
'nid' => 2,
|
||||
'langcode' => 'en',
|
||||
],
|
||||
[
|
||||
'nid' => 1,
|
||||
'langcode' => 'en',
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $expected, $map);
|
||||
$view->destroy();
|
||||
|
||||
$view = Views::getView('test_view_sort_translation');
|
||||
$view->setDisplay('display_de');
|
||||
$this->executeView($view);
|
||||
|
||||
$expected = [
|
||||
[
|
||||
'nid' => 3,
|
||||
'langcode' => 'de',
|
||||
],
|
||||
[
|
||||
'nid' => 2,
|
||||
'langcode' => 'de',
|
||||
],
|
||||
[
|
||||
'nid' => 1,
|
||||
'langcode' => 'de',
|
||||
],
|
||||
];
|
||||
|
||||
// The weight field is not translated, we sort by it so the nodes
|
||||
// should come out in the same order in both languages.
|
||||
$this->assertIdenticalResultset($view, $expected, $map);
|
||||
$view->destroy();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -158,13 +158,13 @@ class ModuleTest extends ViewsKernelTestBase {
|
||||
$this->assertEquals(array_keys($all_views), array_keys(Views::getAllViews()), 'Views::getAllViews works as expected.');
|
||||
|
||||
// Test Views::getEnabledViews().
|
||||
$expected_enabled = array_filter($all_views, function($view) {
|
||||
$expected_enabled = array_filter($all_views, function ($view) {
|
||||
return views_view_is_enabled($view);
|
||||
});
|
||||
$this->assertEquals(array_keys($expected_enabled), array_keys(Views::getEnabledViews()), 'Expected enabled views returned.');
|
||||
|
||||
// Test Views::getDisabledViews().
|
||||
$expected_disabled = array_filter($all_views, function($view) {
|
||||
$expected_disabled = array_filter($all_views, function ($view) {
|
||||
return views_view_is_disabled($view);
|
||||
});
|
||||
$this->assertEquals(array_keys($expected_disabled), array_keys(Views::getDisabledViews()), 'Expected disabled views returned.');
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Kernel\Plugin;
|
||||
|
||||
use Drupal\views\Plugin\views\join\FieldOrLanguageJoin;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Tests the "field OR language" join plugin.
|
||||
*
|
||||
* @group views
|
||||
* @see \Drupal\views\Plugin\views\join\FieldOrLanguageJoin
|
||||
*/
|
||||
class FieldOrLanguageJoinTest extends RelationshipJoinTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $pluginId = 'field_or_language_join';
|
||||
|
||||
/**
|
||||
* A plugin manager which handlers the instances of joins.
|
||||
*
|
||||
* @var \Drupal\views\Plugin\ViewsPluginManager
|
||||
*/
|
||||
protected $manager;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp();
|
||||
|
||||
// Add a join plugin manager which can be used in all of the tests.
|
||||
$this->manager = $this->container->get('plugin.manager.views.join');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests base join functionality.
|
||||
*
|
||||
* This duplicates parts of
|
||||
* \Drupal\Tests\views\Kernel\Plugin\JoinTest::testBasePlugin() to ensure that
|
||||
* no functionality provided by the base join plugin is broken.
|
||||
*/
|
||||
public function testBase() {
|
||||
// Setup a simple join and test the result sql.
|
||||
$view = Views::getView('test_view');
|
||||
$view->initDisplay();
|
||||
$view->initQuery();
|
||||
|
||||
// First define a simple join without an extra condition.
|
||||
// Set the various options on the join object.
|
||||
$configuration = [
|
||||
'left_table' => 'views_test_data',
|
||||
'left_field' => 'uid',
|
||||
'table' => 'users_field_data',
|
||||
'field' => 'uid',
|
||||
'adjusted' => TRUE,
|
||||
];
|
||||
$join = $this->manager->createInstance($this->pluginId, $configuration);
|
||||
$this->assertTrue($join instanceof FieldOrLanguageJoin);
|
||||
$this->assertNull($join->extra);
|
||||
$this->assertTrue($join->adjusted);
|
||||
|
||||
$join_info = $this->buildJoin($view, $configuration, 'users_field_data');
|
||||
$this->assertSame($join_info['join type'], 'LEFT');
|
||||
$this->assertSame($join_info['table'], $configuration['table']);
|
||||
$this->assertSame($join_info['alias'], 'users_field_data');
|
||||
$this->assertSame($join_info['condition'], 'views_test_data.uid = users_field_data.uid');
|
||||
|
||||
// Set a different alias and make sure table info is as expected.
|
||||
$join_info = $this->buildJoin($view, $configuration, 'users1');
|
||||
$this->assertSame($join_info['alias'], 'users1');
|
||||
|
||||
// Set a different join type (INNER) and make sure it is used.
|
||||
$configuration['type'] = 'INNER';
|
||||
$join_info = $this->buildJoin($view, $configuration, 'users2');
|
||||
$this->assertSame($join_info['join type'], 'INNER');
|
||||
|
||||
// Setup addition conditions and make sure it is used.
|
||||
$random_name_1 = $this->randomMachineName();
|
||||
$random_name_2 = $this->randomMachineName();
|
||||
$configuration['extra'] = [
|
||||
[
|
||||
'field' => 'name',
|
||||
'value' => $random_name_1
|
||||
],
|
||||
[
|
||||
'field' => 'name',
|
||||
'value' => $random_name_2,
|
||||
'operator' => '<>'
|
||||
],
|
||||
];
|
||||
$join_info = $this->buildJoin($view, $configuration, 'users3');
|
||||
$this->assertContains('views_test_data.uid = users3.uid', $join_info['condition']);
|
||||
$this->assertContains('users3.name = :views_join_condition_0', $join_info['condition']);
|
||||
$this->assertContains('users3.name <> :views_join_condition_1', $join_info['condition']);
|
||||
$this->assertSame(array_values($join_info['arguments']), [$random_name_1, $random_name_2]);
|
||||
|
||||
// Test that 'IN' conditions are properly built.
|
||||
$random_name_1 = $this->randomMachineName();
|
||||
$random_name_2 = $this->randomMachineName();
|
||||
$random_name_3 = $this->randomMachineName();
|
||||
$random_name_4 = $this->randomMachineName();
|
||||
$configuration['extra'] = [
|
||||
[
|
||||
'field' => 'name',
|
||||
'value' => $random_name_1
|
||||
],
|
||||
[
|
||||
'field' => 'name',
|
||||
'value' => [$random_name_2, $random_name_3, $random_name_4],
|
||||
],
|
||||
];
|
||||
$join_info = $this->buildJoin($view, $configuration, 'users4');
|
||||
$this->assertContains('views_test_data.uid = users4.uid', $join_info['condition']);
|
||||
$this->assertContains('users4.name = :views_join_condition_0', $join_info['condition']);
|
||||
$this->assertContains('users4.name IN ( :views_join_condition_1[] )', $join_info['condition']);
|
||||
$this->assertSame($join_info['arguments'][':views_join_condition_1[]'], [$random_name_2, $random_name_3, $random_name_4]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the adding of conditions by the join plugin.
|
||||
*/
|
||||
public function testLanguageBundleConditions() {
|
||||
// Setup a simple join and test the result sql.
|
||||
$view = Views::getView('test_view');
|
||||
$view->initDisplay();
|
||||
$view->initQuery();
|
||||
|
||||
// Set the various options on the join object with only a langcode
|
||||
// condition.
|
||||
$configuration = [
|
||||
'table' => 'node__field_tags',
|
||||
'left_table' => 'node',
|
||||
'left_field' => 'nid',
|
||||
'field' => 'entity_id',
|
||||
'extra' => [
|
||||
[
|
||||
'left_field' => 'langcode',
|
||||
'field' => 'langcode',
|
||||
],
|
||||
],
|
||||
];
|
||||
$join_info = $this->buildJoin($view, $configuration, 'node__field_tags');
|
||||
$this->assertContains('AND (node__field_tags.langcode = .langcode)', $join_info['condition']);
|
||||
|
||||
array_unshift($configuration['extra'], [
|
||||
'field' => 'deleted',
|
||||
'value' => 0,
|
||||
'numeric' => TRUE,
|
||||
]);
|
||||
$join_info = $this->buildJoin($view, $configuration, 'node__field_tags');
|
||||
$this->assertContains('AND (node__field_tags.langcode = .langcode)', $join_info['condition']);
|
||||
|
||||
// Replace the language condition with a bundle condition.
|
||||
$configuration['extra'][1] = [
|
||||
'field' => 'bundle',
|
||||
'value' => ['page'],
|
||||
];
|
||||
$join_info = $this->buildJoin($view, $configuration, 'node__field_tags');
|
||||
$this->assertContains('AND (node__field_tags.bundle = :views_join_condition_1)', $join_info['condition']);
|
||||
|
||||
// Now re-add a language condition to make sure the bundle and language
|
||||
// conditions are combined with an OR.
|
||||
$configuration['extra'][] = [
|
||||
'left_field' => 'langcode',
|
||||
'field' => 'langcode',
|
||||
];
|
||||
$join_info = $this->buildJoin($view, $configuration, 'node__field_tags');
|
||||
$this->assertContains('AND (node__field_tags.bundle = :views_join_condition_1 OR node__field_tags.langcode = .langcode)', $join_info['condition']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a join using the given configuration.
|
||||
*
|
||||
* @param \Drupal\views\ViewExecutable $view
|
||||
* The view used in this test.
|
||||
* @param $configuration
|
||||
* The join plugin configuration.
|
||||
* @param $table_alias
|
||||
* The table alias to use for the join.
|
||||
*
|
||||
* @return array
|
||||
* The join information for the joined table. See
|
||||
* \Drupal\Core\Database\Query\Select::$tables for more information on the
|
||||
* structure of the array.
|
||||
*/
|
||||
protected function buildJoin($view, $configuration, $table_alias) {
|
||||
// Build the actual join values and read them back from the query object.
|
||||
$query = \Drupal::database()->select('node');
|
||||
|
||||
$join = $this->manager->createInstance('field_or_language_join', $configuration);
|
||||
$this->assertInstanceOf(FieldOrLanguageJoin::class, $join, 'The correct join class got loaded.');
|
||||
|
||||
$table = ['alias' => $table_alias];
|
||||
$join->buildJoin($query, $table, $view->query);
|
||||
|
||||
$tables = $query->getTables();
|
||||
$join_info = $tables[$table['alias']];
|
||||
return $join_info;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,6 @@ use Drupal\views_test_data\Plugin\views\join\JoinTest as JoinTestPlugin;
|
||||
use Drupal\views\Plugin\views\join\JoinPluginBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
|
||||
/**
|
||||
* Tests the join plugin.
|
||||
*
|
||||
|
||||
@@ -44,6 +44,8 @@ abstract class RelationshipJoinTestBase extends PluginKernelTestBase {
|
||||
* Overrides \Drupal\views\Tests\ViewTestBase::schemaDefinition().
|
||||
*
|
||||
* Adds a uid column to test the relationships.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function schemaDefinition() {
|
||||
$schema = parent::schemaDefinition();
|
||||
|
||||
@@ -47,7 +47,7 @@ class RowEntityTest extends ViewsKernelTestBase {
|
||||
public function testEntityRow() {
|
||||
$vocab = Vocabulary::create(['name' => $this->randomMachineName(), 'vid' => strtolower($this->randomMachineName())]);
|
||||
$vocab->save();
|
||||
$term = Term::create(['name' => $this->randomMachineName(), 'vid' => $vocab->id() ]);
|
||||
$term = Term::create(['name' => $this->randomMachineName(), 'vid' => $vocab->id()]);
|
||||
$term->save();
|
||||
|
||||
$view = Views::getView('test_entity_row');
|
||||
|
||||
@@ -37,7 +37,7 @@ class SqlEntityLoadingTest extends ViewsKernelTestBase {
|
||||
$this->installSchema('node', 'node_access');
|
||||
}
|
||||
|
||||
public function testViewWithNonDefaultForwardRevision() {
|
||||
public function testViewWithNonDefaultPendingRevision() {
|
||||
$node_type = NodeType::create([
|
||||
'type' => 'page',
|
||||
]);
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Kernel\Plugin;
|
||||
|
||||
use Drupal\views\Views;
|
||||
use Drupal\views\ViewExecutable;
|
||||
|
||||
/**
|
||||
* Tests the grid style plugin.
|
||||
*
|
||||
* @group views
|
||||
* @see \Drupal\views\Plugin\views\style\Grid
|
||||
*/
|
||||
class StyleGridTest extends PluginKernelTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = ['test_grid'];
|
||||
|
||||
/**
|
||||
* Keeps track of which alignments have been tested.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $alignmentsTested = [];
|
||||
|
||||
/**
|
||||
* Tests the grid style.
|
||||
*/
|
||||
public function testGrid() {
|
||||
$view = Views::getView('test_grid');
|
||||
foreach (['horizontal', 'vertical'] as $alignment) {
|
||||
$this->assertGrid($view, $alignment, 5);
|
||||
$this->assertGrid($view, $alignment, 4);
|
||||
$this->assertGrid($view, $alignment, 3);
|
||||
$this->assertGrid($view, $alignment, 2);
|
||||
$this->assertGrid($view, $alignment, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a grid and asserts that it is displaying correctly.
|
||||
*
|
||||
* @param \Drupal\views\ViewExecutable $view
|
||||
* The executable to prepare.
|
||||
* @param string $alignment
|
||||
* The alignment of the grid to test.
|
||||
* @param int $columns
|
||||
* The number of columns in the grid to test.
|
||||
*/
|
||||
protected function assertGrid(ViewExecutable $view, $alignment, $columns) {
|
||||
$view->setDisplay('default');
|
||||
$view->initStyle();
|
||||
$view->initHandlers();
|
||||
$view->initQuery();
|
||||
$view->style_plugin->options['alignment'] = $alignment;
|
||||
$view->style_plugin->options['columns'] = $columns;
|
||||
$this->executeView($view);
|
||||
$output = $view->preview();
|
||||
$output = \Drupal::service('renderer')->renderRoot($output);
|
||||
$this->setRawContent($output);
|
||||
if (!in_array($alignment, $this->alignmentsTested)) {
|
||||
$result = $this->xpath('//div[contains(@class, "views-view-grid") and contains(@class, :alignment) and contains(@class, :columns)]', [':alignment' => $alignment, ':columns' => 'cols-' . $columns]);
|
||||
$this->assertTrue(count($result), ucfirst($alignment) . " grid markup detected.");
|
||||
$this->alignmentsTested[] = $alignment;
|
||||
}
|
||||
$width = '0';
|
||||
switch ($columns) {
|
||||
case 5: $width = '20'; break;
|
||||
case 4: $width = '25'; break;
|
||||
case 3: $width = '33.3333'; break;
|
||||
case 2: $width = '50'; break;
|
||||
case 1: $width = '100'; break;
|
||||
}
|
||||
// Ensure last column exists.
|
||||
$result = $this->xpath('//div[contains(@class, "views-col") and contains(@class, :columns) and starts-with(@style, :width)]', [':columns' => 'col-' . $columns, ':width' => 'width: ' . $width]);
|
||||
$this->assertTrue(count($result), ucfirst($alignment) . " $columns column grid: last column exists and automatic width calculated correctly.");
|
||||
// Ensure no extra columns were generated.
|
||||
$result = $this->xpath('//div[contains(@class, "views-col") and contains(@class, :columns)]', [':columns' => 'col-' . ($columns + 1)]);
|
||||
$this->assertFalse(count($result), ucfirst($alignment) . " $columns column grid: no extraneous columns exist.");
|
||||
// Ensure tokens are being replaced in custom row/column classes.
|
||||
$result = $this->xpath('//div[contains(@class, "views-col") and contains(@class, "name-John")]');
|
||||
$this->assertTrue(count($result), ucfirst($alignment) . " $columns column grid: Token replacement verified in custom column classes.");
|
||||
$result = $this->xpath('//div[contains(@class, "views-row") and contains(@class, "age-25")]');
|
||||
$this->assertTrue(count($result), ucfirst($alignment) . " $columns column grid: Token replacement verified in custom row classes.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -164,7 +164,7 @@ class RenderCacheIntegrationTest extends ViewsKernelTestBase {
|
||||
$this->pass('Test arguments');
|
||||
|
||||
// Custom assert for a single result row.
|
||||
$single_entity_assertions = function(array $build, EntityInterface $entity) {
|
||||
$single_entity_assertions = function (array $build, EntityInterface $entity) {
|
||||
$this->setRawContent($build['#markup']);
|
||||
|
||||
$result = $this->cssSelect('div.views-row');
|
||||
|
||||
@@ -34,7 +34,8 @@ class TestViewsTest extends KernelTestBase {
|
||||
\Drupal::service('config.storage'),
|
||||
new TestInstallStorage(InstallStorage::CONFIG_SCHEMA_DIRECTORY),
|
||||
\Drupal::service('cache.discovery'),
|
||||
\Drupal::service('module_handler')
|
||||
\Drupal::service('module_handler'),
|
||||
\Drupal::service('class_resolver')
|
||||
);
|
||||
|
||||
// Create a configuration storage with access to default configuration in
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Kernel;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Tests the view render element.
|
||||
*
|
||||
* @group views
|
||||
*/
|
||||
class ViewElementTest extends ViewsKernelTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = ['test_view_embed'];
|
||||
|
||||
/**
|
||||
* Tests the rendered output and form output of a view element.
|
||||
*/
|
||||
public function testViewElement() {
|
||||
/** @var \Drupal\Core\Render\RendererInterface $renderer */
|
||||
$renderer = $this->container->get('renderer');
|
||||
$view = Views::getView('test_view_embed');
|
||||
|
||||
// Get the render array, #embed must be FALSE since this is the default
|
||||
// display.
|
||||
$render = $view->buildRenderable();
|
||||
$this->assertEqual($render['#embed'], FALSE);
|
||||
$this->setRawContent($renderer->renderRoot($render));
|
||||
|
||||
$xpath = $this->xpath('//div[@class="views-element-container"]');
|
||||
$this->assertTrue($xpath, 'The view container has been found in the rendered output.');
|
||||
|
||||
// There should be 5 rows in the results.
|
||||
$xpath = $this->xpath('//div[@class="views-row"]');
|
||||
$this->assertEqual(count($xpath), 5);
|
||||
|
||||
// Add an argument and save the view.
|
||||
$view->displayHandlers->get('default')->overrideOption('arguments', [
|
||||
'age' => [
|
||||
'default_action' => 'ignore',
|
||||
'title' => '',
|
||||
'default_argument_type' => 'fixed',
|
||||
'validate' => [
|
||||
'type' => 'none',
|
||||
'fail' => 'not found',
|
||||
],
|
||||
'break_phrase' => FALSE,
|
||||
'not' => FALSE,
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'plugin_id' => 'numeric',
|
||||
],
|
||||
]);
|
||||
$view->save();
|
||||
|
||||
// Test the render array again.
|
||||
$view = Views::getView('test_view_embed');
|
||||
$render = $view->buildRenderable(NULL, [25]);
|
||||
$this->setRawContent($renderer->renderRoot($render));
|
||||
// There should be 1 row in the results, 'John' arg 25.
|
||||
$xpath = $this->xpath('//div[@class="views-row"]');
|
||||
$this->assertEqual(count($xpath), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the rendered output and form output of a view element, using the
|
||||
* embed display plugin.
|
||||
*/
|
||||
public function testViewElementEmbed() {
|
||||
/** @var \Drupal\Core\Render\RendererInterface $renderer */
|
||||
$renderer = $this->container->get('renderer');
|
||||
$view = Views::getView('test_view_embed');
|
||||
|
||||
// Get the render array, #embed must be TRUE since this is an embed display.
|
||||
$render = $view->buildRenderable('embed_1');
|
||||
$this->assertEqual($render['#embed'], TRUE);
|
||||
$this->setRawContent($renderer->renderRoot($render));
|
||||
|
||||
$xpath = $this->xpath('//div[@class="views-element-container"]');
|
||||
$this->assertTrue($xpath, 'The view container has been found in the rendered output.');
|
||||
|
||||
// There should be 5 rows in the results.
|
||||
$xpath = $this->xpath('//div[@class="views-row"]');
|
||||
$this->assertEqual(count($xpath), 5);
|
||||
|
||||
// Add an argument and save the view.
|
||||
$view->displayHandlers->get('default')->overrideOption('arguments', [
|
||||
'age' => [
|
||||
'default_action' => 'ignore',
|
||||
'title' => '',
|
||||
'default_argument_type' => 'fixed',
|
||||
'validate' => [
|
||||
'type' => 'none',
|
||||
'fail' => 'not found',
|
||||
],
|
||||
'break_phrase' => FALSE,
|
||||
'not' => FALSE,
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'plugin_id' => 'numeric',
|
||||
],
|
||||
]);
|
||||
$view->save();
|
||||
|
||||
// Test the render array again.
|
||||
$view = Views::getView('test_view_embed');
|
||||
$render = $view->buildRenderable('embed_1', [25]);
|
||||
$this->setRawContent($renderer->renderRoot($render));
|
||||
// There should be 1 row in the results, 'John' arg 25.
|
||||
$xpath = $this->xpath('//div[@class="views-row"]');
|
||||
$this->assertEqual(count($xpath), 1);
|
||||
|
||||
// Tests the render array with an exposed filter.
|
||||
$view = Views::getView('test_view_embed');
|
||||
$render = $view->buildRenderable('embed_2');
|
||||
$this->setRawContent($renderer->renderRoot($render));
|
||||
|
||||
// Ensure that the exposed form is rendered.
|
||||
$this->assertEqual(1, count($this->xpath('//form[@class="views-exposed-form"]')));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -196,8 +196,13 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
||||
$view->initDisplay();
|
||||
|
||||
// Error is triggered while calling the wrong display.
|
||||
$this->setExpectedException(\PHPUnit_Framework_Error::class);
|
||||
$view->setDisplay('invalid');
|
||||
try {
|
||||
$view->setDisplay('invalid');
|
||||
$this->fail('Expected error, when setDisplay() called with invalid display ID');
|
||||
}
|
||||
catch (\PHPUnit_Framework_Error_Warning $e) {
|
||||
$this->assertEquals('setDisplay() called with invalid display ID "invalid".', $e->getMessage());
|
||||
}
|
||||
|
||||
$this->assertEqual($view->current_display, 'default', 'If setDisplay is called with an invalid display id the default display should be used.');
|
||||
$this->assertEqual(spl_object_hash($view->display_handler), spl_object_hash($view->displayHandlers->get('default')));
|
||||
@@ -427,7 +432,7 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
||||
|
||||
$count = 0;
|
||||
foreach ($view->displayHandlers as $id => $display) {
|
||||
$match = function($value) use ($display) {
|
||||
$match = function ($value) use ($display) {
|
||||
return strpos($value, $display->display['display_title']) !== FALSE;
|
||||
};
|
||||
$this->assertTrue(array_filter($validate[$id], $match), format_string('Error message found for @id display', ['@id' => $id]));
|
||||
@@ -487,6 +492,37 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
||||
$this->assertIdentical($unserialized->current_display, 'page_1', 'The expected display was set on the unserialized view.');
|
||||
$this->assertIdentical($unserialized->args, ['test'], 'The expected argument was set on the unserialized view.');
|
||||
$this->assertIdentical($unserialized->getCurrentPage(), 2, 'The expected current page was set on the unserialized view.');
|
||||
|
||||
// Get the definition of node's nid field, for example. Only get it not from
|
||||
// the field manager directly, but from the item data definition. It should
|
||||
// be the same base field definition object (the field and item definitions
|
||||
// refer to each other).
|
||||
// See https://bugs.php.net/bug.php?id=66052
|
||||
$field_manager = $this->container->get('entity_field.manager');
|
||||
$nid_definition_before = $field_manager->getBaseFieldDefinitions('node')['nid']
|
||||
->getItemDefinition()
|
||||
->getFieldDefinition();
|
||||
|
||||
// Load and execute a view.
|
||||
$view_entity = View::load('content');
|
||||
$view_executable = $view_entity->getExecutable();
|
||||
$view_executable->execute('page_1');
|
||||
|
||||
// Reset the static cache. Don't use clearCachedFieldDefinitions() since
|
||||
// that clears the persistent cache and we need to get the serialized cache
|
||||
// data.
|
||||
$field_manager->useCaches(FALSE);
|
||||
$field_manager->useCaches(TRUE);
|
||||
|
||||
// Serialize the ViewExecutable as part of other data.
|
||||
unserialize(serialize(['SOMETHING UNEXPECTED', $view_executable]));
|
||||
|
||||
// Make sure the serialisation of the ViewExecutable didn't influence the
|
||||
// field definitions.
|
||||
$nid_definition_after = $field_manager->getBaseFieldDefinitions('node')['nid']
|
||||
->getItemDefinition()
|
||||
->getFieldDefinition();
|
||||
$this->assertEquals($nid_definition_before->getPropertyDefinitions(), $nid_definition_after->getPropertyDefinitions());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Drupal\Tests\views\Kernel;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\image\Entity\ImageStyle;
|
||||
use Drupal\user\Entity\Role;
|
||||
use Drupal\views\Entity\View;
|
||||
|
||||
/**
|
||||
@@ -17,13 +18,23 @@ class ViewsConfigDependenciesIntegrationTest extends ViewsKernelTestBase {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['field', 'file', 'image', 'entity_test'];
|
||||
public static $modules = ['field', 'file', 'image', 'entity_test', 'user', 'text'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $testViews = ['entity_test_fields'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$this->installEntitySchema('user');
|
||||
$this->installSchema('user', ['users_data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests integration with image module.
|
||||
*/
|
||||
@@ -69,7 +80,81 @@ class ViewsConfigDependenciesIntegrationTest extends ViewsKernelTestBase {
|
||||
// Delete the 'foo' image style.
|
||||
$style->delete();
|
||||
|
||||
$view = View::load('entity_test_fields');
|
||||
|
||||
// Checks that the view has not been deleted too.
|
||||
$this->assertNotNull(View::load('entity_test_fields'));
|
||||
|
||||
// Checks that the image field was removed from the View.
|
||||
$display = $view->getDisplay('default');
|
||||
$this->assertFalse(isset($display['display_options']['fields']['bar']));
|
||||
|
||||
// Checks that the view has been disabled.
|
||||
$this->assertFalse($view->status());
|
||||
|
||||
$dependencies = $view->getDependencies() + ['config' => []];
|
||||
// Checks that the dependency on style 'foo' has been removed.
|
||||
$this->assertFalse(in_array('image.style.foo', $dependencies['config']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests removing a config dependency that deletes the View.
|
||||
*/
|
||||
public function testConfigRemovalRole() {
|
||||
// Create a role we can add to the View and delete.
|
||||
$role = Role::create([
|
||||
'id' => 'dummy',
|
||||
'label' => 'dummy',
|
||||
]);
|
||||
|
||||
$role->save();
|
||||
|
||||
/** @var \Drupal\views\ViewEntityInterface $view */
|
||||
$view = View::load('entity_test_fields');
|
||||
$display = &$view->getDisplay('default');
|
||||
|
||||
// Set the access to be restricted by the dummy role.
|
||||
$display['display_options']['access'] = [
|
||||
'type' => 'role',
|
||||
'options' => [
|
||||
'role' => [
|
||||
$role->id() => $role->id(),
|
||||
],
|
||||
],
|
||||
];
|
||||
$view->save();
|
||||
|
||||
// Check that the View now has a dependency on the Role.
|
||||
$dependencies = $view->getDependencies() + ['config' => []];
|
||||
$this->assertTrue(in_array('user.role.dummy', $dependencies['config']));
|
||||
|
||||
// Delete the role.
|
||||
$role->delete();
|
||||
|
||||
$view = View::load('entity_test_fields');
|
||||
|
||||
// Checks that the view has been deleted too.
|
||||
$this->assertNull($view);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninstalling a module that provides a base table for a View.
|
||||
*/
|
||||
public function testConfigRemovalBaseTable() {
|
||||
// Find all the entity types provided by the entity_test module and install
|
||||
// the schema for them so we can uninstall them.
|
||||
$entities = \Drupal::entityTypeManager()->getDefinitions();
|
||||
foreach ($entities as $entity_type_id => $definition) {
|
||||
if ($definition->getProvider() == 'entity_test') {
|
||||
$this->installEntitySchema($entity_type_id);
|
||||
};
|
||||
}
|
||||
|
||||
// Check that removing the module that provides the base table for a View,
|
||||
// deletes the View.
|
||||
$this->assertNotNull(View::load('entity_test_fields'));
|
||||
$this->container->get('module_installer')->uninstall(['entity_test']);
|
||||
// Check that the View has been deleted.
|
||||
$this->assertNull(View::load('entity_test_fields'));
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ class ViewsHooksTest extends ViewsKernelTestBase {
|
||||
],
|
||||
'#substitutions' => ['#value' => []],
|
||||
];
|
||||
$element = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function() use ($element) {
|
||||
$element = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($element) {
|
||||
return views_pre_render_views_form_views_form($element);
|
||||
});
|
||||
$this->setRawContent((string) $element['output']['#markup']);
|
||||
|
||||
@@ -129,6 +129,8 @@ abstract class ViewsKernelTestBase extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* Returns the schema definition.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function schemaDefinition() {
|
||||
return ViewTestData::schemaDefinition();
|
||||
|
||||
@@ -74,7 +74,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
||||
$this->renderer = $this->getMock('\Drupal\Core\Render\RendererInterface');
|
||||
$this->renderer->expects($this->any())
|
||||
->method('render')
|
||||
->will($this->returnCallback(function(array &$elements) {
|
||||
->will($this->returnCallback(function (array &$elements) {
|
||||
$elements['#attached'] = [];
|
||||
return isset($elements['#markup']) ? $elements['#markup'] : '';
|
||||
}));
|
||||
@@ -344,8 +344,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
||||
$display_handler->expects($this->never())
|
||||
->method('setOption');
|
||||
$display_handler->expects($this->any())
|
||||
->method('getOption')
|
||||
->with('use_ajax')
|
||||
->method('ajaxEnabled')
|
||||
->willReturn($use_ajax);
|
||||
|
||||
$display_collection = $this->getMockBuilder('Drupal\views\DisplayPluginCollection')
|
||||
|
||||
@@ -9,7 +9,6 @@ namespace Drupal\Tests\views\Unit;
|
||||
|
||||
use Drupal\Core\Config\Entity\ConfigEntityType;
|
||||
use Drupal\Core\Entity\ContentEntityType;
|
||||
use Drupal\Core\Entity\EntityType;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Entity\Sql\DefaultTableMapping;
|
||||
use Drupal\Core\Field\BaseFieldDefinition;
|
||||
@@ -243,8 +242,7 @@ class EntityViewsDataTest extends UnitTestCase {
|
||||
->set('revision_table', 'entity_test_mulrev_revision')
|
||||
->set('revision_data_table', NULL)
|
||||
->set('id', 'entity_test_mulrev')
|
||||
->setKey('revision', 'revision_id')
|
||||
;
|
||||
->setKey('revision', 'revision_id');
|
||||
$this->viewsData->setEntityType($entity_type);
|
||||
|
||||
$data = $this->viewsData->getViewsData();
|
||||
@@ -279,8 +277,7 @@ class EntityViewsDataTest extends UnitTestCase {
|
||||
->set('revision_data_table', 'entity_test_mulrev_property_revision')
|
||||
->set('id', 'entity_test_mulrev')
|
||||
->set('translatable', TRUE)
|
||||
->setKey('revision', 'revision_id')
|
||||
;
|
||||
->setKey('revision', 'revision_id');
|
||||
$this->viewsData->setEntityType($entity_type);
|
||||
|
||||
$data = $this->viewsData->getViewsData();
|
||||
@@ -299,7 +296,9 @@ class EntityViewsDataTest extends UnitTestCase {
|
||||
$this->assertCount(1, $revision_field_data['table']['join']);
|
||||
$this->assertEquals([
|
||||
'entity_test_mul_property_data' => [
|
||||
'left_field' => 'revision_id', 'field' => 'revision_id', 'type' => 'INNER'
|
||||
'left_field' => 'revision_id',
|
||||
'field' => 'revision_id',
|
||||
'type' => 'INNER',
|
||||
],
|
||||
], $revision_field_data['table']['join']);
|
||||
|
||||
@@ -307,7 +306,9 @@ class EntityViewsDataTest extends UnitTestCase {
|
||||
$this->assertCount(1, $revision_base_data['table']['join']);
|
||||
$this->assertEquals([
|
||||
'entity_test_mulrev_property_revision' => [
|
||||
'left_field' => 'revision_id', 'field' => 'revision_id', 'type' => 'INNER'
|
||||
'left_field' => 'revision_id',
|
||||
'field' => 'revision_id',
|
||||
'type' => 'INNER',
|
||||
],
|
||||
], $revision_base_data['table']['join']);
|
||||
|
||||
@@ -323,8 +324,7 @@ class EntityViewsDataTest extends UnitTestCase {
|
||||
->set('revision_data_table', 'entity_test_mulrev_property_revision')
|
||||
->set('id', 'entity_test_mulrev')
|
||||
->set('translatable', TRUE)
|
||||
->setKey('revision', 'revision_id')
|
||||
;
|
||||
->setKey('revision', 'revision_id');
|
||||
$this->viewsData->setEntityType($entity_type);
|
||||
|
||||
$data = $this->viewsData->getViewsData();
|
||||
@@ -343,7 +343,9 @@ class EntityViewsDataTest extends UnitTestCase {
|
||||
$this->assertCount(1, $revision_field_data['table']['join']);
|
||||
$this->assertEquals([
|
||||
'entity_test_mulrev_field_data' => [
|
||||
'left_field' => 'revision_id', 'field' => 'revision_id', 'type' => 'INNER'
|
||||
'left_field' => 'revision_id',
|
||||
'field' => 'revision_id',
|
||||
'type' => 'INNER',
|
||||
],
|
||||
], $revision_field_data['table']['join']);
|
||||
|
||||
@@ -351,7 +353,9 @@ class EntityViewsDataTest extends UnitTestCase {
|
||||
$this->assertCount(1, $revision_base_data['table']['join']);
|
||||
$this->assertEquals([
|
||||
'entity_test_mulrev_property_revision' => [
|
||||
'left_field' => 'revision_id', 'field' => 'revision_id', 'type' => 'INNER'
|
||||
'left_field' => 'revision_id',
|
||||
'field' => 'revision_id',
|
||||
'type' => 'INNER',
|
||||
],
|
||||
], $revision_base_data['table']['join']);
|
||||
$this->assertFalse(isset($data['data_table']));
|
||||
@@ -533,10 +537,11 @@ class EntityViewsDataTest extends UnitTestCase {
|
||||
'left_field' => 'id',
|
||||
'field' => 'entity_id',
|
||||
'extra' => [[
|
||||
'field' => 'deleted',
|
||||
'value' => 0,
|
||||
'numeric' => TRUE,
|
||||
]],
|
||||
'field' => 'deleted',
|
||||
'value' => 0,
|
||||
'numeric' => TRUE,
|
||||
],
|
||||
],
|
||||
], $data['entity_test__string']['table']['join']['entity_test']);
|
||||
}
|
||||
|
||||
@@ -548,8 +553,7 @@ class EntityViewsDataTest extends UnitTestCase {
|
||||
->set('data_table', 'entity_test_mul_property_data')
|
||||
->set('base_table', 'entity_test_mul')
|
||||
->set('id', 'entity_test_mul')
|
||||
->setKey('bundle', 'type')
|
||||
;
|
||||
->setKey('bundle', 'type');
|
||||
$base_field_definitions = $this->setupBaseFields(EntityTestMul::baseFieldDefinitions($this->baseEntityType));
|
||||
$base_field_definitions['type'] = BaseFieldDefinition::create('entity_reference')
|
||||
->setLabel('entity test type')
|
||||
@@ -604,7 +608,7 @@ class EntityViewsDataTest extends UnitTestCase {
|
||||
|
||||
$table_mapping->expects($this->any())
|
||||
->method('getFieldTableName')
|
||||
->willReturnCallback(function($field) {
|
||||
->willReturnCallback(function ($field) {
|
||||
if ($field == 'uuid') {
|
||||
return 'entity_test_mul';
|
||||
}
|
||||
@@ -688,10 +692,11 @@ class EntityViewsDataTest extends UnitTestCase {
|
||||
'left_field' => 'id',
|
||||
'field' => 'entity_id',
|
||||
'extra' => [[
|
||||
'field' => 'deleted',
|
||||
'value' => 0,
|
||||
'numeric' => TRUE,
|
||||
]],
|
||||
'field' => 'deleted',
|
||||
'value' => 0,
|
||||
'numeric' => TRUE,
|
||||
],
|
||||
],
|
||||
], $data['entity_test_mul__string']['table']['join']['entity_test_mul']);
|
||||
}
|
||||
|
||||
@@ -777,7 +782,7 @@ class EntityViewsDataTest extends UnitTestCase {
|
||||
|
||||
$table_mapping->expects($this->any())
|
||||
->method('getFieldTableName')
|
||||
->willReturnCallback(function($field) {
|
||||
->willReturnCallback(function ($field) {
|
||||
if ($field == 'uuid') {
|
||||
return 'entity_test_mulrev';
|
||||
}
|
||||
@@ -873,10 +878,11 @@ class EntityViewsDataTest extends UnitTestCase {
|
||||
'left_field' => 'id',
|
||||
'field' => 'entity_id',
|
||||
'extra' => [[
|
||||
'field' => 'deleted',
|
||||
'value' => 0,
|
||||
'numeric' => TRUE,
|
||||
]],
|
||||
'field' => 'deleted',
|
||||
'value' => 0,
|
||||
'numeric' => TRUE,
|
||||
],
|
||||
],
|
||||
], $data['entity_test_mulrev__string']['table']['join']['entity_test_mulrev_property_data']);
|
||||
|
||||
$this->assertStringField($data['entity_test_mulrev_revision__string']['string']);
|
||||
@@ -885,10 +891,11 @@ class EntityViewsDataTest extends UnitTestCase {
|
||||
'left_field' => 'revision_id',
|
||||
'field' => 'entity_id',
|
||||
'extra' => [[
|
||||
'field' => 'deleted',
|
||||
'value' => 0,
|
||||
'numeric' => TRUE,
|
||||
]],
|
||||
'field' => 'deleted',
|
||||
'value' => 0,
|
||||
'numeric' => TRUE,
|
||||
],
|
||||
],
|
||||
], $data['entity_test_mulrev_revision__string']['table']['join']['entity_test_mulrev_property_revision']);
|
||||
}
|
||||
|
||||
@@ -1087,7 +1094,7 @@ class TestEntityViewsData extends EntityViewsData {
|
||||
|
||||
}
|
||||
|
||||
class TestEntityType extends EntityType {
|
||||
class TestEntityType extends ContentEntityType {
|
||||
|
||||
/**
|
||||
* Sets a specific entity key.
|
||||
|
||||
@@ -101,7 +101,7 @@ class RouteSubscriberTest extends UnitTestCase {
|
||||
// should only call the second display.
|
||||
$display_1->expects($this->once())
|
||||
->method('collectRoutes')
|
||||
->willReturnCallback(function() use ($collection) {
|
||||
->willReturnCallback(function () use ($collection) {
|
||||
$collection->add('views.test_id.page_1', new Route('test_route', ['_controller' => 'Drupal\views\Routing\ViewPageController']));
|
||||
return ['test_id.page_1' => 'views.test_id.page_1'];
|
||||
});
|
||||
@@ -111,7 +111,7 @@ class RouteSubscriberTest extends UnitTestCase {
|
||||
|
||||
$display_2->expects($this->once())
|
||||
->method('collectRoutes')
|
||||
->willReturnCallback(function() use ($collection) {
|
||||
->willReturnCallback(function () use ($collection) {
|
||||
$collection->add('views.test_id.page_2', new Route('test_route', ['_controller' => 'Drupal\views\Routing\ViewPageController']));
|
||||
return ['test_id.page_2' => 'views.test_id.page_2'];
|
||||
});
|
||||
@@ -139,8 +139,8 @@ class RouteSubscriberTest extends UnitTestCase {
|
||||
/**
|
||||
* Sets up mocks of Views objects needed for testing.
|
||||
*
|
||||
* @return array \Drupal\views\Plugin\views\display\DisplayRouterInterface[]|\PHPUnit_Framework_MockObject_MockObject[]
|
||||
* An array of two mocked view displays
|
||||
* @return \Drupal\views\Plugin\views\display\DisplayRouterInterface[]|\PHPUnit_Framework_MockObject_MockObject[]
|
||||
* An array of two mocked view displays.
|
||||
*/
|
||||
protected function setupMocks() {
|
||||
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
|
||||
@@ -58,7 +58,8 @@ class ViewsBlockTest extends UnitTestCase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
// TODO: Change the autogenerated stub.
|
||||
parent::setUp();
|
||||
$condition_plugin_manager = $this->getMock('Drupal\Core\Executable\ExecutableManagerInterface');
|
||||
$condition_plugin_manager->expects($this->any())
|
||||
->method('getDefinitions')
|
||||
|
||||
@@ -73,18 +73,22 @@ class HandlerBaseTest extends UnitTestCase {
|
||||
$this->viewsData->expects($this->any())
|
||||
->method('get')
|
||||
->willReturnMap([
|
||||
['test_entity_type_table', [
|
||||
'table' => ['entity type' => 'test_entity_type'],
|
||||
'test_relationship' => [
|
||||
'relationship' => [
|
||||
'base' => 'test_other_entity_type_table',
|
||||
'base field' => 'id',
|
||||
[
|
||||
'test_entity_type_table',
|
||||
[
|
||||
'table' => ['entity type' => 'test_entity_type'],
|
||||
'test_relationship' => [
|
||||
'relationship' => [
|
||||
'base' => 'test_other_entity_type_table',
|
||||
'base field' => 'id',
|
||||
],
|
||||
],
|
||||
],
|
||||
]],
|
||||
['test_other_entity_type_table', [
|
||||
'table' => ['entity type' => 'test_other_entity_type'],
|
||||
]],
|
||||
],
|
||||
[
|
||||
'test_other_entity_type_table',
|
||||
['table' => ['entity type' => 'test_other_entity_type']],
|
||||
],
|
||||
]);
|
||||
$handler->setViewsData($this->viewsData);
|
||||
|
||||
|
||||
@@ -548,7 +548,7 @@ class FieldPluginBaseTest extends UnitTestCase {
|
||||
'#type' => 'inline_template',
|
||||
'#template' => 'test-path/' . explode('/', $path)[1],
|
||||
'#context' => ['foo' => 123],
|
||||
'#post_render' => [function() {}],
|
||||
'#post_render' => [function () {}],
|
||||
];
|
||||
|
||||
$this->renderer->expects($this->once())
|
||||
@@ -612,7 +612,7 @@ class FieldPluginBaseTest extends UnitTestCase {
|
||||
'#type' => 'inline_template',
|
||||
'#template' => $path,
|
||||
'#context' => ['foo' => $context['context_path']],
|
||||
'#post_render' => [function() {}],
|
||||
'#post_render' => [function () {}],
|
||||
];
|
||||
|
||||
$this->renderer->expects($this->once())
|
||||
@@ -740,7 +740,7 @@ class FieldPluginBaseTest extends UnitTestCase {
|
||||
'#type' => 'inline_template',
|
||||
'#template' => $test_class,
|
||||
'#context' => $tokens,
|
||||
'#post_render' => [function() {}],
|
||||
'#post_render' => [function () {}],
|
||||
];
|
||||
|
||||
// We're not testing the token rendering itself, just that the function
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace Drupal\Tests\views\Unit\Plugin\pager;
|
||||
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\Core\Database\StatementInterface;
|
||||
use Drupal\Core\Database\Query\Select;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\views\Plugin\views\pager\PagerPluginBase
|
||||
@@ -247,6 +248,30 @@ class PagerPluginBaseTest extends UnitTestCase {
|
||||
$this->assertEquals(1, $this->pager->executeCountQuery($query));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the executeCountQuery method with an offset larger than result count.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\pager\PagerPluginBase::executeCountQuery()
|
||||
*/
|
||||
public function testExecuteCountQueryWithOffsetLargerThanResult() {
|
||||
$statement = $this->getMock(TestStatementInterface::class);
|
||||
|
||||
$statement->expects($this->once())
|
||||
->method('fetchField')
|
||||
->will($this->returnValue(2));
|
||||
|
||||
$query = $this->getMockBuilder(Select::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$query->expects($this->once())
|
||||
->method('execute')
|
||||
->will($this->returnValue($statement));
|
||||
|
||||
$this->pager->setOffset(3);
|
||||
$this->assertEquals(0, $this->pager->executeCountQuery($query));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -139,7 +139,7 @@ class SqlTest extends UnitTestCase {
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface[][] $entities_by_type
|
||||
* Test entities keyed by entity type and entity ID.
|
||||
* @param \Drupal\Core\Entity\EntityInterface[][] $entities_by_type
|
||||
* @param \Drupal\Core\Entity\EntityInterface[][] $entity_revisions_by_type
|
||||
* Test entities keyed by entity type and revision ID.
|
||||
*
|
||||
* @return \Prophecy\Prophecy\ObjectProphecy
|
||||
|
||||
@@ -79,8 +79,7 @@ class PluginBaseTest extends UnitTestCase {
|
||||
'storage' => [
|
||||
'key' => 'value',
|
||||
],
|
||||
'options' => [
|
||||
],
|
||||
'options' => [],
|
||||
'definition' => [
|
||||
'key' => ['default' => 'value2'],
|
||||
],
|
||||
@@ -172,9 +171,7 @@ class PluginBaseTest extends UnitTestCase {
|
||||
],
|
||||
'definition' => [
|
||||
'key0' => ['default' => 'value0'],
|
||||
'key1' => ['contains' => [
|
||||
'key1:1' => ['default' => 'value1:1'],
|
||||
]],
|
||||
'key1' => ['contains' => ['key1:1' => ['default' => 'value1:1']]],
|
||||
],
|
||||
'expected' => [
|
||||
'key0' => 'value',
|
||||
@@ -188,29 +185,29 @@ class PluginBaseTest extends UnitTestCase {
|
||||
'key2' => [
|
||||
'key2:1' => [
|
||||
'key2:1:1' => 'value0',
|
||||
'key2:1:2' => [
|
||||
'key2:1:2:1' => 'value1',
|
||||
],
|
||||
'key2:1:2' => ['key2:1:2:1' => 'value1'],
|
||||
],
|
||||
],
|
||||
],
|
||||
'definition' => [
|
||||
'key2' => ['contains' => [
|
||||
'key2:1' => ['contains' => [
|
||||
'key2:1:1' => ['default' => 'value2:1:2:1'],
|
||||
'key2:1:2' => ['contains' => [
|
||||
'key2:1:2:1' => ['default' => 'value2:1:2:1'],
|
||||
]],
|
||||
]],
|
||||
]],
|
||||
'key2' => [
|
||||
'contains' => [
|
||||
'key2:1' => [
|
||||
'contains' => [
|
||||
'key2:1:1' => ['default' => 'value2:1:2:1'],
|
||||
'key2:1:2' => [
|
||||
'contains' => ['key2:1:2:1' => ['default' => 'value2:1:2:1']],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'expected' => [
|
||||
'key2' => [
|
||||
'key2:1' => [
|
||||
'key2:1:1' => 'value0',
|
||||
'key2:1:2' => [
|
||||
'key2:1:2:1' => 'value1',
|
||||
],
|
||||
'key2:1:2' => ['key2:1:2:1' => 'value1'],
|
||||
],
|
||||
],
|
||||
],
|
||||
@@ -261,10 +258,12 @@ class PluginBaseTest extends UnitTestCase {
|
||||
'storage' => [],
|
||||
'definition' => [
|
||||
'key' => ['default' => 'value'],
|
||||
'key2' => ['contains' => [
|
||||
'key2:1' => ['default' => 'value2:1'],
|
||||
'key2:2' => ['default' => 'value2:2'],
|
||||
]],
|
||||
'key2' => [
|
||||
'contains' => [
|
||||
'key2:1' => ['default' => 'value2:1'],
|
||||
'key2:2' => ['default' => 'value2:2'],
|
||||
],
|
||||
],
|
||||
],
|
||||
'expected' => [
|
||||
'key' => 'value',
|
||||
|
||||
@@ -311,7 +311,7 @@ class ViewExecutableTest extends UnitTestCase {
|
||||
];
|
||||
$this->assertEquals($expected, $view->buildThemeFunctions('test_hook'));
|
||||
|
||||
//Change the name of the display plugin and make sure that is in the array.
|
||||
// Change the name of the display plugin and make sure that is in the array.
|
||||
$view->display_handler->display['display_plugin'] = 'default2';
|
||||
|
||||
$expected = [
|
||||
@@ -362,14 +362,16 @@ class ViewExecutableTest extends UnitTestCase {
|
||||
foreach (['field', 'filter', 'argument', 'sort'] as $handler_type) {
|
||||
$display->expects($this->atLeastOnce())
|
||||
->method('setOption')
|
||||
->with($this->callback(function($argument) {
|
||||
->with($this->callback(function ($argument) {
|
||||
return $argument;
|
||||
}), ['test_field' => [
|
||||
'id' => 'test_field',
|
||||
'table' => 'test_entity',
|
||||
'field' => 'test_field',
|
||||
'plugin_id' => 'standard',
|
||||
]]);
|
||||
}), [
|
||||
'test_field' => [
|
||||
'id' => 'test_field',
|
||||
'table' => 'test_entity',
|
||||
'field' => 'test_field',
|
||||
'plugin_id' => 'standard',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
foreach (['field', 'filter', 'argument', 'sort'] as $handler_type) {
|
||||
@@ -403,16 +405,18 @@ class ViewExecutableTest extends UnitTestCase {
|
||||
foreach (['field', 'filter', 'argument', 'sort'] as $handler_type) {
|
||||
$display->expects($this->atLeastOnce())
|
||||
->method('setOption')
|
||||
->with($this->callback(function($argument) {
|
||||
->with($this->callback(function ($argument) {
|
||||
return $argument;
|
||||
}), ['test_field' => [
|
||||
'id' => 'test_field',
|
||||
'table' => 'test_entity',
|
||||
'field' => 'test_field',
|
||||
'entity_type' => 'test_entity_type',
|
||||
'entity_field' => 'test_field',
|
||||
'plugin_id' => 'standard',
|
||||
]]);
|
||||
}), [
|
||||
'test_field' => [
|
||||
'id' => 'test_field',
|
||||
'table' => 'test_entity',
|
||||
'field' => 'test_field',
|
||||
'entity_type' => 'test_entity_type',
|
||||
'entity_field' => 'test_field',
|
||||
'plugin_id' => 'standard',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
foreach (['field', 'filter', 'argument', 'sort'] as $handler_type) {
|
||||
|
||||
@@ -97,7 +97,7 @@ class ViewsDataHelperTest extends UnitTestCase {
|
||||
foreach ($handler_types as $handler_type) {
|
||||
$fields = $data_helper->fetchFields('views_test_data', $handler_type);
|
||||
$expected_keys = $expected[$handler_type];
|
||||
array_walk($expected_keys, function(&$item) {
|
||||
array_walk($expected_keys, function (&$item) {
|
||||
$item = "views_test_data.$item";
|
||||
});
|
||||
$this->assertEquals($expected_keys, array_keys($fields), "Handlers of type $handler_type are not listed as expected");
|
||||
@@ -108,7 +108,7 @@ class ViewsDataHelperTest extends UnitTestCase {
|
||||
$fields = $data_helper->fetchFields('views_test_data', 'area', FALSE, $sub_type);
|
||||
|
||||
$expected_keys = $expected[$sub_type];
|
||||
array_walk($expected_keys, function(&$item) {
|
||||
array_walk($expected_keys, function (&$item) {
|
||||
$item = "views_test_data.$item";
|
||||
});
|
||||
$this->assertEquals($expected_keys, array_keys($fields), "Sub_type $sub_type is not filtered as expected.");
|
||||
|
||||
+3
-3
@@ -4,8 +4,8 @@ description: Theme for testing Views rendering of checkboxes.
|
||||
# version: VERSION
|
||||
# core: 8.x
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
+6
-1
@@ -11,5 +11,10 @@ use Drupal\Core\Form\FormStateInterface;
|
||||
* Changes an exposed "type" filter from a multi-select to checkboxes.
|
||||
*/
|
||||
function views_test_checkboxes_theme_form_views_exposed_form_alter(&$form, FormStateInterface $form_state) {
|
||||
$form['type']['#type'] = 'checkboxes';
|
||||
if (isset($form['type'])) {
|
||||
$form['type']['#type'] = 'checkboxes';
|
||||
}
|
||||
if (isset($form['tid'])) {
|
||||
$form['tid']['#type'] = 'checkboxes';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ description: Theme for testing Views functionality.
|
||||
# version: VERSION
|
||||
# core: 8.x
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
Reference in New Issue
Block a user