Browse Source

Merge pull request #957 from rosiel/get-tests-passing

Get tests passing
pull/965/head
Jordan Dukart 2 years ago committed by GitHub
parent
commit
8502a347ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      .github/workflows/build-2.x.yml
  2. 2
      modules/islandora_audio/tests/src/Functional/GenerateAudioDerivativeTest.php
  3. 6
      modules/islandora_breadcrumbs/config/install/islandora_breadcrumbs.breadcrumbs.yml
  4. 2
      modules/islandora_breadcrumbs/islandora_breadcrumbs.info.yml
  5. 2
      modules/islandora_image/tests/src/Functional/GenerateImageDerivativeTest.php
  6. 2
      modules/islandora_video/tests/src/Functional/GenerateVideoDerivativeTest.php
  7. 4
      src/IslandoraUtils.php
  8. 12
      src/Plugin/Field/FieldFormatter/IslandoraImageFormatter.php
  9. 9
      tests/fixtures/config/core.entity_form_display.media.test_media_type.default.yml
  10. 29
      tests/fixtures/config/core.entity_form_display.node.test_type.default.yml
  11. 8
      tests/fixtures/config/core.entity_form_display.node.test_type.secondary.yml
  12. 1
      tests/fixtures/config/core.entity_form_mode.node.secondary.yml
  13. 15
      tests/fixtures/config/core.entity_view_display.node.test_type.default.yml
  14. 14
      tests/fixtures/config/core.entity_view_display.node.test_type.teaser.yml
  15. 2
      tests/fixtures/config/rest.resource.entity.file.yml
  16. 3
      tests/fixtures/config/rest.resource.entity.media.yml
  17. 1
      tests/fixtures/config/rest.resource.entity.node.yml
  18. 1
      tests/fixtures/config/rest.resource.entity.taxonomy_term.yml
  19. 2
      tests/src/Functional/DeleteNodeWithMediaAndFile.php
  20. 2
      tests/src/Functional/IslandoraFunctionalTestBase.php
  21. 2
      tests/src/Functional/IslandoraImageFormatterTest.php
  22. 2
      tests/src/Functional/JsonldTypeAlterReactionTest.php
  23. 2
      tests/src/Functional/MediaSourceUpdateTest.php
  24. 1
      tests/src/Kernel/EventGeneratorTest.php

4
.github/workflows/build-2.x.yml

@ -24,11 +24,11 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
# PHP 8.1 fails - see https://github.com/Islandora/islandora/issues/887 # PHP 8.1 fails - see https://github.com/Islandora/islandora/issues/887
php-versions: ["7.4", "8.0"] php-versions: ["7.4", "8.0", "8.1"]
# test-suite functional-javascript will appear to pass but will skip tests; missing chromedriver. # test-suite functional-javascript will appear to pass but will skip tests; missing chromedriver.
test-suite: ["kernel", "functional", "functional-javascript"] test-suite: ["kernel", "functional", "functional-javascript"]
# Not yet Drupal 10 ready - see https://github.com/Islandora/islandora/issues/888 # Not yet Drupal 10 ready - see https://github.com/Islandora/islandora/issues/888
drupal-version: ["9.4.x", "9.5.x-dev"] drupal-version: ["9.4.x", "9.5.x"]
mysql: ["8.0"] mysql: ["8.0"]
allowed_failure: [false] allowed_failure: [false]

2
modules/islandora_audio/tests/src/Functional/GenerateAudioDerivativeTest.php

@ -66,7 +66,7 @@ class GenerateAudioDerivativeTest extends GenerateDerivativeTestBase {
'name[0][value]' => 'Test Media', 'name[0][value]' => 'Test Media',
'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file.txt', 'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file.txt',
'field_media_of[0][target_id]' => 'Test Node', 'field_media_of[0][target_id]' => 'Test Node',
'field_tags[0][target_id]' => 'Preservation Master', 'field_media_use[0][target_id]' => $this->preservationMasterTerm->label(),
]; ];
$this->drupalGet('media/add/' . $this->testMediaType->id()); $this->drupalGet('media/add/' . $this->testMediaType->id());
$this->submitForm($values, $this->t('Save')); $this->submitForm($values, $this->t('Save'));

6
modules/islandora_breadcrumbs/config/install/islandora_breadcrumbs.breadcrumbs.yml

@ -2,9 +2,3 @@ maxDepth: -1
includeSelf: FALSE includeSelf: FALSE
referenceFields: referenceFields:
- field_member_of - field_member_of
dependencies:
module:
- islandora
enforced:
module:
- islandora_breadcrumbs

2
modules/islandora_breadcrumbs/islandora_breadcrumbs.info.yml

@ -5,4 +5,4 @@ core: 8.x
core_version_requirement: ^8 || ^9 core_version_requirement: ^8 || ^9
package: Islandora package: Islandora
dependencies: dependencies:
- drupal:islandora - islandora:islandora

2
modules/islandora_image/tests/src/Functional/GenerateImageDerivativeTest.php

@ -68,7 +68,7 @@ class GenerateImageDerivativeTest extends GenerateDerivativeTestBase {
'name[0][value]' => 'Test Media', 'name[0][value]' => 'Test Media',
'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file.txt', 'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file.txt',
'field_media_of[0][target_id]' => 'Test Node', 'field_media_of[0][target_id]' => 'Test Node',
'field_tags[0][target_id]' => 'Preservation Master', 'field_media_use[0][target_id]' => $this->preservationMasterTerm->label(),
]; ];
$this->drupalGet('media/add/' . $this->testMediaType->id()); $this->drupalGet('media/add/' . $this->testMediaType->id());
$this->submitForm($values, $this->t('Save')); $this->submitForm($values, $this->t('Save'));

2
modules/islandora_video/tests/src/Functional/GenerateVideoDerivativeTest.php

@ -63,7 +63,7 @@ class GenerateVideoDerivativeTest extends GenerateDerivativeTestBase {
'name[0][value]' => 'Test Media', 'name[0][value]' => 'Test Media',
'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file.txt', 'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file.txt',
'field_media_of[0][target_id]' => 'Test Node', 'field_media_of[0][target_id]' => 'Test Node',
'field_tags[0][target_id]' => 'Preservation Master', 'field_media_use[0][target_id]' => $this->preservationMasterTerm->label(),
]; ];
$this->drupalGet('media/add/' . $this->testMediaType->id()); $this->drupalGet('media/add/' . $this->testMediaType->id());
$this->submitForm($values, $this->t('Save')); $this->submitForm($values, $this->t('Save'));

4
src/IslandoraUtils.php

@ -148,6 +148,7 @@ class IslandoraUtils {
return []; return [];
} }
$mids = $this->entityTypeManager->getStorage('media')->getQuery() $mids = $this->entityTypeManager->getStorage('media')->getQuery()
->accessCheck(TRUE)
->condition(self::MEDIA_OF_FIELD, $node->id()) ->condition(self::MEDIA_OF_FIELD, $node->id())
->execute(); ->execute();
if (empty($mids)) { if (empty($mids)) {
@ -208,6 +209,7 @@ class IslandoraUtils {
// Query for media that reference this file. // Query for media that reference this file.
$query = $this->entityTypeManager->getStorage('media')->getQuery(); $query = $this->entityTypeManager->getStorage('media')->getQuery();
$query->accessCheck(TRUE);
$group = $query->orConditionGroup(); $group = $query->orConditionGroup();
foreach ($conditions as $condition) { foreach ($conditions as $condition) {
$group->condition($condition, $fid); $group->condition($condition, $fid);
@ -252,6 +254,7 @@ class IslandoraUtils {
} }
$results = $query $results = $query
->accessCheck(TRUE)
->condition($orGroup) ->condition($orGroup)
->execute(); ->execute();
@ -498,6 +501,7 @@ class IslandoraUtils {
array_walk($node_fields, $remove_entity); array_walk($node_fields, $remove_entity);
$query = $this->entityTypeManager->getStorage('media')->getQuery(); $query = $this->entityTypeManager->getStorage('media')->getQuery();
$query->accessCheck(TRUE);
$taxon_condition = $this->getEntityQueryOrCondition($query, $term_fields, $term->id()); $taxon_condition = $this->getEntityQueryOrCondition($query, $term_fields, $term->id());
$query->condition($taxon_condition); $query->condition($taxon_condition);
$node_condition = $this->getEntityQueryOrCondition($query, $node_fields, $node->id()); $node_condition = $this->getEntityQueryOrCondition($query, $node_fields, $node->id());

12
src/Plugin/Field/FieldFormatter/IslandoraImageFormatter.php

@ -5,6 +5,7 @@ namespace Drupal\islandora\Plugin\Field\FieldFormatter;
use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\File\FileUrlGenerator;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\image\Plugin\Field\FieldFormatter\ImageFormatter; use Drupal\image\Plugin\Field\FieldFormatter\ImageFormatter;
use Drupal\islandora\IslandoraUtils; use Drupal\islandora\IslandoraUtils;
@ -56,6 +57,8 @@ class IslandoraImageFormatter extends ImageFormatter {
* The image style storage. * The image style storage.
* @param \Drupal\islandora\IslandoraUtils $utils * @param \Drupal\islandora\IslandoraUtils $utils
* Islandora utils. * Islandora utils.
* @param \Drupal\Core\File\FileUrlGenerator $file_url_generator
* The File URL Generator.
*/ */
public function __construct( public function __construct(
$plugin_id, $plugin_id,
@ -67,7 +70,8 @@ class IslandoraImageFormatter extends ImageFormatter {
array $third_party_settings, array $third_party_settings,
AccountInterface $current_user, AccountInterface $current_user,
EntityStorageInterface $image_style_storage, EntityStorageInterface $image_style_storage,
IslandoraUtils $utils IslandoraUtils $utils,
FileUrlGenerator $file_url_generator
) { ) {
parent::__construct( parent::__construct(
$plugin_id, $plugin_id,
@ -78,7 +82,8 @@ class IslandoraImageFormatter extends ImageFormatter {
$view_mode, $view_mode,
$third_party_settings, $third_party_settings,
$current_user, $current_user,
$image_style_storage $image_style_storage,
$file_url_generator
); );
$this->utils = $utils; $this->utils = $utils;
} }
@ -97,7 +102,8 @@ class IslandoraImageFormatter extends ImageFormatter {
$configuration['third_party_settings'], $configuration['third_party_settings'],
$container->get('current_user'), $container->get('current_user'),
$container->get('entity_type.manager')->getStorage('image_style'), $container->get('entity_type.manager')->getStorage('image_style'),
$container->get('islandora.utils') $container->get('islandora.utils'),
$container->get('file_url_generator')
); );
} }

9
tests/fixtures/config/core.entity_form_display.media.test_media_type.default.yml vendored

@ -1,9 +1,11 @@
uuid: 9151a0fe-7729-4943-b506-dd6f8d12ceac
langcode: en langcode: en
status: true status: true
dependencies: dependencies:
config: config:
- field.field.media.test_media_type.field_media_file
- field.field.media.test_media_type.field_media_of - field.field.media.test_media_type.field_media_of
- field.field.media.test_media_type.field_tags - field.field.media.test_media_type.field_media_use
- media.type.test_media_type - media.type.test_media_type
module: module:
- path - path
@ -34,15 +36,17 @@ content:
region: content region: content
settings: settings:
match_operator: CONTAINS match_operator: CONTAINS
match_limit: 10
size: 60 size: 60
placeholder: '' placeholder: ''
third_party_settings: { } third_party_settings: { }
field_tags: field_media_use:
type: entity_reference_autocomplete type: entity_reference_autocomplete
weight: 3 weight: 3
region: content region: content
settings: settings:
match_operator: CONTAINS match_operator: CONTAINS
match_limit: 10
size: 60 size: 60
placeholder: '' placeholder: ''
third_party_settings: { } third_party_settings: { }
@ -64,6 +68,7 @@ content:
weight: 4 weight: 4
settings: settings:
match_operator: CONTAINS match_operator: CONTAINS
match_limit: 10
size: 60 size: 60
placeholder: '' placeholder: ''
region: content region: content

29
tests/fixtures/config/core.entity_form_display.node.test_type.default.yml vendored

@ -1,12 +1,13 @@
uuid: 90a6909f-a2aa-44e8-8b61-4cd54ec6974f
langcode: en langcode: en
status: true status: true
dependencies: dependencies:
config: config:
- field.field.node.test_type.field_member_of - field.field.node.test_type.field_member_of
- field.field.node.test_type.field_model
- node.type.test_type - node.type.test_type
module: module:
- path - path
- text
id: node.test_type.default id: node.test_type.default
targetEntityType: node targetEntityType: node
bundle: test_type bundle: test_type
@ -19,14 +20,25 @@ content:
settings: { } settings: { }
third_party_settings: { } third_party_settings: { }
field_member_of: field_member_of:
type: entity_reference_autocomplete
weight: 122 weight: 122
region: content
settings: settings:
match_operator: CONTAINS match_operator: CONTAINS
match_limit: 10
size: 60 size: 60
placeholder: '' placeholder: ''
third_party_settings: { } third_party_settings: { }
field_model:
type: entity_reference_autocomplete type: entity_reference_autocomplete
weight: 123
region: content region: content
settings:
match_operator: CONTAINS
match_limit: 10
size: 60
placeholder: ''
third_party_settings: { }
langcode: langcode:
type: language_select type: language_select
weight: 2 weight: 2
@ -42,24 +54,24 @@ content:
third_party_settings: { } third_party_settings: { }
promote: promote:
type: boolean_checkbox type: boolean_checkbox
settings:
display_label: true
weight: 15 weight: 15
region: content region: content
settings:
display_label: true
third_party_settings: { } third_party_settings: { }
status: status:
type: boolean_checkbox type: boolean_checkbox
settings:
display_label: true
weight: 120 weight: 120
region: content region: content
settings:
display_label: true
third_party_settings: { } third_party_settings: { }
sticky: sticky:
type: boolean_checkbox type: boolean_checkbox
settings:
display_label: true
weight: 16 weight: 16
region: content region: content
settings:
display_label: true
third_party_settings: { } third_party_settings: { }
title: title:
type: string_textfield type: string_textfield
@ -72,10 +84,11 @@ content:
uid: uid:
type: entity_reference_autocomplete type: entity_reference_autocomplete
weight: 5 weight: 5
region: content
settings: settings:
match_operator: CONTAINS match_operator: CONTAINS
match_limit: 10
size: 60 size: 60
placeholder: '' placeholder: ''
region: content
third_party_settings: { } third_party_settings: { }
hidden: { } hidden: { }

8
tests/fixtures/config/core.entity_form_display.node.test_type.secondary.yml vendored

@ -1,12 +1,12 @@
uuid: e24c2b3c-60e4-4ff5-99cb-80e5e67e7b04
langcode: en langcode: en
status: true status: true
dependencies: dependencies:
config: config:
- core.entity_form_mode.node.secondary
- field.field.node.test_type.field_member_of - field.field.node.test_type.field_member_of
- field.field.node.test_type.field_model
- node.type.test_type - node.type.test_type
module:
- path
- text
id: node.test_type.secondary id: node.test_type.secondary
targetEntityType: node targetEntityType: node
bundle: test_type bundle: test_type
@ -23,6 +23,8 @@ content:
hidden: hidden:
created: true created: true
field_media: true field_media: true
field_member_of: true
field_model: true
field_node: true field_node: true
langcode: true langcode: true
path: true path: true

1
tests/fixtures/config/core.entity_form_mode.node.secondary.yml vendored

@ -1,3 +1,4 @@
uuid: d9f22219-ff4c-48cc-a98a-6ccaad7a880d
langcode: en langcode: en
status: true status: true
dependencies: dependencies:

15
tests/fixtures/config/core.entity_view_display.node.test_type.default.yml vendored

@ -1,11 +1,12 @@
uuid: 36f4aecf-0e14-4281-a213-ca7d129da52a
langcode: en langcode: en
status: true status: true
dependencies: dependencies:
config: config:
- field.field.node.test_type.field_member_of - field.field.node.test_type.field_member_of
- field.field.node.test_type.field_model
- node.type.test_type - node.type.test_type
module: module:
- text
- user - user
id: node.test_type.default id: node.test_type.default
targetEntityType: node targetEntityType: node
@ -13,14 +14,24 @@ bundle: test_type
mode: default mode: default
content: content:
field_member_of: field_member_of:
weight: 102 type: entity_reference_label
label: above label: above
settings: settings:
link: true link: true
third_party_settings: { } third_party_settings: { }
weight: 102
region: content
field_model:
type: entity_reference_label type: entity_reference_label
label: above
settings:
link: true
third_party_settings: { }
weight: 103
region: content region: content
links: links:
settings: { }
third_party_settings: { }
weight: 100 weight: 100
region: content region: content
hidden: hidden:

14
tests/fixtures/config/core.entity_view_display.node.test_type.teaser.yml vendored

@ -1,19 +1,25 @@
uuid: 0308339a-a9e5-4a04-8ce2-9f62ed504e34 uuid: b337f462-8e64-4853-be65-9e03b94515bf
langcode: en langcode: en
status: true status: true
dependencies: dependencies:
config: config:
- core.entity_view_mode.node.teaser - core.entity_view_mode.node.teaser
- field.field.node.test_type.field_member_of
- field.field.node.test_type.field_model
- node.type.test_type - node.type.test_type
module: module:
- text
- user - user
id: node.test_type.teaser id: node.test_type.teaser
targetEntityType: node targetEntityType: node
bundle: test_type bundle: test_type
mode: teaser mode: teaser
content: content:
links:
settings: { }
third_party_settings: { }
weight: 100
region: content
hidden: hidden:
body: true field_member_of: true
links: true field_model: true
langcode: true langcode: true

2
tests/fixtures/config/rest.resource.entity.file.yml vendored

@ -1,3 +1,4 @@
uuid: 11c4e25e-6b06-4270-b934-243e4f4aade1
langcode: en langcode: en
status: true status: true
dependencies: dependencies:
@ -26,3 +27,4 @@ configuration:
supported_auth: supported_auth:
- basic_auth - basic_auth
- jwt_auth - jwt_auth
- cookie

3
tests/fixtures/config/rest.resource.entity.media.yml vendored

@ -1,3 +1,4 @@
uuid: 9a5633b1-6a1a-40b2-8482-c24cf44122ff
langcode: en langcode: en
status: true status: true
dependencies: dependencies:
@ -5,7 +6,7 @@ dependencies:
- basic_auth - basic_auth
- jsonld - jsonld
- jwt - jwt
- media_entity - media
- serialization - serialization
- user - user
id: entity.media id: entity.media

1
tests/fixtures/config/rest.resource.entity.node.yml vendored

@ -1,3 +1,4 @@
uuid: 08a90469-0355-4b41-a4d6-cb6b53072b8c
langcode: en langcode: en
status: true status: true
dependencies: dependencies:

1
tests/fixtures/config/rest.resource.entity.taxonomy_term.yml vendored

@ -1,3 +1,4 @@
uuid: 7534e393-12a7-498c-a4a3-a7bbe4ff9a5d
langcode: en langcode: en
status: true status: true
dependencies: dependencies:

2
tests/src/Functional/DeleteNodeWithMediaAndFile.php

@ -42,8 +42,8 @@ class DeleteNodeWithMediaAndFile extends IslandoraFunctionalTestBase {
'uri' => "public://test.jpeg", 'uri' => "public://test.jpeg",
'filename' => "test.jpeg", 'filename' => "test.jpeg",
'filemime' => "image/jpeg", 'filemime' => "image/jpeg",
'status' => FILE_STATUS_PERMANENT,
]); ]);
$file->setPermanent();
$file->save(); $file->save();
$this->drupalGet("node/1/delete"); $this->drupalGet("node/1/delete");

2
tests/src/Functional/IslandoraFunctionalTestBase.php

@ -438,8 +438,8 @@ EOD;
'uri' => "public://test_file.txt", 'uri' => "public://test_file.txt",
'filename' => "test_file.txt", 'filename' => "test_file.txt",
'filemime' => "text/plain", 'filemime' => "text/plain",
'status' => FILE_STATUS_PERMANENT,
]); ]);
$file->setPermanent();
$file->save(); $file->save();
// Get the source field for the media. // Get the source field for the media.

2
tests/src/Functional/IslandoraImageFormatterTest.php

@ -59,8 +59,8 @@ class IslandoraImageFormatterTest extends IslandoraFunctionalTestBase {
'uri' => "public://test.jpeg", 'uri' => "public://test.jpeg",
'filename' => "test.jpeg", 'filename' => "test.jpeg",
'filemime' => "image/jpeg", 'filemime' => "image/jpeg",
'status' => FILE_STATUS_PERMANENT,
]); ]);
$file->setPermanent();
$file->save(); $file->save();
// Make the media, and associate it with the image and node. // Make the media, and associate it with the image and node.

2
tests/src/Functional/JsonldTypeAlterReactionTest.php

@ -30,7 +30,7 @@ class JsonldTypeAlterReactionTest extends JsonldSelfReferenceReactionTest {
'new_storage_type' => 'string', 'new_storage_type' => 'string',
'label' => 'Typed Predicate', 'label' => 'Typed Predicate',
'field_name' => 'type_predicate', 'field_name' => 'type_predicate',
], $this->t('Save and continue')); ], 'Save and continue');
$this->submitForm([], $this->t('Save field settings')); $this->submitForm([], $this->t('Save field settings'));
$this->submitForm([], $this->t('Save settings')); $this->submitForm([], $this->t('Save settings'));
$this->assertSession()->responseContains('field_type_predicate'); $this->assertSession()->responseContains('field_type_predicate');

2
tests/src/Functional/MediaSourceUpdateTest.php

@ -52,8 +52,8 @@ class MediaSourceUpdateTest extends IslandoraFunctionalTestBase {
'uri' => "public://test_file.txt", 'uri' => "public://test_file.txt",
'filename' => "test_file.txt", 'filename' => "test_file.txt",
'filemime' => "text/plain", 'filemime' => "text/plain",
'status' => FILE_STATUS_PERMANENT,
]); ]);
$this->file->setPermanent();
$this->file->save(); $this->file->save();
// Get the source field for the media. // Get the source field for the media.

1
tests/src/Kernel/EventGeneratorTest.php

@ -116,7 +116,6 @@ class EventGeneratorTest extends IslandoraKernelTestBase {
['event' => 'delete', 'queue' => 'islandora-indexing-fcrepo-delete'] ['event' => 'delete', 'queue' => 'islandora-indexing-fcrepo-delete']
); );
$msg = json_decode($json, TRUE); $msg = json_decode($json, TRUE);
$msg = json_decode($json, TRUE);
$this->assertBasicStructure($msg); $this->assertBasicStructure($msg);
$this->assertTrue($msg["type"] == "Delete", "Event must be of type 'Delete'."); $this->assertTrue($msg["type"] == "Delete", "Event must be of type 'Delete'.");

Loading…
Cancel
Save