Move into nested docroot

This commit is contained in:
Rob Davies 2017-02-13 15:31:17 +00:00
parent 83a0d3a149
commit c8b70abde9
13405 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,7 @@
taxonomy.vocabulary.*.third_party.taxonomy_crud:
type: mapping
label: 'Schema for taxonomy_crud module additions to vocabulary entity'
mapping:
foo:
type: string
label: 'Label for foo'

View file

@ -0,0 +1,8 @@
name: 'Taxonomy CRUD tests'
type: module
description: 'Provides 3rd party settings for vocabulary.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- taxonomy

View file

@ -0,0 +1,15 @@
<?php
/**
* @file
* Provides hook implementations for testing purposes.
*/
use Drupal\taxonomy\VocabularyInterface;
/**
* Implements hook_ENTITY_TYPE_presave() for taxonomy_vocabulary entities.
*/
function taxonomy_crud_taxonomy_vocabulary_presave(VocabularyInterface $vocabulary) {
$vocabulary->setThirdPartySetting('taxonomy_crud', 'foo', 'bar');
}

View file

@ -0,0 +1,32 @@
id: taxonomy_term_stub_test
label: Taxonomy term stub
migration_tags:
- Import and rollback test
source:
plugin: embedded_data
data_rows:
-
id: 1
vocab: 1
name: music
parent: 2
ids:
id:
type: integer
process:
tid: id
vid: vocab
name: name
weight: weight
parent:
plugin: migration
migration: taxonomy_term_stub_test
source: parent
destination:
plugin: entity:taxonomy_term
migration_dependencies:
required:
- vocabularies
provider:
- migrate_drupal
- taxonomy

View file

@ -0,0 +1,9 @@
name: 'Taxonomy Migrate stub test'
type: module
description: 'Provides a migration plugin for stub testing.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- taxonomy
- migrate

View file

@ -0,0 +1,8 @@
name: 'Taxonomy test'
type: module
description: 'Provides test hook implementations for taxonomy tests'
package: Testing
version: VERSION
core: 8.x
dependencies:
- taxonomy

View file

@ -0,0 +1,38 @@
<?php
/**
* @file
* Provides test hook implementations for taxonomy tests.
*/
use Drupal\Core\Database\Query\AlterableInterface;
/**
* Implements hook_query_alter().
*/
function taxonomy_test_query_alter(AlterableInterface $query) {
$value = \Drupal::state()->get(__FUNCTION__);
if (isset($value)) {
\Drupal::state()->set(__FUNCTION__, ++$value);
}
}
/**
* Implements hook_query_TAG_alter().
*/
function taxonomy_test_query_term_access_alter(AlterableInterface $query) {
$value = \Drupal::state()->get(__FUNCTION__);
if (isset($value)) {
\Drupal::state()->set(__FUNCTION__, ++$value);
}
}
/**
* Implements hook_query_TAG_alter().
*/
function taxonomy_test_query_taxonomy_term_access_alter(AlterableInterface $query) {
$value = \Drupal::state()->get(__FUNCTION__);
if (isset($value)) {
\Drupal::state()->set(__FUNCTION__, ++$value);
}
}

View file

@ -0,0 +1,9 @@
name: 'Taxonomy test views'
type: module
description: 'Provides default views for views taxonomy tests.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- taxonomy
- views

View file

@ -0,0 +1,258 @@
langcode: en
status: true
dependencies:
module:
- node
- taxonomy
- user
id: taxonomy_all_terms_test
label: taxonomy_all_terms_test
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: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: 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
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:
term_node_tid:
id: term_node_tid
table: node_field_data
field: term_node_tid
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
type: separator
separator: ', '
link_to_taxonomy: true
limit: false
vids:
tags: '0'
entity_type: node
plugin_id: taxonomy_index_tid
filters: { }
sorts:
nid:
id: nid
table: node
field: nid
relationship: none
group_type: group
admin_label: ''
order: ASC
exposed: false
expose:
label: ''
entity_type: node
entity_field: nid
plugin_id: standard
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }
display_extenders: { }
cache_metadata:
contexts:
- 'languages:language_interface'
- url.query_args
- 'user.node_grants:view'
- user.permissions
max-age: 0
page_1:
display_plugin: page
id: page_1
display_title: Page
position: 1
display_options:
display_extenders: { }
path: taxonomy_all_terms_test
cache_metadata:
contexts:
- 'languages:language_interface'
- url.query_args
- 'user.node_grants:view'
- user.permissions
cacheable: false
page_2:
display_plugin: page
id: page_2
display_title: 'Token tests'
position: 2
display_options:
display_extenders: { }
display_description: ''
fields:
term_node_tid:
id: term_node_tid
table: node_field_data
field: term_node_tid
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: true
text: "Term: {{ term_node_tid }}<br />\nThe taxonomy term ID for the term: {{ term_node_tid__tid }}<br />\nThe taxonomy term name for the term: {{ term_node_tid__name }}<br />\nThe machine name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary_vid }}<br />\nThe name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary }}<br />"
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
type: separator
separator: '<br />'
link_to_taxonomy: false
limit: false
vids:
tags: '0'
entity_type: node
plugin_id: taxonomy_index_tid
defaults:
fields: false
path: taxonomy_all_terms_token_test
cache_metadata:
contexts:
- 'languages:language_interface'
- url.query_args
- 'user.node_grants:view'
- user.permissions
max-age: 0

View file

@ -0,0 +1,172 @@
langcode: en
status: true
dependencies:
module:
- taxonomy
- user
id: taxonomy_default_argument_test
label: taxonomy_default_argument_test
module: views
description: ''
tag: ''
base_table: taxonomy_term_field_data
base_field: tid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: 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, 20, 40, 60'
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
options:
grouping: { }
row_class: ''
default_row_class: true
uses_fields: false
row:
type: 'entity:taxonomy_term'
options:
relationship: none
view_mode: default
fields:
name:
id: name
table: taxonomy_term_field_data
field: name
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
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
plugin_id: field
type: string
settings:
link_to_entity: true
entity_type: taxonomy_term
entity_field: name
filters: { }
sorts: { }
header: { }
footer: { }
empty: { }
relationships: { }
arguments:
tid:
id: tid
table: taxonomy_term_field_data
field: tid
relationship: none
group_type: group
admin_label: ''
default_action: default
exception:
value: all
title_enable: false
title: All
title_enable: false
title: ''
default_argument_type: taxonomy_tid
default_argument_options:
term_page: '1'
node: true
anyall: ','
limit: false
vids: { }
default_argument_skip_url: false
summary_options:
base_path: ''
count: true
items_per_page: 25
override: false
summary:
sort_order: asc
number_of_records: 0
format: default_summary
specify_validation: false
validate:
type: none
fail: 'not found'
validate_options: { }
break_phrase: false
not: false
plugin_id: taxonomy
entity_type: taxonomy_term
entity_field: tid
rendering_language: '***LANGUAGE_entity_translation***'
page_1:
display_plugin: page
id: page_1
display_title: Page
position: null
display_options:
path: taxonomy_default_argument_test

View file

@ -0,0 +1,227 @@
langcode: en
status: true
dependencies:
module:
- node
- taxonomy
- user
id: test_argument_taxonomy_index_tid_depth
label: test_argument_taxonomy_index_tid_depth
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: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: 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
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_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:
value: '1'
table: node_field_data
field: status
plugin_id: boolean
entity_type: node
entity_field: status
id: status
expose:
operator: ''
group: 1
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
header: { }
footer: { }
empty: { }
relationships: { }
arguments:
term_node_tid_depth:
id: term_node_tid_depth
table: node_field_data
field: term_node_tid_depth
relationship: none
group_type: group
admin_label: ''
default_action: ignore
exception:
value: all
title_enable: false
title: All
title_enable: true
title: '{{ arguments.term_node_tid_depth }}'
default_argument_type: fixed
default_argument_options:
argument: ''
default_argument_skip_url: false
summary_options:
base_path: ''
count: true
items_per_page: 25
override: false
summary:
sort_order: asc
number_of_records: 0
format: default_summary
specify_validation: false
validate:
type: none
fail: 'not found'
validate_options: { }
depth: 0
break_phrase: false
use_taxonomy_term_path: false
entity_type: node
plugin_id: taxonomy_index_tid_depth
display_extenders: { }
cache_metadata:
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- url.query_args
- 'user.node_grants:view'
- user.permissions
cacheable: false
page_1:
display_plugin: page
id: page_1
display_title: Page
position: 1
display_options:
display_extenders: { }
path: test_argument_taxonomy_index_tid_depth
cache_metadata:
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- url.query_args
- 'user.node_grants:view'
- user.permissions
cacheable: false

View file

@ -0,0 +1,424 @@
langcode: en
status: true
dependencies:
module:
- taxonomy
- user
id: test_field_filters
label: 'Test field filters'
module: views
description: ''
tag: ''
base_table: taxonomy_term_field_data
base_field: tid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: none
options:
items_per_page: 0
offset: 0
style:
type: default
row:
type: 'entity:taxonomy_term'
fields:
name:
id: name
table: taxonomy_term_field_data
field: name
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
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
plugin_id: field
type: string
settings:
link_to_entity: true
entity_type: taxonomy_term
entity_field: name
filters:
name:
id: name
table: taxonomy_term_field_data
field: name
relationship: none
group_type: group
admin_label: ''
operator: contains
value: Comida
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: string
entity_type: taxonomy_term
entity_field: name
sorts: { }
title: 'Name filter page'
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }
page_dc:
display_plugin: page
id: page_dc
display_title: 'Description Comida'
position: 3
display_options:
display_description: ''
path: test-desc-filter
filters:
description__value:
id: description__value
table: taxonomy_term_field_data
field: description__value
relationship: none
group_type: group
admin_label: ''
operator: contains
value: Comida
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: string
entity_type: taxonomy_term
entity_field: description
defaults:
filters: false
filter_groups: false
title: false
filter_groups:
operator: AND
groups:
1: AND
title: 'Description filter page'
page_dp:
display_plugin: page
id: page_dp
display_title: 'Description Comida'
position: 3
display_options:
display_description: ''
path: test-desc-paris
filters:
description__value:
id: description__value
table: taxonomy_term_field_data
field: description__value
relationship: none
group_type: group
admin_label: ''
operator: contains
value: Paris
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: string
entity_type: taxonomy_term
entity_field: description
defaults:
filters: false
filter_groups: false
title: false
filter_groups:
operator: AND
groups:
1: AND
title: 'Description filter page'
page_fc:
display_plugin: page
id: page_fc
display_title: 'Field Comida'
position: 3
display_options:
display_description: ''
path: test-field-filter
filters:
field_foo_value:
id: field_foo_value
table: taxonomy_term__field_foo
field: field_foo_value
relationship: none
group_type: group
admin_label: ''
operator: contains
value: Comida
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: string
entity_type: taxonomy_term
entity_field: field_foo
defaults:
filters: false
filter_groups: false
title: false
filter_groups:
operator: AND
groups:
1: AND
title: 'Field filter page'
page_fp:
display_plugin: page
id: page_fp
display_title: 'Field Paris'
position: 3
display_options:
display_description: ''
path: test-field-paris
filters:
field_foo_value:
id: field_foo_value
table: taxonomy_term__field_foo
field: field_foo_value
relationship: none
group_type: group
admin_label: ''
operator: contains
value: Paris
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: string
entity_type: taxonomy_term
entity_field: field_foo
defaults:
filters: false
filter_groups: false
title: false
filter_groups:
operator: AND
groups:
1: AND
title: 'Field filter page'
page_nc:
display_plugin: page
id: page_nc
display_title: 'Name Comida'
position: 1
display_options:
path: test-name-filter
display_description: ''
page_np:
display_plugin: page
id: page_np
display_title: 'Name Paris'
position: 1
display_options:
path: test-name-paris
display_description: ''
filters:
name:
id: name
table: taxonomy_term_field_data
field: name
relationship: none
group_type: group
admin_label: ''
operator: contains
value: Paris
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: string
entity_type: taxonomy_term
entity_field: name
defaults:
filters: false
filter_groups: false
filter_groups:
operator: AND
groups:
1: AND

View file

@ -0,0 +1,186 @@
langcode: en
status: true
dependencies:
module:
- node
- taxonomy
- user
id: test_filter_taxonomy_index_tid
label: test_filter_taxonomy_index_tid
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: 1
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: 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
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_data
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
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
plugin_id: field
entity_type: node
entity_field: title
filters:
status:
value: '1'
table: node_field_data
field: status
id: status
expose:
operator: '0'
group: 1
plugin_id: boolean
entity_type: node
entity_field: status
tid:
id: tid
table: taxonomy_index
field: tid
relationship: none
group_type: group
admin_label: ''
operator: or
value:
- 2
group: 1
exposed: false
expose:
operator_id: '0'
label: ''
description: ''
use_operator: false
operator: ''
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
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: tags
hierarchy: true
error_message: true
plugin_id: taxonomy_index_tid
sorts: { }
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }
page_1:
display_plugin: page
id: page_1
display_title: Page
position: 2
display_options:
display_extenders: { }
path: test-filter-taxonomy-index-tid

View file

@ -0,0 +1,187 @@
langcode: en
status: true
dependencies:
module:
- node
- taxonomy
- user
id: test_filter_taxonomy_index_tid__non_existing_dependency
label: test_filter_taxonomy_index_tid__non_existing_dependency
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: 1
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: 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
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_data
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
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
plugin_id: field
entity_type: node
entity_field: title
filters:
status:
value: '1'
table: node_field_data
field: status
id: status
expose:
operator: '0'
group: 1
plugin_id: boolean
entity_type: node
entity_field: status
tid:
id: tid
table: taxonomy_index
field: tid
relationship: none
group_type: group
admin_label: ''
operator: or
value:
- 3
- 4
group: 1
exposed: false
expose:
operator_id: '0'
label: ''
description: ''
use_operator: false
operator: ''
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
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: tags
hierarchy: true
error_message: true
plugin_id: taxonomy_index_tid
sorts: { }
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }
page_1:
display_plugin: page
id: page_1
display_title: Page
position: 2
display_options:
display_extenders: { }
path: test-filter-taxonomy-index-tid

View file

@ -0,0 +1,178 @@
langcode: en
status: true
dependencies:
module:
- node
- taxonomy
- user
id: test_filter_taxonomy_index_tid_depth
label: test_filter_taxonomy_index_tid_depth
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: 1
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: 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
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_data
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
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
plugin_id: field
entity_type: node
entity_field: title
filters:
status:
value: '1'
table: node_field_data
field: status
id: status
expose:
operator: '0'
group: 1
plugin_id: boolean
entity_type: node
entity_field: status
tid_depth:
id: tid_depth
table: node_field_data
field: term_node_tid_depth
relationship: none
group_type: group
admin_label: ''
operator: or
value: { }
group: 1
exposed: false
expose:
operator_id: '0'
label: ''
description: ''
use_operator: false
operator: ''
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
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: views_testing_tags
hierarchy: true
depth: -2
error_message: true
plugin_id: taxonomy_index_tid_depth
sorts: { }
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }

View file

@ -0,0 +1,83 @@
langcode: en
status: true
dependencies:
module:
- node
- taxonomy
- user
id: test_groupwise_term
label: test_groupwise
module: views
description: ''
tag: default
base_table: taxonomy_term_field_data
base_field: tid
core: 8.0-dev
display:
default:
display_options:
access:
type: perm
cache:
type: tag
exposed_form:
type: basic
fields:
name:
field: name
id: name
table: taxonomy_term_field_data
plugin_id: term_name
type: string
settings:
link_to_entity: true
convert_spaces: false
entity_type: taxonomy_term
entity_field: name
nid:
field: nid
id: nid
relationship: tid_representative
table: node_field_data
plugin_id: node
entity_type: node
entity_field: nid
pager:
options:
items_per_page: 10
type: full
query:
type: views_query
relationships:
tid_representative:
admin_label: 'Representative node'
field: tid_representative
group_type: group
id: tid_representative
relationship: none
required: false
subquery_namespace: ''
subquery_order: DESC
subquery_regenerate: true
subquery_sort: node_field_data.nid
subquery_view: ''
table: taxonomy_term_field_data
plugin_id: groupwise_max
row:
type: fields
sorts:
tid:
field: tid
id: tid
order: DESC
table: taxonomy_term_field_data
plugin_id: standard
entity_type: taxonomy_term
entity_field: tid
style:
type: default
title: test_groupwise
display_plugin: default
display_title: Master
id: default
position: 0

View file

@ -0,0 +1,89 @@
langcode: en
status: true
dependencies:
module:
- node
- taxonomy
- user
id: test_taxonomy_node_term_data
label: test_taxonomy_node_term_data
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: '8'
display:
default:
display_options:
access:
type: perm
arguments:
tid:
default_argument_type: fixed
field: tid
id: tid
relationship: term_node_tid
summary:
format: default_summary
number_of_records: 0
summary_options:
items_per_page: 25
table: taxonomy_term_field_data
plugin_id: taxonomy
entity_type: taxonomy_term
entity_field: tid
tid_1:
default_argument_type: fixed
field: tid
id: tid_1
relationship: term_node_tid_1
summary:
format: default_summary
number_of_records: 0
summary_options:
items_per_page: 25
table: taxonomy_term_field_data
plugin_id: taxonomy
entity_type: taxonomy_term
entity_field: tid
cache:
type: tag
exposed_form:
type: basic
pager:
type: full
query:
type: views_query
relationships:
term_node_tid:
field: term_node_tid
id: term_node_tid
admin_label: 'Term #1'
table: node_field_data
vids: {}
plugin_id: node_term_data
term_node_tid_1:
field: term_node_tid
id: term_node_tid_1
admin_label: 'Term #2'
table: node_field_data
vids: {}
plugin_id: node_term_data
sorts:
nid:
field: nid
id: nid
order: DESC
table: node_field_data
plugin_id: standard
entity_type: node
entity_field: nid
style:
type: default
row:
type: 'entity:node'
display_plugin: default
display_title: Master
id: default
position: 0

View file

@ -0,0 +1,134 @@
langcode: en
status: true
dependencies:
module:
- taxonomy
- user
id: test_taxonomy_parent
label: test_taxonomy_parent
module: views
description: ''
tag: ''
base_table: taxonomy_term_data
base_field: tid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: 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
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:
name:
id: name
table: taxonomy_term_data
field: name
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
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
plugin_id: field
type: string
settings:
link_to_entity: true
entity_type: taxonomy_term
entity_field: name
filters: { }
sorts: { }
header: { }
footer: { }
empty: { }
relationships:
parent:
id: parent
table: taxonomy_term_hierarchy
field: parent
relationship: none
group_type: group
admin_label: Parent
required: true
plugin_id: standard
arguments: { }

View file

@ -0,0 +1,158 @@
langcode: en
status: true
dependencies:
module:
- taxonomy
- user
id: test_taxonomy_term_name
label: test_taxonomy_term_name
module: views
description: ''
tag: ''
base_table: taxonomy_term_field_data
base_field: tid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: 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, 20, 40, 60'
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
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:
name:
id: name
table: taxonomy_term_field_data
field: name
relationship: none
group_type: group
admin_label: ''
label: Name
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: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
plugin_id: term_name
type: string
settings:
link_to_entity: false
convert_spaces: false
entity_type: taxonomy_term
entity_field: name
filters: { }
sorts:
tid:
id: tid
table: taxonomy_term_field_data
field: tid
relationship: none
group_type: group
admin_label: ''
order: ASC
exposed: false
expose:
label: ''
plugin_id: standard
entity_type: taxonomy_term
entity_field: tid
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }

View file

@ -0,0 +1,202 @@
langcode: en
status: true
dependencies:
module:
- node
- taxonomy
- user
id: test_taxonomy_term_relationship
label: test_taxonomy_term_relationship
module: views
description: ''
tag: ''
base_table: taxonomy_term_field_data
base_field: tid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: 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
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:
tid:
id: tid
table: taxonomy_term_field_data
field: tid
entity_type: taxonomy_term
entity_field: tid
plugin_id: field
tid_1:
id: tid_1
table: taxonomy_term_field_data
field: tid
relationship: parent
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: taxonomy_term
entity_field: tid
plugin_id: field
nid:
id: nid
table: node_field_data
field: nid
entity_type: node
entity_field: nid
plugin_id: field
relationship: nid
filters: { }
sorts:
tid:
id: tid
table: taxonomy_term_field_data
field: tid
entity_type: taxonomy_term
entity_field: tid
plugin_id: standard
header: { }
footer: { }
empty: { }
relationships:
nid:
id: nid
table: taxonomy_index
field: nid
relationship: none
group_type: group
admin_label: node
required: false
plugin_id: standard
parent:
id: parent
table: taxonomy_term_hierarchy
field: parent
relationship: none
group_type: group
admin_label: Parent
required: false
plugin_id: standard
arguments: { }
display_extenders: { }
cache_metadata:
contexts:
- 'languages:language_content'
- 'languages:language_interface'
max-age: 0

View file

@ -0,0 +1,157 @@
langcode: en
status: true
dependencies:
module:
- taxonomy
- user
id: test_taxonomy_tid_field
label: test_taxonomy_tid_field
module: views
description: ''
tag: ''
base_table: taxonomy_term_field_data
base_field: tid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: 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, 20, 40, 60'
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
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:
name:
id: name
table: taxonomy_term_field_data
field: name
relationship: none
group_type: group
admin_label: ''
label: Name
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: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
plugin_id: field
type: string
settings:
link_to_entity: true
entity_type: taxonomy_term
entity_field: name
filters: { }
sorts:
tid:
id: tid
table: taxonomy_term_field_data
field: tid
relationship: none
group_type: group
admin_label: ''
order: ASC
exposed: false
expose:
label: ''
plugin_id: standard
entity_type: taxonomy_term
entity_field: tid
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }

View file

@ -0,0 +1,19 @@
<?php
namespace Drupal\vocabulary_serialization_test;
use Drupal\Core\Cache\CacheableResponse;
use Drupal\taxonomy\VocabularyInterface;
class VocabularyResponse extends CacheableResponse {
/**
* @var \Drupal\taxonomy\VocabularyInterface
*/
protected $vocabulary;
public function setVocabulary(VocabularyInterface $vocabulary) {
$this->vocabulary = $vocabulary;
}
}

View file

@ -0,0 +1,15 @@
<?php
namespace Drupal\vocabulary_serialization_test;
use Drupal\taxonomy\VocabularyInterface;
class VocabularySerializationTestController {
public function vocabularyResponse(VocabularyInterface $taxonomy_vocabulary) {
$response = new VocabularyResponse('this is the output');
$response->setVocabulary($taxonomy_vocabulary);
return $response;
}
}

View file

@ -0,0 +1,7 @@
name: 'Vocabulary serialization test'
type: module
package: Testing
version: VERSION
core: 8.x
dependencies:
- taxonomy

View file

@ -0,0 +1,6 @@
vocabulary_serialization_test:
path: '/vocabulary_serialization_test/{taxonomy_vocabulary}'
defaults:
_controller: 'Drupal\vocabulary_serialization_test\VocabularySerializationTestController::vocabularyResponse'
requirements:
_access: 'TRUE'

View file

@ -0,0 +1,47 @@
<?php
namespace Drupal\Tests\taxonomy\Functional;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\Tests\BrowserTestBase;
/**
* Regression test for https://www.drupal.org/node/2807263.
*
* When a Vocabulary entity is unserialized before the modules have been loaded
* (which happens in the KernelPreHandle Stack middleware), then the constants
* that the Vocabulary entity uses are not yet available because they are set in
* taxonomy.module. This means that for example the PageCache middleware cannot
* load any cached Vocabulary entity, because unserialization will fail.
*
* @group taxonomy
*/
class VocabularySerializationTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy', 'vocabulary_serialization_test'];
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
Vocabulary::create(['vid' => 'test'])->save();
}
public function testSerialization() {
$this->drupalGet('/vocabulary_serialization_test/test');
$this->assertSession()->statusCodeEquals(200);
$this->assertSame('this is the output', $this->getSession()->getPage()->getContent());
$this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
$this->drupalGet('/vocabulary_serialization_test/test');
$this->assertSession()->statusCodeEquals(200);
$this->assertSame('this is the output', $this->getSession()->getPage()->getContent());
$this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
}
}

View file

@ -0,0 +1,121 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\KernelTests\KernelTestBase;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\Entity\Vocabulary;
/**
* Kernel tests for taxonomy forward revisions.
*
* @group taxonomy
*/
class ForwardRevisionTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy', 'node', 'user', 'text', 'field', 'system'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('user');
$this->installEntitySchema('node');
$this->installEntitySchema('taxonomy_term');
$this->installSchema('node', 'node_access');
}
/**
* Tests that the taxonomy index work correctly with forward revisions.
*/
public function testTaxonomyIndexWithForwardRevision() {
\Drupal::configFactory()->getEditable('taxonomy.settings')->set('maintain_index_table', TRUE)->save();
Vocabulary::create([
'name' => 'test',
'vid' => 'test',
])->save();
$term = Term::create([
'name' => 'term1',
'vid' => 'test',
]);
$term->save();
$term2 = Term::create([
'name' => 'term2',
'vid' => 'test',
]);
$term2->save();
NodeType::create([
'type' => 'page',
])->save();
FieldStorageConfig::create([
'entity_type' => 'node',
'field_name' => 'field_tags',
'type' => 'entity_reference',
'settings' => [
'target_type' => 'taxonomy_term',
],
])->save();
FieldConfig::create([
'field_name' => 'field_tags',
'entity_type' => 'node',
'bundle' => 'page',
])->save();
$node = Node::create([
'type' => 'page',
'title' => 'test_title',
'field_tags' => [$term->id()],
]);
$node->save();
$taxonomy_index = $this->getTaxonomyIndex();
$this->assertEquals($term->id(), $taxonomy_index[$node->id()]->tid);
// Normal new revision.
$node->setNewRevision(TRUE);
$node->isDefaultRevision(TRUE);
$node->field_tags->target_id = $term2->id();
$node->save();
$taxonomy_index = $this->getTaxonomyIndex();
$this->assertEquals($term2->id(), $taxonomy_index[$node->id()]->tid);
// Check that saving a forward (non-default) revision does not affect the
// taxonomy index.
$node->setNewRevision(TRUE);
$node->isDefaultRevision(FALSE);
$node->field_tags->target_id = $term->id();
$node->save();
$taxonomy_index = $this->getTaxonomyIndex();
$this->assertEquals($term2->id(), $taxonomy_index[$node->id()]->tid);
// Check that making the previously created forward-revision the default
// revision updates the taxonomy index correctly.
$node->isDefaultRevision(TRUE);
$node->save();
$taxonomy_index = $this->getTaxonomyIndex();
$this->assertEquals($term->id(), $taxonomy_index[$node->id()]->tid);
}
protected function getTaxonomyIndex() {
return \Drupal::database()->select('taxonomy_index')
->fields('taxonomy_index')
->execute()
->fetchAllAssoc('nid');
}
}

View file

@ -0,0 +1,40 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate;
use Drupal\config\Tests\SchemaCheckTestTrait;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Upgrade variables to taxonomy.settings.yml.
*
* @group migrate_drupal_6
*/
class MigrateTaxonomyConfigsTest extends MigrateDrupal6TestBase {
use SchemaCheckTestTrait;
/**
* {@inheritdoc}
*/
public static $modules = array('taxonomy');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('taxonomy_settings');
}
/**
* Tests migration of taxonomy variables to taxonomy.settings.yml.
*/
public function testTaxonomySettings() {
$config = $this->config('taxonomy.settings');
$this->assertIdentical(100, $config->get('terms_per_page_admin'));
$this->assertIdentical(FALSE, $config->get('override_selector'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'taxonomy.settings', $config->get());
}
}

View file

@ -0,0 +1,86 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate;
use Drupal\migrate\MigrateExecutable;
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
use Drupal\migrate_drupal\Tests\StubTestTrait;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\Entity\Vocabulary;
/**
* Test stub creation for taxonomy terms.
*
* @group taxonomy
*/
class MigrateTaxonomyTermStubTest extends MigrateDrupalTestBase {
use StubTestTrait;
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy', 'text', 'taxonomy_term_stub_test'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('taxonomy_term');
}
/**
* Tests creation of taxonomy term stubs.
*/
public function testStub() {
Vocabulary::create([
'vid' => 'test_vocabulary',
'name' => 'Test vocabulary',
])->save();
$this->performStubTest('taxonomy_term');
}
/**
* Tests creation of stubs when weight is mapped.
*/
public function testStubWithWeightMapping() {
// Create a vocabulary via migration for the terms to reference.
$vocabulary_data_rows = [
['id' => '1', 'name' => 'tags'],
];
$ids = ['id' => ['type' => 'integer']];
$definition = [
'migration_tags' => ['Stub test'],
'source' => [
'plugin' => 'embedded_data',
'data_rows' => $vocabulary_data_rows,
'ids' => $ids,
],
'process' => [
'vid' => 'id',
'name' => 'name',
],
'destination' => ['plugin' => 'entity:taxonomy_vocabulary'],
];
$vocabulary_migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$vocabulary_executable = new MigrateExecutable($vocabulary_migration, $this);
$vocabulary_executable->import();
// We have a term referencing an unmigrated parent, forcing a stub to be
// created.
$migration = $this->getMigration('taxonomy_term_stub_test');
$term_executable = new MigrateExecutable($migration, $this);
$term_executable->import();
$this->assertTrue($migration->getIdMap()->getRowBySource(['2']), 'Stub row exists in the ID map table');
// Load the referenced term, which should exist as a stub.
/** @var \Drupal\Core\Entity\ContentEntityBase $stub_entity */
$stub_entity = Term::load(2);
$this->assertTrue($stub_entity, 'Stub successfully created');
if ($stub_entity) {
$this->assertIdentical(count($stub_entity->validate()), 0, 'Stub is a valid entity');
}
}
}

View file

@ -0,0 +1,107 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\taxonomy\Entity\Term;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Upgrade taxonomy terms.
*
* @group migrate_drupal_6
*/
class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('taxonomy');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('taxonomy_term');
$this->executeMigrations(['d6_taxonomy_vocabulary', 'd6_taxonomy_term']);
}
/**
* Tests the Drupal 6 taxonomy term to Drupal 8 migration.
*/
public function testTaxonomyTerms() {
$expected_results = array(
'1' => array(
'source_vid' => 1,
'vid' => 'vocabulary_1_i_0_',
'weight' => 0,
'parent' => array(0),
),
'2' => array(
'source_vid' => 2,
'vid' => 'vocabulary_2_i_1_',
'weight' => 3,
'parent' => array(0),
),
'3' => array(
'source_vid' => 2,
'vid' => 'vocabulary_2_i_1_',
'weight' => 4,
'parent' => array(2),
),
'4' => array(
'source_vid' => 3,
'vid' => 'vocabulary_3_i_2_',
'weight' => 6,
'parent' => array(0),
),
'5' => array(
'source_vid' => 3,
'vid' => 'vocabulary_3_i_2_',
'weight' => 7,
'parent' => array(4),
),
'6' => array(
'source_vid' => 3,
'vid' => 'vocabulary_3_i_2_',
'weight' => 8,
'parent' => array(4, 5),
),
);
$terms = Term::loadMultiple(array_keys($expected_results));
// Find each term in the tree.
$storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
$vids = array_unique(array_column($expected_results, 'vid'));
$tree_terms = [];
foreach ($vids as $vid) {
foreach ($storage->loadTree($vid) as $term) {
$tree_terms[$term->tid] = $term;
}
}
foreach ($expected_results as $tid => $values) {
/** @var Term $term */
$term = $terms[$tid];
$this->assertIdentical("term {$tid} of vocabulary {$values['source_vid']}", $term->name->value);
$this->assertIdentical("description of term {$tid} of vocabulary {$values['source_vid']}", $term->description->value);
$this->assertIdentical($values['vid'], $term->vid->target_id);
$this->assertIdentical((string) $values['weight'], $term->weight->value);
if ($values['parent'] === array(0)) {
$this->assertNull($term->parent->target_id);
}
else {
$parents = array();
foreach (\Drupal::entityManager()->getStorage('taxonomy_term')->loadParents($tid) as $parent) {
$parents[] = (int) $parent->id();
}
$this->assertIdentical($parents, $values['parent']);
}
$this->assertArrayHasKey($tid, $tree_terms, "Term $tid exists in vocabulary tree");
$tree_term = $tree_terms[$tid];
$this->assertEquals($values['parent'], $tree_term->parents, "Term $tid has correct parents in vocabulary tree");
}
}
}

View file

@ -0,0 +1,48 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Migrate taxonomy vocabularies to taxonomy.vocabulary.*.yml.
*
* @group migrate_drupal_6
*/
class MigrateTaxonomyVocabularyTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('taxonomy');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d6_taxonomy_vocabulary');
}
/**
* Tests the Drupal 6 taxonomy vocabularies to Drupal 8 migration.
*/
public function testTaxonomyVocabulary() {
for ($i = 0; $i < 3; $i++) {
$j = $i + 1;
$vocabulary = Vocabulary::load("vocabulary_{$j}_i_{$i}_");
$this->assertIdentical($this->getMigration('d6_taxonomy_vocabulary')->getIdMap()->lookupDestinationID(array($j)), array($vocabulary->id()));
$this->assertIdentical("vocabulary $j (i=$i)", $vocabulary->label());
$this->assertIdentical("description of vocabulary $j (i=$i)", $vocabulary->getDescription());
$this->assertIdentical($i, $vocabulary->getHierarchy());
$this->assertIdentical(4 + $i, $vocabulary->get('weight'));
}
$vocabulary = Vocabulary::load('vocabulary_name_much_longer_than');
$this->assertIdentical('vocabulary name much longer than thirty two characters', $vocabulary->label());
$this->assertIdentical('description of vocabulary name much longer than thirty two characters', $vocabulary->getDescription());
$this->assertIdentical(3, $vocabulary->getHierarchy());
$this->assertIdentical(7, $vocabulary->get('weight'));
}
}

View file

@ -0,0 +1,40 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Upgrade taxonomy term node associations.
*
* @group migrate_drupal_6
*/
class MigrateTermNodeRevisionTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installSchema('node', ['node_access']);
$this->migrateContent(['revisions']);
$this->migrateTaxonomy();
$this->executeMigrations(['d6_term_node', 'd6_term_node_revision']);
}
/**
* Tests the Drupal 6 term-node revision association to Drupal 8 migration.
*/
public function testTermRevisionNode() {
$node = \Drupal::entityManager()->getStorage('node')->loadRevision(2);
$this->assertIdentical(2, count($node->vocabulary_3_i_2_));
$this->assertIdentical('4', $node->vocabulary_3_i_2_[0]->target_id);
$this->assertIdentical('5', $node->vocabulary_3_i_2_[1]->target_id);
}
}

View file

@ -0,0 +1,67 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
use Drupal\node\Entity\Node;
/**
* Upgrade taxonomy term node associations.
*
* @group migrate_drupal_6
*/
class MigrateTermNodeTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installSchema('node', ['node_access']);
$this->migrateContent();
$this->migrateTaxonomy();
}
/**
* Tests the Drupal 6 term-node association to Drupal 8 migration.
*/
public function testTermNode() {
// This is a base plugin id and we want to run all derivatives.
$this->executeMigrations(['d6_term_node']);
$this->container->get('entity.manager')
->getStorage('node')
->resetCache([1, 2]);
$nodes = Node::loadMultiple([1, 2]);
$node = $nodes[1];
$this->assertIdentical(1, count($node->vocabulary_1_i_0_));
$this->assertIdentical('1', $node->vocabulary_1_i_0_[0]->target_id);
$node = $nodes[2];
$this->assertIdentical(2, count($node->vocabulary_2_i_1_));
$this->assertIdentical('2', $node->vocabulary_2_i_1_[0]->target_id);
$this->assertIdentical('3', $node->vocabulary_2_i_1_[1]->target_id);
}
/**
* Tests that term associations are ignored when they belong to nodes which
* were not migrated.
*/
public function testSkipNonExistentNode() {
// Node 2 is migrated by d6_node__story, but we need to pretend that it
// failed, so record that in the map table.
$this->mockFailure('d6_node:story', ['nid' => 2, 'language' => 'en']);
// d6_term_node__2 should skip over node 2 (a.k.a. revision 3) because,
// according to the map table, it failed.
$migration = $this->getMigration('d6_term_node:2');
$this->executeMigration($migration);
$this->assertNull($migration->getIdMap()->lookupDestinationId(['vid' => 3])[0]);
}
}

View file

@ -0,0 +1,40 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Vocabulary entity display migration.
*
* @group migrate_drupal_6
*/
class MigrateVocabularyEntityDisplayTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['field', 'taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->migrateTaxonomy();
}
/**
* Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
*/
public function testVocabularyEntityDisplay() {
// Test that the field exists.
$component = EntityViewDisplay::load('node.page.default')->getComponent('tags');
$this->assertIdentical('entity_reference_label', $component['type']);
$this->assertIdentical(20, $component['weight']);
// Test the Id map.
$this->assertIdentical(array('node', 'article', 'default', 'tags'), $this->getMigration('d6_vocabulary_entity_display')->getIdMap()->lookupDestinationID(array(4, 'article')));
}
}

View file

@ -0,0 +1,45 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Vocabulary entity form display migration.
*
* @group migrate_drupal_6
*/
class MigrateVocabularyEntityFormDisplayTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->migrateTaxonomy();
}
/**
* Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
*/
public function testVocabularyEntityFormDisplay() {
// Test that the field exists.
$component = EntityFormDisplay::load('node.page.default')->getComponent('tags');
$this->assertIdentical('options_select', $component['type']);
$this->assertIdentical(20, $component['weight']);
// Test the Id map.
$this->assertIdentical(array('node', 'article', 'default', 'tags'), $this->getMigration('d6_vocabulary_entity_form_display')->getIdMap()->lookupDestinationID(array(4, 'article')));
// Test the term widget tags setting.
$entity_form_display = EntityFormDisplay::load('node.story.default');
$this->assertIdentical($entity_form_display->getComponent('vocabulary_1_i_0_')['type'], 'options_select');
$this->assertIdentical($entity_form_display->getComponent('vocabulary_2_i_1_')['type'], 'entity_reference_autocomplete_tags');
}
}

View file

@ -0,0 +1,59 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\field\Entity\FieldConfig;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Vocabulary field instance migration.
*
* @group migrate_drupal_6
*/
class MigrateVocabularyFieldInstanceTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->migrateTaxonomy();
}
/**
* Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
*/
public function testVocabularyFieldInstance() {
// Test that the field exists.
$field_id = 'node.article.tags';
$field = FieldConfig::load($field_id);
$this->assertIdentical($field_id, $field->id(), 'Field instance exists on article bundle.');
$this->assertIdentical('Tags', $field->label());
$this->assertTrue($field->isRequired(), 'Field is required');
// Test the page bundle as well.
$field_id = 'node.page.tags';
$field = FieldConfig::load($field_id);
$this->assertIdentical($field_id, $field->id(), 'Field instance exists on page bundle.');
$this->assertIdentical('Tags', $field->label());
$this->assertTrue($field->isRequired(), 'Field is required');
$settings = $field->getSettings();
$this->assertIdentical('default:taxonomy_term', $settings['handler'], 'The handler plugin ID is correct.');
$this->assertIdentical(['tags'], $settings['handler_settings']['target_bundles'], 'The target_bundles handler setting is correct.');
$this->assertIdentical(TRUE, $settings['handler_settings']['auto_create'], 'The "auto_create" setting is correct.');
$this->assertIdentical(array('node', 'article', 'tags'), $this->getMigration('d6_vocabulary_field_instance')->getIdMap()->lookupDestinationID(array(4, 'article')));
// Test the the field vocabulary_1_i_0_
$field_id = 'node.story.vocabulary_1_i_0_';
$field = FieldConfig::load($field_id);
$this->assertFalse($field->isRequired(), 'Field is not required');
}
}

View file

@ -0,0 +1,45 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Vocabulary field migration.
*
* @group migrate_drupal_6
*/
class MigrateVocabularyFieldTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->migrateTaxonomy();
}
/**
* Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
*/
public function testVocabularyField() {
// Test that the field exists.
$field_storage_id = 'node.tags';
/** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
$field_storage = FieldStorageConfig::load($field_storage_id);
$this->assertIdentical($field_storage_id, $field_storage->id());
$settings = $field_storage->getSettings();
$this->assertIdentical('taxonomy_term', $settings['target_type'], "Target type is correct.");
$this->assertIdentical(1, $field_storage->getCardinality(), "Field cardinality in 1.");
$this->assertIdentical(array('node', 'tags'), $this->getMigration('d6_vocabulary_field')->getIdMap()->lookupDestinationID(array(4)), "Test IdMap");
}
}

View file

@ -0,0 +1,79 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d7;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\FieldStorageConfigInterface;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
use Drupal\node\Entity\Node;
use Drupal\node\NodeInterface;
/**
* @group taxonomy
*/
class MigrateNodeTaxonomyTest extends MigrateDrupal7TestBase {
public static $modules = array(
'datetime',
'field',
'filter',
'image',
'link',
'node',
'taxonomy',
'telephone',
'text',
);
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installEntitySchema('taxonomy_term');
$this->installConfig(static::$modules);
$this->installSchema('node', ['node_access']);
$this->installSchema('system', ['sequences']);
$this->executeMigration('d7_node_type');
FieldStorageConfig::create(array(
'type' => 'entity_reference',
'field_name' => 'field_tags',
'entity_type' => 'node',
'settings' => array(
'target_type' => 'taxonomy_term',
),
'cardinality' => FieldStorageConfigInterface::CARDINALITY_UNLIMITED,
))->save();
FieldConfig::create(array(
'entity_type' => 'node',
'field_name' => 'field_tags',
'bundle' => 'article',
))->save();
$this->executeMigrations([
'd7_taxonomy_vocabulary',
'd7_taxonomy_term',
'd7_user_role',
'd7_user',
'd7_node:article',
]);
}
/**
* Test node migration from Drupal 7 to 8.
*/
public function testMigration() {
$node = Node::load(2);
$this->assertTrue($node instanceof NodeInterface);
$this->assertEqual(9, $node->field_tags[0]->target_id);
$this->assertEqual(14, $node->field_tags[1]->target_id);
$this->assertEqual(17, $node->field_tags[2]->target_id);
}
}

View file

@ -0,0 +1,146 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d7;
use Drupal\taxonomy\Entity\Term;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
use Drupal\taxonomy\TermInterface;
/**
* Upgrade taxonomy terms.
*
* @group taxonomy
*/
class MigrateTaxonomyTermTest extends MigrateDrupal7TestBase {
public static $modules = [
'comment',
'datetime',
'image',
'link',
'node',
'taxonomy',
'telephone',
'text',
];
/**
* The cached taxonomy tree items, keyed by vid and tid.
*
* @var array
*/
protected $treeData = [];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('taxonomy_term');
$this->installConfig(static::$modules);
$this->executeMigrations([
'd7_node_type',
'd7_comment_type',
'd7_field',
'd7_taxonomy_vocabulary',
'd7_field_instance',
'd7_taxonomy_term'
]);
}
/**
* Validate a migrated term contains the expected values.
*
* @param $id
* Entity ID to load and check.
* @param $expected_label
* The label the migrated entity should have.
* @param $expected_vid
* The parent vocabulary the migrated entity should have.
* @param string $expected_description
* The description the migrated entity should have.
* @param string $expected_format
* The format the migrated entity should have.
* @param int $expected_weight
* The weight the migrated entity should have.
* @param array $expected_parents
* The parent terms the migrated entity should have.
* @param int $expected_field_integer_value
* The value the migrated entity field should have.
* @param int $expected_term_reference_tid
* The term reference id the migrated entity field should have.
*/
protected function assertEntity($id, $expected_label, $expected_vid, $expected_description = '', $expected_format = NULL, $expected_weight = 0, $expected_parents = [], $expected_field_integer_value = NULL, $expected_term_reference_tid = NULL) {
/** @var \Drupal\taxonomy\TermInterface $entity */
$entity = Term::load($id);
$this->assertTrue($entity instanceof TermInterface);
$this->assertIdentical($expected_label, $entity->label());
$this->assertIdentical($expected_vid, $entity->getVocabularyId());
$this->assertEqual($expected_description, $entity->getDescription());
$this->assertEquals($expected_format, $entity->getFormat());
$this->assertEqual($expected_weight, $entity->getWeight());
$this->assertIdentical($expected_parents, $this->getParentIDs($id));
$this->assertHierarchy($expected_vid, $id, $expected_parents);
if (!is_null($expected_field_integer_value)) {
$this->assertTrue($entity->hasField('field_integer'));
$this->assertEquals($expected_field_integer_value, $entity->field_integer->value);
}
if (!is_null($expected_term_reference_tid)) {
$this->assertTrue($entity->hasField('field_integer'));
$this->assertEquals($expected_term_reference_tid, $entity->field_term_reference->target_id);
}
}
/**
* Tests the Drupal 7 taxonomy term to Drupal 8 migration.
*/
public function testTaxonomyTerms() {
$this->assertEntity(1, 'General discussion', 'forums', '', NULL, 2);
$this->assertEntity(2, 'Term1', 'test_vocabulary', 'The first term.', 'filtered_html', 0, [], NULL, 3);
$this->assertEntity(3, 'Term2', 'test_vocabulary', 'The second term.', 'filtered_html');
$this->assertEntity(4, 'Term3', 'test_vocabulary', 'The third term.', 'full_html', 0, [3], 6);
$this->assertEntity(5, 'Custom Forum', 'forums', 'Where the cool kids are.', NULL, 3);
$this->assertEntity(6, 'Games', 'forums', '', NULL, 4);
$this->assertEntity(7, 'Minecraft', 'forums', '', NULL, 1, [6]);
$this->assertEntity(8, 'Half Life 3', 'forums', '', NULL, 0, [6]);
}
/**
* Retrieves the parent term IDs for a given term.
*
* @param $tid
* ID of the term to check.
*
* @return array
* List of parent term IDs.
*/
protected function getParentIDs($tid) {
return array_keys(\Drupal::entityManager()->getStorage('taxonomy_term')->loadParents($tid));
}
/**
* Assert that a term is present in the tree storage, with the right parents.
*
* @param string $vid
* Vocabular ID.
* @param int $tid
* ID of the term to check.
* @param array $parent_ids
* The expected parent term IDs.
*/
protected function assertHierarchy($vid, $tid, array $parent_ids) {
if (!isset($this->treeData[$vid])) {
$tree = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid);
$this->treeData[$vid] = [];
foreach ($tree as $item) {
$this->treeData[$vid][$item->tid] = $item;
}
}
$this->assertArrayHasKey($tid, $this->treeData[$vid], "Term $tid exists in taxonomy tree");
$term = $this->treeData[$vid][$tid];
$this->assertEquals($parent_ids, array_filter($term->parents), "Term $tid has correct parents in taxonomy tree");
}
}

View file

@ -0,0 +1,62 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d7;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
use Drupal\taxonomy\VocabularyInterface;
/**
* Migrate taxonomy vocabularies to taxonomy.vocabulary.*.yml.
*
* @group taxonomy
*/
class MigrateTaxonomyVocabularyTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('taxonomy');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d7_taxonomy_vocabulary');
}
/**
* Validate a migrated vocabulary contains the expected values.
*
* @param $id
* Entity ID to load and check.
* @param $expected_label
* The label the migrated entity should have.
* @param $expected_description
* The description the migrated entity should have.
* @param $expected_hierarchy
* The hierarchy setting the migrated entity should have.
* @param $expected_weight
* The weight the migrated entity should have.
*/
protected function assertEntity($id, $expected_label, $expected_description, $expected_hierarchy, $expected_weight) {
/** @var \Drupal\taxonomy\VocabularyInterface $entity */
$entity = Vocabulary::load($id);
$this->assertTrue($entity instanceof VocabularyInterface);
$this->assertIdentical($expected_label, $entity->label());
$this->assertIdentical($expected_description, $entity->getDescription());
$this->assertIdentical($expected_hierarchy, $entity->getHierarchy());
$this->assertIdentical($expected_weight, $entity->get('weight'));
}
/**
* Tests the Drupal 7 taxonomy vocabularies to Drupal 8 migration.
*/
public function testTaxonomyVocabulary() {
$this->assertEntity('tags', 'Tags', 'Use tags to group articles on similar topics into categories.', VocabularyInterface::HIERARCHY_DISABLED, 0);
$this->assertEntity('forums', 'Forums', 'Forum navigation vocabulary', VocabularyInterface::HIERARCHY_SINGLE, -10);
$this->assertEntity('test_vocabulary', 'Test Vocabulary', 'This is the vocabulary description', VocabularyInterface::HIERARCHY_SINGLE, 0);
}
}

View file

@ -0,0 +1,108 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d6;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests d6_term_node source plugin.
*
* @covers \Drupal\taxonomy\Plugin\migrate\source\d6\TermNode
* @group taxonomy
*/
class TermNodeTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy', 'migrate_drupal'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
// The source data.
$tests[0]['source_data']['term_node'] = [
[
'nid' => '1',
'vid' => '1',
'tid' => '1',
],
[
'nid' => '1',
'vid' => '1',
'tid' => '4',
],
[
'nid' => '1',
'vid' => '1',
'tid' => '5',
],
];
$tests[0]['source_data']['node'] = [
[
'nid' => '1',
'vid' => '1',
'type' => 'story',
'language' => '',
'title' => 'Test title',
'uid' => '1',
'status' => '1',
'created' => '1388271197',
'changed' => '1420861423',
'comment' => '0',
'promote' => '0',
'moderate' => '0',
'sticky' => '0',
'tnid' => '0',
'translate' => '0',
],
];
$tests[0]['source_data']['term_data'] = [
[
'tid' => '1',
'vid' => '3',
'name' => 'term 1 of vocabulary 3',
'description' => 'description of term 1 of vocabulary 3',
'weight' => '0',
],
[
'tid' => '4',
'vid' => '3',
'name' => 'term 4 of vocabulary 3',
'description' => 'description of term 4 of vocabulary 3',
'weight' => '6',
],
[
'tid' => '5',
'vid' => '3',
'name' => 'term 5 of vocabulary 3',
'description' => 'description of term 5 of vocabulary 3',
'weight' => '7',
],
];
// The expected results.
$tests[0]['expected_data'] = [
[
'nid' => 1,
'vid' => 1,
'type' => 'story',
'tid' => [1, 4, 5],
],
];
// Set default value for expected count.
$tests[0]['expected_count'] = NULL;
// Set plugin configuration.
$tests[0]['configuration'] = [
'vid' => 3,
];
return $tests;
}
}

View file

@ -0,0 +1,56 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d6;
/**
* Tests the taxonomy term source with vocabulary filter.
*
* @covers \Drupal\taxonomy\Plugin\migrate\source\d6\Term
* @group taxonomy
*/
class TermSourceWithVocabularyFilterTest extends TermTest {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy', 'migrate_drupal'];
/**
* {@inheritdoc}
*/
public function providerSource() {
// Get the source data from parent.
$tests = parent::providerSource();
// The expected results.
$tests[0]['expected_data'] = [
[
'tid' => 1,
'vid' => 5,
'name' => 'name value 1',
'description' => 'description value 1',
'weight' => 0,
'parent' => [0],
],
[
'tid' => 4,
'vid' => 5,
'name' => 'name value 4',
'description' => 'description value 4',
'weight' => 1,
'parent' => [1],
],
];
// We know there are two rows with vid == 5.
$tests[0]['expected_count'] = 2;
// Set up source plugin configuration.
$tests[0]['configuration'] = [
'bundle' => [5],
];
return $tests;
}
}

View file

@ -0,0 +1,218 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d6;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests taxonomy term source plugin.
*
* @covers \Drupal\taxonomy\Plugin\migrate\source\d6\Term
* @group taxonomy
*/
class TermTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy', 'migrate_drupal'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
// The source data.
$tests[0]['source_data']['term_data'] = [
[
'tid' => 1,
'vid' => 5,
'name' => 'name value 1',
'description' => 'description value 1',
'weight' => 0,
],
[
'tid' => 2,
'vid' => 6,
'name' => 'name value 2',
'description' => 'description value 2',
'weight' => 0,
],
[
'tid' => 3,
'vid' => 6,
'name' => 'name value 3',
'description' => 'description value 3',
'weight' => 0,
],
[
'tid' => 4,
'vid' => 5,
'name' => 'name value 4',
'description' => 'description value 4',
'weight' => 1,
],
[
'tid' => 5,
'vid' => 6,
'name' => 'name value 5',
'description' => 'description value 5',
'weight' => 1,
],
[
'tid' => 6,
'vid' => 6,
'name' => 'name value 6',
'description' => 'description value 6',
'weight' => 0,
],
[
'tid' => 7,
'vid' => 3,
'name' => 'name value 7',
'description' => 'description value 7',
'weight' => 0,
],
];
$tests[0]['source_data']['term_hierarchy'] = [
[
'tid' => 1,
'parent' => 0,
],
[
'tid' => 2,
'parent' => 0,
],
[
'tid' => 3,
'parent' => 0,
],
[
'tid' => 4,
'parent' => 1,
],
[
'tid' => 5,
'parent' => 2,
],
[
'tid' => 6,
'parent' => 3,
],
[
'tid' => 6,
'parent' => 2,
],
[
'tid' => 7,
'parent' => 0,
],
];
// The expected results.
$tests[0]['expected_data'] = [
[
'tid' => 1,
'vid' => 5,
'name' => 'name value 1',
'description' => 'description value 1',
'weight' => 0,
'parent' => [0],
],
[
'tid' => 2,
'vid' => 6,
'name' => 'name value 2',
'description' => 'description value 2',
'weight' => 0,
'parent' => [0],
],
[
'tid' => 3,
'vid' => 6,
'name' => 'name value 3',
'description' => 'description value 3',
'weight' => 0,
'parent' => [0],
],
[
'tid' => 4,
'vid' => 5,
'name' => 'name value 4',
'description' => 'description value 4',
'weight' => 1,
'parent' => [1],
],
[
'tid' => 5,
'vid' => 6,
'name' => 'name value 5',
'description' => 'description value 5',
'weight' => 1,
'parent' => [2],
],
[
'tid' => 6,
'vid' => 6,
'name' => 'name value 6',
'description' => 'description value 6',
'weight' => 0,
'parent' => [3, 2],
],
[
'tid' => 7,
'vid' => 3,
'name' => 'name value 7',
'description' => 'description value 7',
'weight' => 0,
'parent' => [0],
],
];
$tests[0]['expected_count'] = NULL;
// Empty configuration will return terms for all vocabularies.
$tests[0]['configuration'] = [];
// Change configuration to get one vocabulary, 5.
$tests[1]['source_data'] = $tests[0]['source_data'];
$tests[1]['expected_data'] = [
[
'tid' => 1,
'vid' => 5,
'name' => 'name value 1',
'description' => 'description value 1',
'weight' => 0,
'parent' => [0],
],
[
'tid' => 4,
'vid' => 5,
'name' => 'name value 4',
'description' => 'description value 4',
'weight' => 1,
'parent' => [1],
],
];
$tests[1]['expected_count'] = NULL;
$tests[1]['configuration']['bundle'] = ['5'];
// Same as previous test, but with configuration vocabulary as a string
// instead of an array.
$tests[2]['source_data'] = $tests[0]['source_data'];
$tests[2]['expected_data'] = $tests[1]['expected_data'];
$tests[2]['expected_count'] = NULL;
$tests[2]['configuration']['bundle'] = '5';
// Change configuration to get two vocabularies, 5 and 6.
$tests[3]['source_data'] = $tests[0]['source_data'];
$tests[3]['expected_data'] = $tests[0]['expected_data'];
// Remove the last element because it is for vid 3.
array_pop($tests[3]['expected_data']);
$tests[3]['expected_count'] = NULL;
$tests[3]['configuration']['bundle'] = ['5', '6'];
return $tests;
}
}

View file

@ -0,0 +1,108 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d6;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests D6 vocabulary source plugin.
*
* @covers \Drupal\taxonomy\Plugin\migrate\source\d6\Vocabulary
* @group taxonomy
*/
class VocabularyTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy', 'migrate_drupal'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
// The source data.
$tests[0]['source_data']['vocabulary'] = [
[
'vid' => 1,
'name' => 'Tags',
'description' => 'Tags description.',
'help' => 1,
'relations' => 0,
'hierarchy' => 0,
'multiple' => 0,
'required' => 0,
'tags' => 1,
'module' => 'taxonomy',
'weight' => 0,
],
[
'vid' => 2,
'name' => 'Categories',
'description' => 'Categories description.',
'help' => 1,
'relations' => 1,
'hierarchy' => 1,
'multiple' => 0,
'required' => 1,
'tags' => 0,
'module' => 'taxonomy',
'weight' => 0,
],
];
$tests[0]['source_data']['vocabulary_node_types'] = [
[
'vid' => 1,
'type' => 'page',
],
[
'vid' => 1,
'type' => 'article',
],
[
'vid' => 2,
'type' => 'article',
],
];
// The expected results.
$tests[0]['expected_data'] = [
[
'vid' => 1,
'name' => 'Tags',
'description' => 'Tags description.',
'help' => 1,
'relations' => 0,
'hierarchy' => 0,
'multiple' => 0,
'required' => 0,
'tags' => 1,
'module' => 'taxonomy',
'weight' => 0,
'node_types' => ['page', 'article'],
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
],
[
'vid' => 2,
'name' => 'Categories',
'description' => 'Categories description.',
'help' => 1,
'relations' => 1,
'hierarchy' => 1,
'multiple' => 0,
'required' => 1,
'tags' => 0,
'module' => 'taxonomy',
'weight' => 0,
'node_types' => ['article'],
'cardinality' => 1,
],
];
return $tests;
}
}

View file

@ -0,0 +1,56 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d7;
/**
* Tests the taxonomy term source with vocabulary filter.
*
* @covers \Drupal\taxonomy\Plugin\migrate\source\d7\Term
* @group taxonomy
*/
class TermSourceWithVocabularyFilterTest extends TermTest {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy', 'migrate_drupal'];
/**
* {@inheritdoc}
*/
public function providerSource() {
// Get the source data from parent.
$tests = parent::providerSource();
// The expected results.
$tests[0]['expected_data'] = [
[
'tid' => 1,
'vid' => 5,
'name' => 'name value 1',
'description' => 'description value 1',
'weight' => 0,
'parent' => [0],
],
[
'tid' => 4,
'vid' => 5,
'name' => 'name value 4',
'description' => 'description value 4',
'weight' => 1,
'parent' => [1],
],
];
// We know there are two rows with machine_name == 'tags'.
$tests[0]['expected_count'] = 2;
// Set up source plugin configuration.
$tests[0]['configuration'] = [
'bundle' => ['tags'],
];
return $tests;
}
}

View file

@ -0,0 +1,258 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d7;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests taxonomy term source plugin.
*
* @covers \Drupal\taxonomy\Plugin\migrate\source\d7\Term
* @group taxonomy
*/
class TermTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy', 'migrate_drupal'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
// The source data.
$tests[0]['source_data']['taxonomy_term_data'] = [
[
'tid' => 1,
'vid' => 5,
'name' => 'name value 1',
'description' => 'description value 1',
'weight' => 0,
],
[
'tid' => 2,
'vid' => 6,
'name' => 'name value 2',
'description' => 'description value 2',
'weight' => 0,
],
[
'tid' => 3,
'vid' => 6,
'name' => 'name value 3',
'description' => 'description value 3',
'weight' => 0,
],
[
'tid' => 4,
'vid' => 5,
'name' => 'name value 4',
'description' => 'description value 4',
'weight' => 1,
],
[
'tid' => 5,
'vid' => 6,
'name' => 'name value 5',
'description' => 'description value 5',
'weight' => 1,
],
[
'tid' => 6,
'vid' => 6,
'name' => 'name value 6',
'description' => 'description value 6',
'weight' => 0,
],
[
'tid' => 7,
'vid' => 3,
'name' => 'name value 7',
'description' => 'description value 7',
'weight' => 0,
],
];
$tests[0]['source_data']['taxonomy_term_hierarchy'] = [
[
'tid' => 1,
'parent' => 0,
],
[
'tid' => 2,
'parent' => 0,
],
[
'tid' => 3,
'parent' => 0,
],
[
'tid' => 4,
'parent' => 1,
],
[
'tid' => 5,
'parent' => 2,
],
[
'tid' => 6,
'parent' => 3,
],
[
'tid' => 6,
'parent' => 2,
],
[
'tid' => 7,
'parent' => 0,
],
];
$tests[0]['source_data']['taxonomy_vocabulary'] = [
[
'vid' => 5,
'machine_name' => 'tags',
],
[
'vid' => 6,
'machine_name' => 'categories',
],
];
$tests[0]['source_data']['field_config_instance'] = [
[
'field_name' => 'field_term_field',
'entity_type' => 'taxonomy_term',
'bundle' => 'tags',
'deleted' => 0,
],
[
'field_name' => 'field_term_field',
'entity_type' => 'taxonomy_term',
'bundle' => 'categories',
'deleted' => 0,
],
];
$tests[0]['source_data']['field_data_field_term_field'] = [
[
'entity_type' => 'taxonomy_term',
'bundle' => 'tags',
'deleted' => 0,
'entity_id' => 1,
'delta' => 0,
],
[
'entity_type' => 'taxonomy_term',
'bundle' => 'categories',
'deleted' => 0,
'entity_id' => 1,
'delta' => 0,
],
];
// The expected results.
$tests[0]['expected_data'] = [
[
'tid' => 1,
'vid' => 5,
'name' => 'name value 1',
'description' => 'description value 1',
'weight' => 0,
'parent' => [0],
],
[
'tid' => 2,
'vid' => 6,
'name' => 'name value 2',
'description' => 'description value 2',
'weight' => 0,
'parent' => [0],
],
[
'tid' => 3,
'vid' => 6,
'name' => 'name value 3',
'description' => 'description value 3',
'weight' => 0,
'parent' => [0],
],
[
'tid' => 4,
'vid' => 5,
'name' => 'name value 4',
'description' => 'description value 4',
'weight' => 1,
'parent' => [1],
],
[
'tid' => 5,
'vid' => 6,
'name' => 'name value 5',
'description' => 'description value 5',
'weight' => 1,
'parent' => [2],
],
[
'tid' => 6,
'vid' => 6,
'name' => 'name value 6',
'description' => 'description value 6',
'weight' => 0,
'parent' => [3, 2],
],
[
'tid' => 7,
'vid' => 3,
'name' => 'name value 7',
'description' => 'description value 7',
'weight' => 0,
'parent' => [0],
],
];
$tests[0]['expected_count'] = NULL;
// Empty configuration will return terms for all vocabularies.
$tests[0]['configuration'] = [];
// Change configuration to get one vocabulary, "tags".
$tests[1]['source_data'] = $tests[0]['source_data'];
$tests[1]['expected_data'] = [
[
'tid' => 1,
'vid' => 5,
'name' => 'name value 1',
'description' => 'description value 1',
'weight' => 0,
'parent' => [0],
],
[
'tid' => 4,
'vid' => 5,
'name' => 'name value 4',
'description' => 'description value 4',
'weight' => 1,
'parent' => [1],
],
];
$tests[1]['expected_count'] = NULL;
$tests[1]['configuration']['bundle'] = ['tags'];
// Same as previous test, but with configuration vocabulary as a string
// instead of an array.
$tests[2]['source_data'] = $tests[0]['source_data'];
$tests[2]['expected_data'] = $tests[1]['expected_data'];
$tests[2]['expected_count'] = NULL;
$tests[2]['configuration']['bundle'] = 'tags';
// Change configuration to get two vocabularies, "tags" and "categories".
$tests[3]['source_data'] = $tests[0]['source_data'];
$tests[3]['expected_data'] = $tests[0]['expected_data'];
// Remove the last element because it is for vid 3.
array_pop($tests[3]['expected_data']);
$tests[3]['expected_count'] = NULL;
$tests[3]['configuration']['bundle'] = ['tags', 'categories'];
return $tests;
}
}

View file

@ -0,0 +1,54 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d7;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests D7 vocabulary source plugin.
*
* @covers \Drupal\taxonomy\Plugin\migrate\source\d7\Vocabulary
* @group taxonomy
*/
class VocabularyTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy', 'migrate_drupal'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
// The source data.
$tests[0]['source_data']['taxonomy_vocabulary'] = [
[
'vid' => 1,
'name' => 'Tags',
'description' => 'Tags description.',
'hierarchy' => 0,
'module' => 'taxonomy',
'weight' => 0,
'machine_name' => 'tags',
],
[
'vid' => 2,
'name' => 'Categories',
'description' => 'Categories description.',
'hierarchy' => 1,
'module' => 'taxonomy',
'weight' => 0,
'machine_name' => 'categories',
],
];
// The expected results.
$tests[0]['expected_data'] = $tests[0]['source_data']['taxonomy_vocabulary'];
return $tests;
}
}

View file

@ -0,0 +1,152 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel;
use Drupal\taxonomy\Entity\Term;
use Drupal\KernelTests\KernelTestBase;
use Drupal\taxonomy\Tests\TaxonomyTestTrait;
/**
* Kernel tests for taxonomy term functions.
*
* @group taxonomy
*/
class TermKernelTest extends KernelTestBase {
use TaxonomyTestTrait;
/**
* {@inheritdoc}
*/
public static $modules = array( 'filter', 'taxonomy', 'text', 'user' );
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(array('filter'));
$this->installEntitySchema('taxonomy_term');
}
/**
* Deleting terms should also remove related vocabulary.
* Deleting an invalid term should silently fail.
*/
public function testTermDelete() {
$vocabulary = $this->createVocabulary();
$valid_term = $this->createTerm($vocabulary);
// Delete a valid term.
$valid_term->delete();
$terms = entity_load_multiple_by_properties('taxonomy_term', array('vid' => $vocabulary->id()));
$this->assertTrue(empty($terms), 'Vocabulary is empty after deletion');
// Delete an invalid term. Should not throw any notices.
entity_delete_multiple('taxonomy_term', array(42));
}
/**
* Deleting a parent of a term with multiple parents does not delete the term.
*/
public function testMultipleParentDelete() {
$vocabulary = $this->createVocabulary();
$parent_term1 = $this->createTerm($vocabulary);
$parent_term2 = $this->createTerm($vocabulary);
$child_term = $this->createTerm($vocabulary);
$child_term->parent = array($parent_term1->id(), $parent_term2->id());
$child_term->save();
$child_term_id = $child_term->id();
$parent_term1->delete();
$term_storage = $this->container->get('entity.manager')->getStorage('taxonomy_term');
$term_storage->resetCache(array($child_term_id));
$child_term = Term::load($child_term_id);
$this->assertTrue(!empty($child_term), 'Child term is not deleted if only one of its parents is removed.');
$parent_term2->delete();
$term_storage->resetCache(array($child_term_id));
$child_term = Term::load($child_term_id);
$this->assertTrue(empty($child_term), 'Child term is deleted if all of its parents are removed.');
}
/**
* Test a taxonomy with terms that have multiple parents of different depths.
*/
public function testTaxonomyVocabularyTree() {
// Create a new vocabulary with 6 terms.
$vocabulary = $this->createVocabulary();
$term = array();
for ($i = 0; $i < 6; $i++) {
$term[$i] = $this->createTerm($vocabulary);
}
// Get the taxonomy storage.
$taxonomy_storage = $this->container->get('entity.manager')->getStorage('taxonomy_term');
// Set the weight on $term[1] so it appears before $term[5] when fetching
// the parents for $term[2], in order to test for a regression on
// \Drupal\taxonomy\TermStorageInterface::loadAllParents().
$term[1]->weight = -1;
$term[1]->save();
// $term[2] is a child of 1 and 5.
$term[2]->parent = array($term[1]->id(), $term[5]->id());
$term[2]->save();
// $term[3] is a child of 2.
$term[3]->parent = array($term[2]->id());
$term[3]->save();
// $term[5] is a child of 4.
$term[5]->parent = array($term[4]->id());
$term[5]->save();
/**
* Expected tree:
* term[0] | depth: 0
* term[1] | depth: 0
* -- term[2] | depth: 1
* ---- term[3] | depth: 2
* term[4] | depth: 0
* -- term[5] | depth: 1
* ---- term[2] | depth: 2
* ------ term[3] | depth: 3
*/
// Count $term[1] parents with $max_depth = 1.
$tree = $taxonomy_storage->loadTree($vocabulary->id(), $term[1]->id(), 1);
$this->assertEqual(1, count($tree), 'We have one parent with depth 1.');
// Count all vocabulary tree elements.
$tree = $taxonomy_storage->loadTree($vocabulary->id());
$this->assertEqual(8, count($tree), 'We have all vocabulary tree elements.');
// Count elements in every tree depth.
foreach ($tree as $element) {
if (!isset($depth_count[$element->depth])) {
$depth_count[$element->depth] = 0;
}
$depth_count[$element->depth]++;
}
$this->assertEqual(3, $depth_count[0], 'Three elements in taxonomy tree depth 0.');
$this->assertEqual(2, $depth_count[1], 'Two elements in taxonomy tree depth 1.');
$this->assertEqual(2, $depth_count[2], 'Two elements in taxonomy tree depth 2.');
$this->assertEqual(1, $depth_count[3], 'One element in taxonomy tree depth 3.');
/** @var \Drupal\taxonomy\TermStorageInterface $storage */
$storage = \Drupal::entityManager()->getStorage('taxonomy_term');
// Count parents of $term[2].
$parents = $storage->loadParents($term[2]->id());
$this->assertEqual(2, count($parents), 'The term has two parents.');
// Count parents of $term[3].
$parents = $storage->loadParents($term[3]->id());
$this->assertEqual(1, count($parents), 'The term has one parent.');
// Identify all ancestors of $term[2].
$ancestors = $storage->loadAllParents($term[2]->id());
$this->assertEqual(4, count($ancestors), 'The term has four ancestors including the term itself.');
// Identify all ancestors of $term[3].
$ancestors = $storage->loadAllParents($term[3]->id());
$this->assertEqual(5, count($ancestors), 'The term has five ancestors including the term itself.');
}
}

View file

@ -0,0 +1,68 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
/**
* Tests term validation constraints.
*
* @group taxonomy
*/
class TermValidationTest extends EntityKernelTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('taxonomy');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('taxonomy_term');
}
/**
* Tests the term validation constraints.
*/
public function testValidation() {
$this->entityManager->getStorage('taxonomy_vocabulary')->create(array(
'vid' => 'tags',
'name' => 'Tags',
))->save();
$term = $this->entityManager->getStorage('taxonomy_term')->create(array(
'name' => 'test',
'vid' => 'tags',
));
$violations = $term->validate();
$this->assertEqual(count($violations), 0, 'No violations when validating a default term.');
$term->set('name', $this->randomString(256));
$violations = $term->validate();
$this->assertEqual(count($violations), 1, 'Violation found when name is too long.');
$this->assertEqual($violations[0]->getPropertyPath(), 'name.0.value');
$field_label = $term->get('name')->getFieldDefinition()->getLabel();
$this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', array('%name' => $field_label, '@max' => 255)));
$term->set('name', NULL);
$violations = $term->validate();
$this->assertEqual(count($violations), 1, 'Violation found when name is NULL.');
$this->assertEqual($violations[0]->getPropertyPath(), 'name');
$this->assertEqual($violations[0]->getMessage(), t('This value should not be null.'));
$term->set('name', 'test');
$term->set('parent', 9999);
$violations = $term->validate();
$this->assertEqual(count($violations), 1, 'Violation found when term parent is invalid.');
$this->assertEqual($violations[0]->getMessage(), format_string('The referenced entity (%type: %id) does not exist.', array('%type' => 'taxonomy_term', '%id' => 9999)));
$term->set('parent', 0);
$violations = $term->validate();
$this->assertEqual(count($violations), 0, 'No violations for parent id 0.');
}
}

View file

@ -0,0 +1,68 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Views;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\Tests\views\Kernel\Handler\FieldFieldAccessTestBase;
/**
* Tests base field access in Views for the taxonomy entity.
*
* @group taxonomy
*/
class TaxonomyViewsFieldAccessTest extends FieldFieldAccessTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy', 'text', 'entity_test'];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
$this->installEntitySchema('taxonomy_term');
}
/**
* Check access for taxonomy fields.
*/
public function testTermFields() {
$vocab = Vocabulary::create([
'vid' => 'random',
'name' => 'Randomness',
]);
$vocab->save();
$term1 = Term::create([
'name' => 'Semi random',
'vid' => $vocab->id(),
]);
$term1->save();
$term2 = Term::create([
'name' => 'Majorly random',
'vid' => $vocab->id(),
]);
$term2->save();
$term3 = Term::create([
'name' => 'Not really random',
'vid' => $vocab->id(),
]);
$term3->save();
$this->assertFieldAccess('taxonomy_term', 'name', 'Majorly random');
$this->assertFieldAccess('taxonomy_term', 'name', 'Semi random');
$this->assertFieldAccess('taxonomy_term', 'name', 'Not really random');
$this->assertFieldAccess('taxonomy_term', 'tid', $term1->id());
$this->assertFieldAccess('taxonomy_term', 'tid', $term2->id());
$this->assertFieldAccess('taxonomy_term', 'tid', $term3->id());
$this->assertFieldAccess('taxonomy_term', 'uuid', $term1->uuid());
$this->assertFieldAccess('taxonomy_term', 'uuid', $term2->uuid());
$this->assertFieldAccess('taxonomy_term', 'uuid', $term3->uuid());
}
}

View file

@ -0,0 +1,42 @@
<?php
namespace Drupal\Tests\taxonomy\Unit\Menu;
use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
/**
* Tests existence of taxonomy local tasks.
*
* @group taxonomy
*/
class TaxonomyLocalTasksTest extends LocalTaskIntegrationTestBase {
protected function setUp() {
$this->directoryList = array('taxonomy' => 'core/modules/taxonomy');
parent::setUp();
}
/**
* Checks taxonomy edit local tasks.
*
* @dataProvider getTaxonomyPageRoutes
*/
public function testTaxonomyPageLocalTasks($route, $subtask = array()) {
$tasks = array(
0 => array('entity.taxonomy_term.canonical', 'entity.taxonomy_term.edit_form'),
);
if ($subtask) $tasks[] = $subtask;
$this->assertLocalTasks($route, $tasks);
}
/**
* Provides a list of routes to test.
*/
public function getTaxonomyPageRoutes() {
return array(
array('entity.taxonomy_term.canonical'),
array('entity.taxonomy_term.edit_form'),
);
}
}