diff --git a/islandora.links.action.yml b/islandora.links.action.yml index f8bf7d2b3..4b0a01bec 100644 --- a/islandora.links.action.yml +++ b/islandora.links.action.yml @@ -15,3 +15,9 @@ islandora.reorder_children: title: Reorder Children appears_on: - view.manage_members.page_1 + +islandora.add_collection: + route_name: islandora.add_collection + title: Add collection + appears_on: + - view.collections.page_1 diff --git a/islandora.routing.yml b/islandora.routing.yml index 58dea1a25..72529c775 100644 --- a/islandora.routing.yml +++ b/islandora.routing.yml @@ -38,6 +38,16 @@ islandora.add_media_to_node_page: requirements: _entity_create_any_access: 'media' +islandora.add_collection: + path: '/collection/add' + defaults: + _controller: '\Drupal\islandora\Controller\AddCollectionController::addCollectionPage' + _title: 'Add Collection' + options: + _admin_route: 'true' + requirements: + _custom_access: '\Drupal\islandora\Controller\AddCollectionController::access' + islandora.media_source_update: path: '/media/{media}/source' defaults: diff --git a/modules/islandora_core_feature/config/install/views.view.collections.yml b/modules/islandora_core_feature/config/install/views.view.collections.yml new file mode 100644 index 000000000..ab6c47ab9 --- /dev/null +++ b/modules/islandora_core_feature/config/install/views.view.collections.yml @@ -0,0 +1,504 @@ +langcode: en +status: true +dependencies: + module: + - media + - node + - taxonomy + - user +id: collections +label: Collections +module: views +description: 'All collections in the repository' +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: mini + options: + items_per_page: 10 + offset: 0 + id: 0 + total_pages: null + expose: + items_per_page: false + items_per_page_label: 'Items per page' + items_per_page_options: '5, 10, 25, 50' + items_per_page_options_all: false + items_per_page_options_all_label: '- All -' + offset: false + offset_label: Offset + tags: + previous: ‹‹ + next: ›› + style: + type: table + options: + grouping: { } + row_class: '' + default_row_class: true + override: true + sticky: false + caption: '' + summary: '' + description: '' + columns: + title: title + field_member_of: field_member_of + field_file_size: field_file_size + operations: operations + info: + title: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + field_member_of: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + field_file_size: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + operations: + align: '' + separator: '' + empty_column: false + responsive: '' + default: '-1' + empty_table: false + row: + type: fields + options: + default_field_elements: true + inline: { } + separator: '' + hide_empty: false + fields: + title: + id: title + table: node_field_data + field: title + relationship: none + group_type: group + admin_label: '' + label: Title + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: false + ellipsis: false + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: string + settings: + link_to_entity: true + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + entity_type: node + entity_field: title + plugin_id: field + field_member_of: + id: field_member_of + table: node__field_member_of + field: field_member_of + relationship: reverse__node__field_member_of + group_type: count + admin_label: '' + label: Children + 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 + set_precision: false + precision: 0 + decimal: . + separator: ', ' + format_plural: 0 + format_plural_string: !!binary MQNAY291bnQ= + prefix: '' + suffix: '' + click_sort_column: target_id + type: entity_reference_label + settings: { } + group_column: entity_id + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + field_api_classes: false + plugin_id: field + field_file_size: + id: field_file_size + table: media__field_file_size + field: field_file_size + relationship: reverse__media__field_media_of + group_type: sum + admin_label: '' + label: 'Disk Usage' + exclude: false + alter: + alter_text: true + text: "{% if field_file_size > (1024 ** 5) %}\r\n {% set size = field_file_size / (1024 ** 5) %}\r\n {% set abbreviation = 'PB' %}\r\n{% elseif field_file_size > (1024 ** 4) %}\r\n {% set size = field_file_size / (1024 ** 4) %}\r\n {% set abbreviation = 'TB' %}\r\n{% elseif field_file_size > (1024 ** 3) %}\r\n {% set size = field_file_size / (1024 ** 3) %}\r\n {% set abbreviation = 'GB' %}\r\n{% elseif field_file_size > (1024 ** 2) %}\r\n {% set size = field_file_size / (1024 ** 2) %}\r\n {% set abbreviation = 'MB' %}\r\n{% elseif field_file_size > 1024 %}\r\n {% set size = field_file_size / 1024 %}\r\n {% set abbreviation = 'KB' %}\r\n{% else %}\r\n {% set size = field_file_size %}\r\n {% set abbreviation = 'B' %}\r\n{% endif %}\r\n\r\n{{ size|round(2, 'common') }} {{ abbreviation }}" + 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 + set_precision: false + precision: 0 + decimal: . + separator: '' + format_plural: 0 + format_plural_string: !!binary MQNAY291bnQ= + prefix: '' + suffix: '' + click_sort_column: value + type: number_integer + settings: { } + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + field_api_classes: false + plugin_id: field + operations: + id: operations + table: node + field: operations + relationship: none + group_type: group + admin_label: '' + label: 'Operations links' + 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 + destination: true + entity_type: node + plugin_id: entity_operations + 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 + field_external_uri_uri: + id: field_external_uri_uri + table: taxonomy_term__field_external_uri + field: field_external_uri_uri + relationship: field_model + group_type: group + admin_label: '' + operator: '=' + value: 'http://purl.org/dc/dcmitype/Collection' + group: 1 + exposed: false + expose: + operator_id: '' + label: '' + description: '' + use_operator: false + operator: '' + identifier: '' + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + placeholder: '' + 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 + sorts: { } + title: Collections + header: { } + footer: { } + empty: { } + relationships: + field_model: + id: field_model + table: node__field_model + field: field_model + relationship: none + group_type: group + admin_label: 'field_model: Taxonomy term' + required: true + plugin_id: standard + reverse__node__field_member_of: + id: reverse__node__field_member_of + table: node_field_data + field: reverse__node__field_member_of + relationship: none + group_type: group + admin_label: field_member_of + required: false + entity_type: node + plugin_id: entity_reverse + reverse__media__field_media_of: + id: reverse__media__field_media_of + table: node_field_data + field: reverse__media__field_media_of + relationship: none + group_type: group + admin_label: field_media_of + required: false + entity_type: node + plugin_id: entity_reverse + arguments: { } + display_extenders: { } + filter_groups: + operator: AND + groups: + 1: AND + group_by: true + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - url.query_args + - 'user.node_grants:view' + - user.permissions + tags: { } + page_1: + display_plugin: page + id: page_1 + display_title: Page + position: 1 + display_options: + display_extenders: { } + path: admin/content/collections + menu: + type: tab + title: Collections + description: '' + expanded: false + parent: '' + weight: -100 + context: '0' + menu_name: admin + tab_options: + type: normal + title: Collections + description: '' + weight: 0 + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - url.query_args + - 'user.node_grants:view' + - user.permissions + tags: { } diff --git a/modules/islandora_core_feature/islandora_core_feature.features.yml b/modules/islandora_core_feature/islandora_core_feature.features.yml index 5af003a72..7afcb1b19 100755 --- a/modules/islandora_core_feature/islandora_core_feature.features.yml +++ b/modules/islandora_core_feature/islandora_core_feature.features.yml @@ -14,3 +14,4 @@ required: - field.storage.node.field_model - field.storage.node.field_weight - field.storage.taxonomy_term.field_external_uri + - views.view.collections diff --git a/src/Controller/AddCollectionController.php b/src/Controller/AddCollectionController.php new file mode 100644 index 000000000..97f03ad9e --- /dev/null +++ b/src/Controller/AddCollectionController.php @@ -0,0 +1,47 @@ +utils->getTermForUri('http://purl.org/dc/dcmitype/Collection'); + $field = IslandoraUtils::MODEL_FIELD; + + return $this->generateTypeList( + 'node', + 'node_type', + 'node.add', + 'node.type_add', + $field, + ['query' => ["edit[$field][widget]" => $term->id()]] + ); + } + + /** + * Check if the object being displayed "is Islandora". + * + * @param \Drupal\Core\Routing\RouteMatch $route_match + * The current routing match. + * + * @return \Drupal\Core\Access\AccessResultAllowed|\Drupal\Core\Access\AccessResultForbidden + * Whether we can or can't show the "thing". + */ + public function access(RouteMatch $route_match) { + if ($this->utils->canCreateIslandoraEntity('node', 'node_type')) { + return AccessResult::allowed(); + } + return AccessResult::forbidden(); + } + +} diff --git a/src/Controller/ManageMediaController.php b/src/Controller/ManageMediaController.php index 776a68086..56e0b5c50 100644 --- a/src/Controller/ManageMediaController.php +++ b/src/Controller/ManageMediaController.php @@ -2,6 +2,7 @@ namespace Drupal\islandora\Controller; +use Drupal\islandora\IslandoraUtils; use Drupal\Core\Access\AccessResult; use Drupal\Core\Routing\RouteMatch; use Drupal\node\Entity\Node; @@ -22,13 +23,15 @@ class ManageMediaController extends ManageMembersController { * Array of media types to add. */ public function addToNodePage(NodeInterface $node) { + $field = IslandoraUtils::MEDIA_OF_FIELD; + return $this->generateTypeList( 'media', 'media_type', 'entity.media.add_form', 'entity.media_type.add_form', - $node, - 'field_media_of' + $field, + ['query' => ["edit[$field][widget][0][target_id]" => $node->id()]] ); } @@ -47,7 +50,7 @@ public function access(RouteMatch $route_match) { if (!$node instanceof NodeInterface) { $node = Node::load($node); } - if ($node->hasField('field_model') && $node->hasField('field_member_of')) { + if ($this->utils->isIslandoraType($node->getEntityTypeId(), $node->bundle())) { return AccessResult::allowed(); } } diff --git a/src/Controller/ManageMembersController.php b/src/Controller/ManageMembersController.php index 7f54706ca..b73dc73f2 100644 --- a/src/Controller/ManageMembersController.php +++ b/src/Controller/ManageMembersController.php @@ -7,6 +7,7 @@ use Drupal\Core\Entity\Controller\EntityController; use Drupal\Core\Entity\EntityFieldManager; use Drupal\Core\Link; +use Drupal\islandora\IslandoraUtils; use Drupal\node\NodeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -36,6 +37,13 @@ class ManageMembersController extends EntityController { */ protected $renderer; + /** + * Islandora Utils. + * + * @var \Drupal\islandora\IslandoraUtils + */ + protected $utils; + /** * Constructor. * @@ -45,15 +53,19 @@ class ManageMembersController extends EntityController { * The entity field manager. * @param \Drupal\Core\Render\RendererInterface $renderer * The renderer. + * @param \Drupal\islandora\IslandoraUtils $utils + * Islandora utils. */ public function __construct( EntityTypeManagerInterface $entity_type_manager, EntityFieldManager $entity_field_manager, - RendererInterface $renderer + RendererInterface $renderer, + IslandoraUtils $utils ) { $this->entityTypeManager = $entity_type_manager; $this->entityFieldManager = $entity_field_manager; $this->renderer = $renderer; + $this->utils = $utils; } /** @@ -63,7 +75,8 @@ public static function create(ContainerInterface $container) { return new static( $container->get('entity_type.manager'), $container->get('entity_field.manager'), - $container->get('renderer') + $container->get('renderer'), + $container->get('islandora.utils') ); } @@ -74,20 +87,21 @@ public static function create(ContainerInterface $container) { * Node you want to add a member to. */ public function addToNodePage(NodeInterface $node) { + $field = IslandoraUtils::MEMBER_OF_FIELD; return $this->generateTypeList( 'node', 'node_type', 'node.add', 'node.type_add', - $node, - 'field_member_of' + $field, + ['query' => ["edit[$field][widget][0][target_id]" => $node->id()]] ); } /** * Renders a list of content types to add as members. */ - protected function generateTypeList($entity_type, $bundle_type, $entity_add_form, $bundle_add_form, NodeInterface $node, $field) { + protected function generateTypeList($entity_type, $bundle_type, $entity_add_form, $bundle_add_form, $field, array $url_options) { $type_definition = $this->entityTypeManager->getDefinition($bundle_type); $build = [ @@ -115,7 +129,7 @@ protected function generateTypeList($entity_type, $bundle_type, $entity_add_form $bundle->label(), $entity_add_form, [$bundle_type => $bundle->id()], - ['query' => ["edit[$field][widget][0][target_id]" => $node->id()]] + $url_options ), ]; } diff --git a/src/IslandoraUtils.php b/src/IslandoraUtils.php index e98766c73..e32a5d03b 100644 --- a/src/IslandoraUtils.php +++ b/src/IslandoraUtils.php @@ -31,6 +31,8 @@ class IslandoraUtils { const EXTERNAL_URI_FIELD = 'field_external_uri'; const MEDIA_OF_FIELD = 'field_media_of'; const MEDIA_USAGE_FIELD = 'field_media_use'; + const MEMBER_OF_FIELD = 'field_member_of'; + const MODEL_FIELD = 'field_model'; /** * The entity type manager. @@ -570,4 +572,62 @@ public function getRestUrl(EntityInterface $entity, $format = '') { return $rest_url; } + /** + * Determines if an entity type and bundle make an 'Islandora' type entity. + * + * @param string $entity_type + * The entity type ('node', 'media', etc...). + * @param string $bundle + * Entity bundle ('article', 'page', etc...). + * + * @return bool + * TRUE if the bundle has the correct fields to be an 'Islandora' type. + */ + public function isIslandoraType($entity_type, $bundle) { + $fields = $this->entityFieldManager->getFieldDefinitions($entity_type, $bundle); + switch ($entity_type) { + case 'media': + return isset($fields[self::MEDIA_OF_FIELD]) && isset($fields[self::MEDIA_USAGE_FIELD]); + + case 'taxonomy_term': + return isset($fields[self::EXTERNAL_URI_FIELD]); + + default: + return isset($fields[self::MEMBER_OF_FIELD]) && isset($fields[self::MODEL_FIELD]); + } + } + + /** + * Util function for access handlers . + * + * @param string $entity_type + * Entity type such as 'node', 'media', 'taxonomy_term', etc.. + * @param string $bundle_type + * Bundle type such as 'node_type', 'media_type', 'vocabulary', etc... + * + * @return bool + * If user can create _at least one_ of the 'Islandora' types requested. + */ + public function canCreateIslandoraEntity($entity_type, $bundle_type) { + $bundles = $this->entityTypeManager->getStorage($bundle_type)->loadMultiple(); + $access_control_handler = $this->entityTypeManager->getAccessControlHandler($entity_type); + + $allowed = []; + foreach (array_keys($bundles) as $bundle) { + // Skip bundles that aren't 'Islandora' types. + if (!$this->isIslandoraType($entity_type, $bundle)) { + continue; + } + + $access = $access_control_handler->createAccess($bundle, NULL, [], TRUE); + if (!$access->isAllowed()) { + continue; + } + + return TRUE; + } + + return FALSE; + } + } diff --git a/tests/src/Functional/AddChildTest.php b/tests/src/Functional/AddChildTest.php new file mode 100644 index 000000000..67bc62335 --- /dev/null +++ b/tests/src/Functional/AddChildTest.php @@ -0,0 +1,60 @@ +parent = + $this->collectionTerm = $this->container->get('entity_type.manager')->getStorage('taxonomy_term')->create([ + 'name' => 'Collection', + 'vid' => $this->testVocabulary->id(), + 'field_external_uri' => [['uri' => "http://purl.org/dc/dcmitype/Collection"]], + ]); + $this->collectionTerm->save(); + } + + /** + * @covers \Drupal\islandora\Controller\AddCollectionController::addToNodePage + * @covers \Drupal\islandora\Controller\AddCollectionController::access + * @covers \Drupal\islandora\IslandoraUtils::isIslandoraType + */ + public function testAddChild() { + $account = $this->drupalCreateUser([ + 'bypass node access', + ]); + $this->drupalLogin($account); + + $parent = $this->container->get('entity_type.manager')->getStorage('node')->create([ + 'type' => 'test_type', + 'title' => 'Parent', + ]); + $parent->save(); + + // Visit the add member page. + $this->drupalGet("/node/{$parent->id()}/members/add"); + + // Assert that test_type is on the list. + $this->assertSession()->pageTextContains($this->testType->label()); + $this->clickLink($this->testType->label()); + $url = $this->getUrl(); + + // Assert that the link creates the correct prepopulate query param. + $substring = 'node/add/test_type?edit%5Bfield_member_of%5D%5Bwidget%5D%5B0%5D%5Btarget_id%5D=1'; + $this->assertTrue( + strpos($url, $substring) !== FALSE, + "Malformed URL, could not find $substring in $url." + ); + } + +} diff --git a/tests/src/Functional/AddCollectionTest.php b/tests/src/Functional/AddCollectionTest.php new file mode 100644 index 000000000..f1a87ab7d --- /dev/null +++ b/tests/src/Functional/AddCollectionTest.php @@ -0,0 +1,62 @@ +collectionTerm = $this->container->get('entity_type.manager')->getStorage('taxonomy_term')->create([ + 'name' => 'Collection', + 'vid' => $this->testVocabulary->id(), + 'field_external_uri' => [['uri' => "http://purl.org/dc/dcmitype/Collection"]], + ]); + $this->collectionTerm->save(); + } + + /** + * @covers \Drupal\islandora\Controller\AddCollectionController::addCollectionPage + * @covers \Drupal\islandora\Controller\AddCollectionController::access + * @covers \Drupal\islandora\IslandoraUtils::isIslandoraType + */ + public function testAddCollection() { + $account = $this->drupalCreateUser([ + 'bypass node access', + ]); + $this->drupalLogin($account); + + // Visit the add collection page. + $this->drupalGet('/collection/add'); + + // Assert the test type is in the list of available types. + $this->assertSession()->pageTextContains($this->testType->label()); + + // Click the test type and make sure you get sent to the right form. + $this->clickLink($this->testType->label()); + $url = $this->getUrl(); + + // Assert that the link creates the correct prepopulate query param. + $substring = 'node/add/test_type?edit%5Bfield_model%5D%5Bwidget%5D=1'; + $this->assertTrue( + strpos($url, 'node/add/test_type?edit%5Bfield_model%5D%5Bwidget%5D=1') !== FALSE, + "Malformed URL, could not find $substring in $url." + ); + } + +} diff --git a/tests/src/Functional/AddMediaTest.php b/tests/src/Functional/AddMediaTest.php new file mode 100644 index 000000000..f91cef825 --- /dev/null +++ b/tests/src/Functional/AddMediaTest.php @@ -0,0 +1,46 @@ +drupalCreateUser([ + 'bypass node access', + 'create media', + ]); + $this->drupalLogin($account); + + $parent = $this->container->get('entity_type.manager')->getStorage('node')->create([ + 'type' => 'test_type', + 'title' => 'Parent', + ]); + $parent->save(); + + // Visit the add media page. + $this->drupalGet("/node/{$parent->id()}/media/add"); + + // Assert that test_meida_type is on the list. + $this->assertSession()->pageTextContains($this->testMediaType->label()); + $this->clickLink($this->testMediaType->label()); + $url = $this->getUrl(); + + // Assert that the link creates the correct prepopulate query param. + $substring = 'media/add/test_media_type?edit%5Bfield_media_of%5D%5Bwidget%5D%5B0%5D%5Btarget_id%5D=1'; + $this->assertTrue( + strpos($url, $substring) !== FALSE, + "Malformed URL, could not find $substring in $url." + ); + } + +} diff --git a/tests/src/Functional/GenerateDerivativeTestBase.php b/tests/src/Functional/GenerateDerivativeTestBase.php index c74ff2555..0f67d5919 100644 --- a/tests/src/Functional/GenerateDerivativeTestBase.php +++ b/tests/src/Functional/GenerateDerivativeTestBase.php @@ -48,7 +48,7 @@ public function setUp() { $this->node = $this->container->get('entity_type.manager')->getStorage('node')->create([ 'type' => $this->testType->id(), 'title' => 'Test Node', - 'field_tags' => [$this->imageTerm->id()], + 'field_model' => [$this->imageTerm->id()], ]); $this->node->save(); } diff --git a/tests/src/Functional/IslandoraFunctionalTestBase.php b/tests/src/Functional/IslandoraFunctionalTestBase.php index 9a50fb050..838c1ee4e 100644 --- a/tests/src/Functional/IslandoraFunctionalTestBase.php +++ b/tests/src/Functional/IslandoraFunctionalTestBase.php @@ -176,13 +176,13 @@ public function setUp() { ]); $this->testType->save(); $this->createEntityReferenceField('node', 'test_type', 'field_member_of', 'Member Of', 'node', 'default', [], 2); - $this->createEntityReferenceField('node', 'test_type', 'field_tags', 'Tags', 'taxonomy_term', 'default', [], 2); + $this->createEntityReferenceField('node', 'test_type', 'field_model', 'Model', 'taxonomy_term', 'default', [], 2); // Create a media type. $this->testMediaType = $this->createMediaType('file', ['id' => 'test_media_type']); $this->testMediaType->save(); $this->createEntityReferenceField('media', $this->testMediaType->id(), 'field_media_of', 'Media Of', 'node', 'default', [], 2); - $this->createEntityReferenceField('media', $this->testMediaType->id(), 'field_tags', 'Tags', 'taxonomy_term', 'default', [], 2); + $this->createEntityReferenceField('media', $this->testMediaType->id(), 'field_media_use', 'Tags', 'taxonomy_term', 'default', [], 2); // Copy over the rest of the config from yml files. $source = new FileStorage(__DIR__ . '/../../fixtures/config'); diff --git a/tests/src/Functional/LinkHeaderTest.php b/tests/src/Functional/LinkHeaderTest.php index 472986c20..57122aaa8 100644 --- a/tests/src/Functional/LinkHeaderTest.php +++ b/tests/src/Functional/LinkHeaderTest.php @@ -61,13 +61,13 @@ public function setUp() { 'type' => $this->testType->id(), 'title' => 'Referencer', 'field_member_of' => [$this->referenced->id()], - 'field_tags' => [$this->imageTerm->id()], + 'field_model' => [$this->imageTerm->id()], ]); $this->referencer->save(); list($this->file, $this->media) = $this->makeMediaAndFile($account); $this->media->set('field_media_of', $this->referencer); - $this->media->set('field_tags', $this->preservationMasterTerm); + $this->media->set('field_media_use', $this->preservationMasterTerm); $this->media->save(); } diff --git a/tests/src/Functional/NodeHasTermTest.php b/tests/src/Functional/NodeHasTermTest.php index a27cf4749..1e560109e 100644 --- a/tests/src/Functional/NodeHasTermTest.php +++ b/tests/src/Functional/NodeHasTermTest.php @@ -33,7 +33,7 @@ public function testNodeHasTerm() { $node = $this->container->get('entity_type.manager')->getStorage('node')->create([ 'type' => 'test_type', 'title' => 'Test Node', - 'field_tags' => [$this->imageTerm->id()], + 'field_model' => [$this->imageTerm->id()], ]); // Create and execute the condition. @@ -60,7 +60,7 @@ public function testNodeHasTerm() { $node = $this->container->get('entity_type.manager')->getStorage('node')->create([ 'type' => 'test_type', 'title' => 'Test Node', - 'field_tags' => [$this->preservationMasterTerm->id()], + 'field_model' => [$this->preservationMasterTerm->id()], ]); $condition->setContextValue('node', $node); @@ -81,7 +81,7 @@ public function testNodeHasTerm() { $node = $this->container->get('entity_type.manager')->getStorage('node')->create([ 'type' => 'test_type', 'title' => 'Test Node', - 'field_tags' => [$this->imageTerm->id(), $this->preservationMasterTerm->id()], + 'field_model' => [$this->imageTerm->id(), $this->preservationMasterTerm->id()], ]); $condition->setContextValue('node', $node); $this->assertTrue($condition->execute(), "Condition should pass if node has both terms");