Compare commits

...

18 Commits

Author SHA1 Message Date
Rosie Le Faive b8f0b9c966
Allow NodeHasMediaUse view filter to work on views with node relationships. (#1010) 4 months ago
Akanksha Singh da47bcfb08
Node has Parent context does not explicitly check if the field exists. (#1019) 4 months ago
Rosie Le Faive 5e958a5e10 Allow application/xml in OCR Action. 4 months ago
Rosie Le Faive 3902cce0ac
Allow filehash 3 (#1016) 5 months ago
Aron Novak c80769580c
Do not have a fatal error on a missing action (#1014) 5 months ago
Adam 54206de712
Fix Functional Javascript CI tests (#1004) 5 months ago
Joe Corall 9b2661696d
Add hOCR functionality (#1006) 5 months ago
Alexander O'Neill 089a3654ba
Merge pull request #1007 from rosiel/2.x 5 months ago
Rosie Le Faive 263666f5fc Remove new_storage_type from form part 2. 6 months ago
Rosie Le Faive 95c2d6c0c9 Syntax. 6 months ago
Rosie Le Faive cde2c133e1 Update tests for D10.3's new field selector form. 6 months ago
Rosie Le Faive a2c31fcaad @adam-vessey's fix for drupalGet headers. 6 months ago
Rosie Le Faive 9ed3637339
Update islandora.module (#1008) 6 months ago
Rosie Le Faive 13bc15ea43 Last attempt to not pass translatables as button labels. 7 months ago
Rosie Le Faive 9f2277fc51 Exclude PHP 8.3 with Drupal 10.1. 7 months ago
Rosie Le Faive 89261c17ae Add some forgotten translateable markup. 7 months ago
Rosie Le Faive 3784def287 Tests use strings not translateable markup to select interface buttons. 7 months ago
Rosie Le Faive e30cdbf681 Update testing drupal and php versions 7 months ago
  1. 49
      .github/workflows/build-2.x.yml
  2. 2
      composer.json
  3. 1
      islandora.module
  4. 6
      modules/islandora_audio/tests/src/Functional/GenerateAudioDerivativeTest.php
  5. 12
      modules/islandora_iiif/config/schema/islandora_iiif.schema.yml
  6. 135
      modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php
  7. 6
      modules/islandora_image/tests/src/Functional/GenerateImageDerivativeTest.php
  8. 5
      modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivative.php
  9. 6
      modules/islandora_video/tests/src/Functional/GenerateVideoDerivativeTest.php
  10. 2
      phpunit.xml
  11. 2
      src/IslandoraContextManager.php
  12. 6
      src/Plugin/Condition/NodeHasParent.php
  13. 74
      src/Plugin/views/filter/NodeHasMediaUse.php
  14. 29
      src/PresetReaction/PresetReaction.php
  15. 221
      tests/modules/integer_weight_test_views/test_views/views.view.test_integer_weight.yml
  16. 4
      tests/src/Functional/ContentEntityTypeTest.php
  17. 6
      tests/src/Functional/DerivativeReactionTest.php
  18. 6
      tests/src/Functional/EmitNodeEventTest.php
  19. 2
      tests/src/Functional/EntityBundleTest.php
  20. 2
      tests/src/Functional/FormDisplayAlterReactionTest.php
  21. 2
      tests/src/Functional/IndexingTest.php
  22. 8
      tests/src/Functional/IslandoraFunctionalTestBase.php
  23. 10
      tests/src/Functional/IslandoraSettingsFormTest.php
  24. 2
      tests/src/Functional/JsonldSelfReferenceReactionTest.php
  25. 38
      tests/src/Functional/JsonldTypeAlterReactionTest.php
  26. 4
      tests/src/Functional/LinkHeaderTest.php
  27. 2
      tests/src/Functional/ViewModeAlterReactionTest.php
  28. 39
      tests/src/FunctionalJavascript/IntegerWeightTest.php

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

@ -1,34 +1,33 @@
# This is a basic workflow to help you get started with Actions
name: CI name: CI
# Controls when the action will run.
on: on:
# Triggers the workflow on push or pull request events but only for the 2.x branch
push: push:
branches: [ 2.x ] branches: [ 2.x ]
pull_request: pull_request:
branches: [ 2.x ] branches: [ 2.x ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch: workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs: jobs:
# This workflow contains a single job called "build"
build: build:
# The type of runner that the job will run on env:
DRUPAL_VERSION: ${{ matrix.drupal-version }}
SCRIPT_DIR: ${{ github.workspace }}/islandora_ci
DRUPAL_DIR: /opt/drupal
PHPUNIT_FILE: ${{ github.workspace }}/build_dir/phpunit.xml
runs-on: ubuntu-latest runs-on: ubuntu-latest
continue-on-error: ${{ matrix.allowed_failure }} continue-on-error: ${{ matrix.allowed_failure }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ["8.1", "8.2"] php-versions: ["8.1", "8.2", "8.3"]
# 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"]
drupal-version: ["10.0.x", "10.1.x", "10.2.x-dev"] drupal-version: ["10.1.x", "10.2.x", "10.3.x-dev"]
mysql: ["8.0"] mysql: ["8.0"]
allowed_failure: [false] allowed_failure: [false]
exclude:
- php-versions: "8.3"
drupal-version: "10.1.x"
name: PHP ${{ matrix.php-versions }} | drupal ${{ matrix.drupal-version }} | mysql ${{ matrix.mysql }} | test-suite ${{ matrix.test-suite }} name: PHP ${{ matrix.php-versions }} | drupal ${{ matrix.drupal-version }} | mysql ${{ matrix.mysql }} | test-suite ${{ matrix.test-suite }}
@ -48,17 +47,15 @@ jobs:
- 61616:61616 - 61616:61616
- 61613:61613 - 61613:61613
# Steps represent a sequence of tasks that will be executed as part of the job
steps: steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
path: build_dir path: build_dir
- name: Checkout islandora_ci - name: Checkout islandora_ci
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
repository: islandora/islandora_ci repository: islandora/islandora_ci
ref: github-actions ref: github-actions
@ -76,13 +73,6 @@ jobs:
sudo apt-get remove -y mysql-client mysql-common sudo apt-get remove -y mysql-client mysql-common
sudo apt-get install -y mysql-client sudo apt-get install -y mysql-client
- name: Set environment variables
run: |
echo "DRUPAL_VERSION=${{ matrix.drupal-version }}" >> $GITHUB_ENV
echo "SCRIPT_DIR=$GITHUB_WORKSPACE/islandora_ci" >> $GITHUB_ENV
echo "DRUPAL_DIR=/opt/drupal" >> $GITHUB_ENV
echo "PHPUNIT_FILE=$GITHUB_WORKSPACE/build_dir/phpunit.xml" >> $GITHUB_ENV
- name: Cache Composer dependencies - name: Cache Composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
@ -115,8 +105,21 @@ jobs:
- name: Test scripts - name: Test scripts
run: $SCRIPT_DIR/travis_scripts.sh run: $SCRIPT_DIR/travis_scripts.sh
- name: Start chromedriver
if: matrix.test-suite == 'functional-javascript'
run: |-
/usr/local/share/chromedriver-linux64/chromedriver \
--log-path=/tmp/chromedriver.log \
--verbose \
--allowed-ips= \
--allowed-origins=* &
- name: PHPUNIT tests - name: PHPUNIT tests
run: | run: |
cd $DRUPAL_DIR/web/core cd $DRUPAL_DIR/web/core
$DRUPAL_DIR/vendor/bin/phpunit --verbose --testsuite "${{ matrix.test-suite }}" $DRUPAL_DIR/vendor/bin/phpunit --verbose --testsuite "${{ matrix.test-suite }}"
- name: Print chromedriver logs
if: matrix.test-suite == 'functional-javascript'
run: cat /tmp/chromedriver.log

2
composer.json

@ -18,7 +18,7 @@
"drupal/ctools": "^3.8 || ^4", "drupal/ctools": "^3.8 || ^4",
"drupal/eva" : "^3.0", "drupal/eva" : "^3.0",
"drupal/file_replace": "^1.1", "drupal/file_replace": "^1.1",
"drupal/filehash": "^2", "drupal/filehash": "^2 || ^3",
"drupal/flysystem" : "^2.0@alpha", "drupal/flysystem" : "^2.0@alpha",
"drupal/jwt": "^1.1 || ^2", "drupal/jwt": "^1.1 || ^2",
"drupal/migrate_plus" : "^5.1 || ^6", "drupal/migrate_plus" : "^5.1 || ^6",

1
islandora.module

@ -615,6 +615,7 @@ function islandora_form_block_form_alter(&$form, FormStateInterface $form_state,
unset($form['visibility']['media_is_islandora_media']); unset($form['visibility']['media_is_islandora_media']);
unset($form['visibility']['media_uses_filesystem']); unset($form['visibility']['media_uses_filesystem']);
unset($form['visibility']['node_had_namespace']); unset($form['visibility']['node_had_namespace']);
unset($form['visibility']['node_has_ancestor']);
unset($form['visibility']['node_has_parent']); unset($form['visibility']['node_has_parent']);
unset($form['visibility']['node_has_term']); unset($form['visibility']['node_has_term']);
unset($form['visibility']['node_is_islandora_object']); unset($form['visibility']['node_is_islandora_object']);

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

@ -40,7 +40,7 @@ class GenerateAudioDerivativeTest extends GenerateDerivativeTestBase {
// Create an action to generate a audio derivative. // Create an action to generate a audio derivative.
$this->drupalGet('admin/config/system/actions'); $this->drupalGet('admin/config/system/actions');
$this->getSession()->getPage()->findById("edit-action")->selectOption("Generate a audio derivative"); $this->getSession()->getPage()->findById("edit-action")->selectOption("Generate a audio derivative");
$this->getSession()->getPage()->pressButton($this->t('Create')); $this->getSession()->getPage()->pressButton('Create');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
$this->getSession()->getPage()->fillField('edit-label', "Generate audio test derivative"); $this->getSession()->getPage()->fillField('edit-label', "Generate audio test derivative");
@ -53,7 +53,7 @@ class GenerateAudioDerivativeTest extends GenerateDerivativeTestBase {
$this->getSession()->getPage()->fillField('edit-args', "-f mp3"); $this->getSession()->getPage()->fillField('edit-args', "-f mp3");
$this->getSession()->getPage()->fillField('edit-scheme', "public"); $this->getSession()->getPage()->fillField('edit-scheme', "public");
$this->getSession()->getPage()->fillField('edit-path', "derp.mov"); $this->getSession()->getPage()->fillField('edit-path', "derp.mov");
$this->getSession()->getPage()->pressButton($this->t('Save')); $this->getSession()->getPage()->pressButton('Save');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
// Create a context and add the action as a derivative reaction. // Create a context and add the action as a derivative reaction.
@ -69,7 +69,7 @@ class GenerateAudioDerivativeTest extends GenerateDerivativeTestBase {
'field_media_use[0][target_id]' => $this->preservationMasterTerm->label(), '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, 'Save');
$expected = [ $expected = [
'source_uri' => 'test_file.txt', 'source_uri' => 'test_file.txt',

12
modules/islandora_iiif/config/schema/islandora_iiif.schema.yml

@ -17,5 +17,17 @@ views.style.iiif_manifest:
mapping: mapping:
iiif_tile_field: iiif_tile_field:
type: sequence type: sequence
label: "Tile source field(s)"
sequence: sequence:
type: string type: string
iiif_ocr_file_field:
type: sequence
label: "Structured OCR data file field"
sequence:
type: string
structured_text_term_uri:
type: string
label: "Structured text term"
search_endpoint:
type: string
label: "Search endpoint path"

135
modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php

@ -11,6 +11,8 @@ use Drupal\Core\Field\FieldItemInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\islandora\IslandoraUtils;
use Drupal\taxonomy\TermInterface;
use Drupal\views\Plugin\views\style\StylePluginBase; use Drupal\views\Plugin\views\style\StylePluginBase;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
use GuzzleHttp\Client; use GuzzleHttp\Client;
@ -35,6 +37,13 @@ use Symfony\Component\HttpFoundation\Request;
*/ */
class IIIFManifest extends StylePluginBase { class IIIFManifest extends StylePluginBase {
/**
* Islandora utility functions.
*
* @var \Drupal\islandora\IslandoraUtils
*/
protected $utils;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -108,10 +117,24 @@ class IIIFManifest extends StylePluginBase {
*/ */
protected $moduleHandler; protected $moduleHandler;
/**
* Memoized structured text term.
*
* @var \Drupal\taxonomy\TermInterface|null
*/
protected ?TermInterface $structuredTextTerm;
/**
* Flag to track if we _have_ attempted a lookup, as the value is nullable.
*
* @var bool
*/
protected bool $structuredTextTermMemoized = FALSE;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(array $configuration, $plugin_id, $plugin_definition, SerializerInterface $serializer, Request $request, ImmutableConfig $iiif_config, EntityTypeManagerInterface $entity_type_manager, FileSystemInterface $file_system, Client $http_client, MessengerInterface $messenger, ModuleHandlerInterface $moduleHandler) { public function __construct(array $configuration, $plugin_id, $plugin_definition, SerializerInterface $serializer, Request $request, ImmutableConfig $iiif_config, EntityTypeManagerInterface $entity_type_manager, FileSystemInterface $file_system, Client $http_client, MessengerInterface $messenger, ModuleHandlerInterface $moduleHandler, IslandoraUtils $utils) {
parent::__construct($configuration, $plugin_id, $plugin_definition); parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->serializer = $serializer; $this->serializer = $serializer;
@ -121,6 +144,7 @@ class IIIFManifest extends StylePluginBase {
$this->fileSystem = $file_system; $this->fileSystem = $file_system;
$this->httpClient = $http_client; $this->httpClient = $http_client;
$this->messenger = $messenger; $this->messenger = $messenger;
$this->utils = $utils;
$this->moduleHandler = $moduleHandler; $this->moduleHandler = $moduleHandler;
} }
@ -139,7 +163,8 @@ class IIIFManifest extends StylePluginBase {
$container->get('file_system'), $container->get('file_system'),
$container->get('http_client'), $container->get('http_client'),
$container->get('messenger'), $container->get('messenger'),
$container->get('module_handler') $container->get('module_handler'),
$container->get('islandora.utils')
); );
} }
@ -217,6 +242,9 @@ class IIIFManifest extends StylePluginBase {
$content_type = 'json'; $content_type = 'json';
// Add a search endpoint if one is defined.
$this->addSearchEndpoint($json, $url_components);
// Give other modules a chance to alter the manifest. // Give other modules a chance to alter the manifest.
$this->moduleHandler->alter('islandora_iiif_manifest', $json, $this); $this->moduleHandler->alter('islandora_iiif_manifest', $json, $this);
@ -300,7 +328,7 @@ class IIIFManifest extends StylePluginBase {
], ],
]; ];
if ($ocr_url = $this->getOcrUrl($entity, $row, $i)) { if ($ocr_url = $this->getOcrUrl($entity)) {
$tmp_canvas['seeAlso'] = [ $tmp_canvas['seeAlso'] = [
'@id' => $ocr_url, '@id' => $ocr_url,
'format' => 'text/vnd.hocr+html', 'format' => 'text/vnd.hocr+html',
@ -380,30 +408,38 @@ class IIIFManifest extends StylePluginBase {
* *
* @param \Drupal\Core\Entity\EntityInterface $entity * @param \Drupal\Core\Entity\EntityInterface $entity
* The entity at the current row. * The entity at the current row.
* @param \Drupal\views\ResultRow $row
* Result row.
* @param int $delta
* The delta in case there are multiple canvases on one media.
* *
* @return string|false * @return string|false
* The absolute URL of the current row's structured text, * The absolute URL of the current row's structured text,
* or FALSE if none. * or FALSE if none.
*/ */
protected function getOcrUrl(EntityInterface $entity, ResultRow $row, $delta) { protected function getOcrUrl(EntityInterface $entity) {
$ocr_url = FALSE; $ocr_url = FALSE;
$iiif_ocr_file_field = !empty($this->options['iiif_ocr_file_field']) ? array_filter(array_values($this->options['iiif_ocr_file_field'])) : []; $iiif_ocr_file_field = !empty($this->options['iiif_ocr_file_field']) ? array_filter(array_values($this->options['iiif_ocr_file_field'])) : [];
$ocrField = count($iiif_ocr_file_field) > 0 ? $this->view->field[$iiif_ocr_file_field[0]] : NULL; $ocrField = count($iiif_ocr_file_field) > 0 ? $this->view->field[$iiif_ocr_file_field[0]] : NULL;
if ($ocrField) { if ($ocrField) {
$ocr_entity = $ocrField->getEntity($row); $ocr_entity = $entity;
$ocr_field_name = $ocrField->definition['field_name']; $ocr_field_name = $ocrField->definition['field_name'];
if (!is_null($ocr_field_name)) { if (!is_null($ocr_field_name)) {
$ocrs = $ocr_entity->{$ocr_field_name}; $ocrs = $ocr_entity->{$ocr_field_name};
$ocr = isset($ocrs[$delta]) ? $ocrs[$delta] : FALSE; $ocr = $ocrs[0] ?? FALSE;
if ($ocr) { if ($ocr) {
$ocr_url = $ocr->entity->createFileUrl(FALSE); $ocr_url = $ocr->entity->createFileUrl(FALSE);
} }
} }
} }
elseif ($structured_text_term = $this->getStructuredTextTerm()) {
$parent_node = $this->utils->getParentNode($entity);
$ocr_entity_array = $this->utils->getMediaReferencingNodeAndTerm($parent_node, $structured_text_term);
$ocr_entity_id = is_array($ocr_entity_array) ? array_shift($ocr_entity_array) : NULL;
$ocr_entity = $ocr_entity_id ? $this->entityTypeManager->getStorage('media')->load($ocr_entity_id) : NULL;
if ($ocr_entity) {
$ocr_file_source = $ocr_entity->getSource();
$ocr_fid = $ocr_file_source->getSourceFieldValue($ocr_entity);
$ocr_file = $this->entityTypeManager->getStorage('file')->load($ocr_fid);
$ocr_url = $ocr_file->createFileUrl(FALSE);
}
}
return $ocr_url; return $ocr_url;
} }
@ -448,6 +484,29 @@ class IIIFManifest extends StylePluginBase {
return $options; return $options;
} }
/**
* Add the configured search endpoint to the manifest.
*
* @param array $json
* The IIIF manifest.
* @param array $url_components
* The search endpoint URL as array.
*/
protected function addSearchEndpoint(array &$json, array $url_components) {
$url_base = $this->getRequest()->getSchemeAndHttpHost();
$hocr_search_path = $this->options['search_endpoint'];
$hocr_search_url = $url_base . '/' . ltrim($hocr_search_path, '/');
$hocr_search_url = str_replace('%node', $url_components[1], $hocr_search_url);
$json['service'][] = [
"@context" => "http://iiif.io/api/search/0/context.json",
"@id" => $hocr_search_url,
"profile" => "http://iiif.io/api/search/0/search",
"label" => t("Search inside this work"),
];
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -504,10 +563,27 @@ class IIIFManifest extends StylePluginBase {
'#title' => $this->t('Structured OCR data file field'), '#title' => $this->t('Structured OCR data file field'),
'#type' => 'checkboxes', '#type' => 'checkboxes',
'#default_value' => $this->options['iiif_ocr_file_field'], '#default_value' => $this->options['iiif_ocr_file_field'],
'#description' => $this->t('The source of structured OCR text for each entity.'), '#description' => $this->t("If the hOCR is a field on the same entity as the image source field above, select it here. If it's found in a related entity via the term below, leave this blank."),
'#options' => $field_options, '#options' => $field_options,
'#required' => FALSE, '#required' => FALSE,
]; ];
$form['structured_text_term'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'taxonomy_term',
'#title' => $this->t('Structured OCR text term'),
'#default_value' => $this->getStructuredTextTerm(),
'#required' => FALSE,
'#description' => $this->t('Term indicating the media that holds structured text, such as hOCR, for the given object. Use this if the text is on a separate media from the tile source.'),
];
$form['search_endpoint'] = [
'#type' => 'textfield',
'#title' => $this->t("Search endpoint path."),
'#description' => $this->t("If there is a search endpoint to search within the book that returns IIIF annotations, put it here. Use %node substitution where needed.<br>E.g., paged-content-search/%node"),
'#default_value' => $this->options['search_endpoint'],
'#required' => FALSE,
];
} }
/** /**
@ -520,4 +596,41 @@ class IIIFManifest extends StylePluginBase {
return ['json' => 'json']; return ['json' => 'json'];
} }
/**
* Submit handler for options form.
*
* Used to store the structured text media term by URL instead of Ttid.
*
* @param array $form
* The form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The form state object.
*/
// @codingStandardsIgnoreStart
public function submitOptionsForm(&$form, FormStateInterface $form_state) {
// @codingStandardsIgnoreEnd
$style_options = $form_state->getValue('style_options');
$tid = $style_options['structured_text_term'];
unset($style_options['structured_text_term']);
$term = $this->entityTypeManager->getStorage('taxonomy_term')->load($tid);
$style_options['structured_text_term_uri'] = $this->utils->getUriForTerm($term);
$form_state->setValue('style_options', $style_options);
parent::submitOptionsForm($form, $form_state);
}
/**
* Get the structured text term.
*
* @return \Drupal\taxonomy\TermInterface|null
* The term if it could be found; otherwise, NULL.
*/
protected function getStructuredTextTerm() : ?TermInterface {
if (!$this->structuredTextTermMemoized) {
$this->structuredTextTermMemoized = TRUE;
$this->structuredTextTerm = $this->utils->getTermForUri($this->options['structured_text_term_uri']);
}
return $this->structuredTextTerm;
}
} }

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

@ -42,7 +42,7 @@ class GenerateImageDerivativeTest extends GenerateDerivativeTestBase {
// Create an action to generate a jpeg thumbnail. // Create an action to generate a jpeg thumbnail.
$this->drupalGet('admin/config/system/actions'); $this->drupalGet('admin/config/system/actions');
$this->getSession()->getPage()->findById("edit-action")->selectOption("Generate an image derivative"); $this->getSession()->getPage()->findById("edit-action")->selectOption("Generate an image derivative");
$this->getSession()->getPage()->pressButton($this->t('Create')); $this->getSession()->getPage()->pressButton('Create');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
$this->getSession()->getPage()->fillField('edit-label', "Generate image test derivative"); $this->getSession()->getPage()->fillField('edit-label', "Generate image test derivative");
@ -55,7 +55,7 @@ class GenerateImageDerivativeTest extends GenerateDerivativeTestBase {
$this->getSession()->getPage()->fillField('edit-args', "-thumbnail 20x20"); $this->getSession()->getPage()->fillField('edit-args', "-thumbnail 20x20");
$this->getSession()->getPage()->fillField('edit-scheme', "public"); $this->getSession()->getPage()->fillField('edit-scheme', "public");
$this->getSession()->getPage()->fillField('edit-path', "derp.jpeg"); $this->getSession()->getPage()->fillField('edit-path', "derp.jpeg");
$this->getSession()->getPage()->pressButton($this->t('Save')); $this->getSession()->getPage()->pressButton('Save');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
// Create a context and add the action as a derivative reaction. // Create a context and add the action as a derivative reaction.
@ -71,7 +71,7 @@ class GenerateImageDerivativeTest extends GenerateDerivativeTestBase {
'field_media_use[0][target_id]' => $this->preservationMasterTerm->label(), '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, 'Save');
$expected = [ $expected = [
'source_uri' => 'test_file.txt', 'source_uri' => 'test_file.txt',

5
modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivative.php

@ -48,8 +48,9 @@ class GenerateOCRDerivative extends AbstractGenerateDerivative {
*/ */
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::validateConfigurationForm($form, $form_state); parent::validateConfigurationForm($form, $form_state);
$exploded_mime = explode('/', $form_state->getValue('mimetype')); $mime = $form_state->getValue('mimetype');
if ($exploded_mime[0] != 'text') { $exploded_mime = explode('/', $mime);
if ($exploded_mime[0] != 'text' && $mime != 'application/xml') {
$form_state->setErrorByName( $form_state->setErrorByName(
'mimetype', 'mimetype',
$this->t('Please enter file mimetype (e.g. text/plain.)') $this->t('Please enter file mimetype (e.g. text/plain.)')

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

@ -37,7 +37,7 @@ class GenerateVideoDerivativeTest extends GenerateDerivativeTestBase {
// Create an action to generate a jpeg thumbnail. // Create an action to generate a jpeg thumbnail.
$this->drupalGet('admin/config/system/actions'); $this->drupalGet('admin/config/system/actions');
$this->getSession()->getPage()->findById("edit-action")->selectOption("Generate a video derivative"); $this->getSession()->getPage()->findById("edit-action")->selectOption("Generate a video derivative");
$this->getSession()->getPage()->pressButton($this->t('Create')); $this->getSession()->getPage()->pressButton('Create');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
$this->getSession()->getPage()->fillField('edit-label', "Generate video test derivative"); $this->getSession()->getPage()->fillField('edit-label', "Generate video test derivative");
@ -50,7 +50,7 @@ class GenerateVideoDerivativeTest extends GenerateDerivativeTestBase {
$this->getSession()->getPage()->fillField('edit-args', "-f mp4"); $this->getSession()->getPage()->fillField('edit-args', "-f mp4");
$this->getSession()->getPage()->fillField('edit-scheme', "public"); $this->getSession()->getPage()->fillField('edit-scheme', "public");
$this->getSession()->getPage()->fillField('edit-path', "derp.mov"); $this->getSession()->getPage()->fillField('edit-path', "derp.mov");
$this->getSession()->getPage()->pressButton($this->t('Save')); $this->getSession()->getPage()->pressButton('Save');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
// Create a context and add the action as a derivative reaction. // Create a context and add the action as a derivative reaction.
@ -66,7 +66,7 @@ class GenerateVideoDerivativeTest extends GenerateDerivativeTestBase {
'field_media_use[0][target_id]' => $this->preservationMasterTerm->label(), '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, 'Save');
$expected = [ $expected = [
'source_uri' => 'test_file.txt', 'source_uri' => 'test_file.txt',

2
phpunit.xml

@ -47,7 +47,7 @@
<!-- Example for changing the driver args to phantomjs tests MINK_DRIVER_ARGS_PHANTOMJS value: '["http://127.0.0.1:8510"]' --> <!-- Example for changing the driver args to phantomjs tests MINK_DRIVER_ARGS_PHANTOMJS value: '["http://127.0.0.1:8510"]' -->
<env name="MINK_DRIVER_ARGS_PHANTOMJS" value=""/> <env name="MINK_DRIVER_ARGS_PHANTOMJS" value=""/>
<!-- Example for changing the driver args to webdriver tests MINK_DRIVER_ARGS_WEBDRIVER value: '["chrome", { "chromeOptions": { "w3c": false } }, "http://localhost:4444/wd/hub"]' For using the Firefox browser, replace "chrome" with "firefox" --> <!-- Example for changing the driver args to webdriver tests MINK_DRIVER_ARGS_WEBDRIVER value: '["chrome", { "chromeOptions": { "w3c": false } }, "http://localhost:4444/wd/hub"]' For using the Firefox browser, replace "chrome" with "firefox" -->
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value=""/> <env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless", "--no-sandbox", "--disable-dev-shm-usage"]}}, "http://localhost:9515"]'/>
</php> </php>
<testsuites> <testsuites>
<testsuite name="unit"> <testsuite name="unit">

2
src/IslandoraContextManager.php

@ -37,7 +37,7 @@ class IslandoraContextManager extends ContextManager {
} }
/** @var \Drupal\context\ContextInterface $context */ /** @var \Drupal\context\ContextInterface $context */
foreach ($this->getContexts() as $context) { foreach ($this->getContexts() as $context) {
if ($this->evaluateContextConditions($context, $provided) && !$context->disabled()) { if (!$context->disabled() && $this->evaluateContextConditions($context, $provided)) {
$this->activeContexts[$context->id()] = $context; $this->activeContexts[$context->id()] = $context;
} }
} }

6
src/Plugin/Condition/NodeHasParent.php

@ -137,9 +137,11 @@ class NodeHasParent extends ConditionPluginBase implements ContainerFactoryPlugi
* TRUE if entity references the specified parent. * TRUE if entity references the specified parent.
*/ */
protected function evaluateEntity(EntityInterface $entity) { protected function evaluateEntity(EntityInterface $entity) {
$parent_reference_field = $this->configuration['parent_reference_field'];
foreach ($entity->referencedEntities() as $referenced_entity) { foreach ($entity->referencedEntities() as $referenced_entity) {
if ($entity->getEntityTypeID() == 'node' && $referenced_entity->getEntityTypeId() == 'node') { // Check whether the entity and the referenced entity are nodes.
$parent_reference_field = $this->configuration['parent_reference_field']; // Also make sure that the field exists.
if ($entity->getEntityTypeID() == 'node' && $entity->hasField($parent_reference_field) && $referenced_entity->getEntityTypeId() == 'node') {
$field = $entity->get($parent_reference_field); $field = $entity->get($parent_reference_field);
if (!$field->isEmpty()) { if (!$field->isEmpty()) {
$nids = $field->getValue(); $nids = $field->getValue();

74
src/Plugin/views/filter/NodeHasMediaUse.php

@ -2,8 +2,13 @@
namespace Drupal\islandora\Plugin\views\filter; namespace Drupal\islandora\Plugin\views\filter;
use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\islandora\IslandoraUtils;
use Drupal\views\Plugin\views\filter\FilterPluginBase; use Drupal\views\Plugin\views\filter\FilterPluginBase;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Views Filter on Having Media of a Type. * Views Filter on Having Media of a Type.
@ -14,6 +19,48 @@ use Drupal\views\Plugin\views\filter\FilterPluginBase;
*/ */
class NodeHasMediaUse extends FilterPluginBase { class NodeHasMediaUse extends FilterPluginBase {
/**
* Islandora's utility service.
*
* @var \Drupal\islandora\IslandoraUtils
*/
protected IslandoraUtils $utils;
/**
* Drupal's entity type manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected EntityTypeManagerInterface $entityTypeManager;
/**
* Drupal's database connection service.
*
* @var \Drupal\Core\Database\Connection
*/
protected Connection $connection;
/**
* Logger service.
*
* @var \Psr\Log\LoggerInterface
*/
protected LoggerInterface $logger;
/**
* {@inheritDoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
$instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
$instance->utils = $container->get('islandora.utils');
$instance->entityTypeManager = $container->get('entity_type.manager');
$instance->connection = $container->get('database');
$instance->logger = $container->get('logger.factory')->get('islanodra');
return $instance;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -29,7 +76,7 @@ class NodeHasMediaUse extends FilterPluginBase {
*/ */
public function validateOptionsForm(&$form, FormStateInterface $form_state) { public function validateOptionsForm(&$form, FormStateInterface $form_state) {
$uri = $form_state->getValues()['options']['use_uri']; $uri = $form_state->getValues()['options']['use_uri'];
$term = \Drupal::service('islandora.utils')->getTermForUri($uri); $term = $this->utils->getTermForUri($uri);
if (empty($term)) { if (empty($term)) {
$form_state->setError($form['use_uri'], $this->t('Could not find term with URI: "%uri"', ['%uri' => $uri])); $form_state->setError($form['use_uri'], $this->t('Could not find term with URI: "%uri"', ['%uri' => $uri]));
} }
@ -39,7 +86,7 @@ class NodeHasMediaUse extends FilterPluginBase {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildOptionsForm(&$form, FormStateInterface $form_state) { public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadByProperties(['vid' => 'islandora_media_use']); $terms = $this->entityTypeManager->getStorage('taxonomy_term')->loadByProperties(['vid' => 'islandora_media_use']);
$uris = []; $uris = [];
foreach ($terms as $term) { foreach ($terms as $term) {
foreach ($term->get('field_external_uri')->getValue() as $uri) { foreach ($term->get('field_external_uri')->getValue() as $uri) {
@ -67,7 +114,7 @@ class NodeHasMediaUse extends FilterPluginBase {
*/ */
public function adminSummary() { public function adminSummary() {
$operator = ($this->options['negated']) ? "does not have" : "has"; $operator = ($this->options['negated']) ? "does not have" : "has";
$term = \Drupal::service('islandora.utils')->getTermForUri($this->options['use_uri']); $term = $this->utils->getTermForUri($this->options['use_uri']);
$label = (empty($term)) ? 'BROKEN TERM URI' : $term->label(); $label = (empty($term)) ? 'BROKEN TERM URI' : $term->label();
return "Node {$operator} a '{$label}' media"; return "Node {$operator} a '{$label}' media";
} }
@ -77,18 +124,21 @@ class NodeHasMediaUse extends FilterPluginBase {
*/ */
public function query() { public function query() {
$condition = ($this->options['negated']) ? 'NOT IN' : 'IN'; $condition = ($this->options['negated']) ? 'NOT IN' : 'IN';
$utils = \Drupal::service('islandora.utils'); $term = $this->utils->getTermForUri($this->options['use_uri']);
$term = $utils->getTermForUri($this->options['use_uri']);
if (empty($term)) { if (empty($term)) {
\Drupal::logger('islandora')->warning('Node Has Media Filter could not find term with URI: "%uri"', ['%uri' => $this->options['use_uri']]); $this->logger->warning('Node Has Media Filter could not find term with URI: "%uri"', ['%uri' => $this->options['use_uri']]);
return; return;
} }
$sub_query = \Drupal::database()->select('media', 'm'); $sub_query = $this->connection->select('media', 'm');
$sub_query->join('media__field_media_use', 'use', 'm.mid = use.entity_id'); $use_alias = $sub_query->join('media__field_media_use', 'use', 'm.mid = %alias.entity_id');
$sub_query->join('media__field_media_of', 'of', 'm.mid = of.entity_id'); $of_alias = $sub_query->join('media__field_media_of', 'of', 'm.mid = %alias.entity_id');
$sub_query->fields('of', ['field_media_of_target_id']) $sub_query->fields($of_alias, ['field_media_of_target_id'])
->condition('use.field_media_use_target_id', $term->id()); ->condition("{$use_alias}.field_media_use_target_id", $term->id());
$this->query->addWhere(0, 'nid', $sub_query, $condition);
/** @var \Drupal\views\Plugin\views\query\Sql $query */
$query = $this->query;
$alias = $query->ensureTable('node_field_data', $this->relationship);
$query->addWhere(0, "{$alias}.nid", $sub_query, $condition);
} }
} }

29
src/PresetReaction/PresetReaction.php

@ -7,6 +7,7 @@ use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
@ -21,12 +22,20 @@ class PresetReaction extends ContextReactionPluginBase implements ContainerFacto
*/ */
protected $actionStorage; protected $actionStorage;
/**
* The logger.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityStorageInterface $action_storage) { public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityStorageInterface $action_storage, LoggerInterface $logger) {
parent::__construct($configuration, $plugin_id, $plugin_definition); parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->actionStorage = $action_storage; $this->actionStorage = $action_storage;
$this->logger = $logger;
} }
/** /**
@ -37,7 +46,8 @@ class PresetReaction extends ContextReactionPluginBase implements ContainerFacto
$configuration, $configuration,
$plugin_id, $plugin_id,
$plugin_definition, $plugin_definition,
$container->get('entity_type.manager')->getStorage('action') $container->get('entity_type.manager')->getStorage('action'),
$container->get('logger.factory')->get('islandora')
); );
} }
@ -56,7 +66,20 @@ class PresetReaction extends ContextReactionPluginBase implements ContainerFacto
$action_ids = $config['actions']; $action_ids = $config['actions'];
foreach ($action_ids as $action_id) { foreach ($action_ids as $action_id) {
$action = $this->actionStorage->load($action_id); $action = $this->actionStorage->load($action_id);
$action->execute([$entity]); if (empty($action)) {
$this->logger->warning('Action "@action" not found.', ['@action' => $action_id]);
continue;
}
try {
$action->execute([$entity]);
}
catch (\Exception $e) {
$this->logger->error('Error executing action "@action" on entity "@entity": @message', [
'@action' => $action->label(),
'@entity' => $entity->label(),
'@message' => $e->getMessage(),
]);
}
} }
} }

221
tests/modules/integer_weight_test_views/test_views/views.view.test_integer_weight.yml

@ -4,6 +4,7 @@ dependencies:
config: config:
- node.type.repo_item - node.type.repo_item
module: module:
- islandora
- node - node
- user - user
id: test_integer_weight id: test_integer_weight
@ -13,87 +14,36 @@ description: ''
tag: '' tag: ''
base_table: node_field_data base_table: node_field_data
base_field: nid base_field: nid
core: 8.x
display: display:
default: default:
display_plugin: default
id: default id: default
display_title: Master display_title: Master
display_plugin: default
position: 0 position: 0
display_options: display_options:
access: title: 'test weight'
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
row:
type: fields
fields: fields:
title: title:
id: title id: title
table: node_field_data table: node_field_data
field: title field: title
relationship: none
group_type: group
admin_label: ''
entity_type: node entity_type: node
entity_field: title entity_field: title
plugin_id: field
label: Title
exclude: false
alter: alter:
alter_text: false alter_text: false
make_link: false make_link: false
absolute: false absolute: false
trim: false
word_boundary: false word_boundary: false
ellipsis: false ellipsis: false
strip_tags: false strip_tags: false
trim: false
html: false html: false
hide_empty: false
empty_zero: false
settings:
link_to_entity: true
plugin_id: field
relationship: none
group_type: group
admin_label: ''
label: Title
exclude: false
element_type: '' element_type: ''
element_class: '' element_class: ''
element_label_type: '' element_label_type: ''
@ -103,9 +53,13 @@ display:
element_wrapper_class: '' element_wrapper_class: ''
element_default_classes: true element_default_classes: true
empty: '' empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true hide_alter_empty: true
click_sort_column: value click_sort_column: value
type: string type: string
settings:
link_to_entity: true
group_column: value group_column: value
group_columns: { } group_columns: { }
group_rows: true group_rows: true
@ -123,7 +77,8 @@ display:
relationship: none relationship: none
group_type: group group_type: group
admin_label: '' admin_label: ''
label: 'Integer weight selector (field_integer_weight)' plugin_id: integer_weight_selector
label: 'Integer Weight Selector (field_integer_weight)'
exclude: false exclude: false
alter: alter:
alter_text: false alter_text: false
@ -164,44 +119,57 @@ display:
hide_empty: false hide_empty: false
empty_zero: false empty_zero: false
hide_alter_empty: true hide_alter_empty: true
range: '20' pager:
plugin_id: integer_weight_selector type: mini
filters: options:
status: offset: 0
value: '1' items_per_page: 10
table: node_field_data total_pages: null
field: status id: 0
plugin_id: boolean tags:
entity_type: node next: ››
entity_field: status previous: ‹‹
id: status
expose: expose:
operator: '' items_per_page: false
group: 1 items_per_page_label: 'Items per page'
type: items_per_page_options: '5, 10, 25, 50'
id: type items_per_page_options_all: false
table: node_field_data items_per_page_options_all_label: '- All -'
field: type offset: false
value: offset_label: Offset
repo_item:repo_item exposed_form:
entity_type: node type: basic
entity_field: type options:
plugin_id: bundle 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
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
empty: { }
sorts: sorts:
created: created:
id: created id: created
table: node_field_data table: node_field_data
field: created field: created
order: DESC
entity_type: node
entity_field: created
plugin_id: date
relationship: none relationship: none
group_type: group group_type: group
admin_label: '' admin_label: ''
exposed: false entity_type: node
entity_field: created
plugin_id: date
order: DESC
expose: expose:
label: '' label: ''
exposed: false
granularity: second granularity: second
field_integer_weight_value: field_integer_weight_value:
id: field_integer_weight_value id: field_integer_weight_value
@ -210,17 +178,82 @@ display:
relationship: none relationship: none
group_type: group group_type: group
admin_label: '' admin_label: ''
plugin_id: standard
order: ASC order: ASC
expose:
label: ''
field_identifier: ''
exposed: false
arguments: { }
filters:
status:
id: status
table: node_field_data
field: status
entity_type: node
entity_field: status
plugin_id: boolean
value: '1'
group: 1
expose:
operator: ''
type:
id: type
table: node_field_data
field: type
relationship: none
group_type: group
admin_label: ''
entity_type: node
entity_field: type
plugin_id: bundle
operator: in
value:
repo_item: repo_item
group: 1
exposed: false exposed: false
expose: expose:
operator_id: ''
label: '' label: ''
plugin_id: standard description: ''
title: 'test weight' use_operator: false
operator: ''
operator_limit_selection: false
operator_list: { }
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: { }
style:
type: table
row:
type: fields
query:
type: views_query
options:
query_comment: ''
disable_sql_rewrite: false
distinct: false
replica: false
query_tags: { }
relationships: { }
header: { } header: { }
footer: { } footer: { }
empty: { }
relationships: { }
arguments: { }
display_extenders: { } display_extenders: { }
cache_metadata: cache_metadata:
max-age: -1 max-age: -1
@ -232,9 +265,9 @@ display:
- user.permissions - user.permissions
tags: { } tags: { }
page_1: page_1:
display_plugin: page
id: page_1 id: page_1
display_title: Page display_title: Page
display_plugin: page
position: 1 position: 1
display_options: display_options:
display_extenders: { } display_extenders: { }

4
tests/src/Functional/ContentEntityTypeTest.php

@ -39,7 +39,7 @@ class ContentEntityTypeTest extends IslandoraFunctionalTestBase {
$this->addCondition('test', 'content_entity_type'); $this->addCondition('test', 'content_entity_type');
$this->getSession()->getPage()->checkField("edit-conditions-content-entity-type-types-node"); $this->getSession()->getPage()->checkField("edit-conditions-content-entity-type-types-node");
$this->getSession()->getPage()->findById("edit-conditions-content-entity-type-context-mapping-node")->selectOption("@node.node_route_context:node"); $this->getSession()->getPage()->findById("edit-conditions-content-entity-type-context-mapping-node")->selectOption("@node.node_route_context:node");
$this->getSession()->getPage()->pressButton($this->t('Save and continue')); $this->getSession()->getPage()->pressButton('Save and continue');
$this->addPresetReaction('test', 'index', 'hello_world'); $this->addPresetReaction('test', 'index', 'hello_world');
// Create a new node confirm Hello World! is printed to the screen. // Create a new node confirm Hello World! is printed to the screen.
@ -53,7 +53,7 @@ class ContentEntityTypeTest extends IslandoraFunctionalTestBase {
'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file.txt', 'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file.txt',
]; ];
$this->drupalGet('media/add/' . $this->testMediaType->id()); $this->drupalGet('media/add/' . $this->testMediaType->id());
$this->submitForm($values, $this->t('Save')); $this->submitForm($values, 'Save');
$this->assertSession()->pageTextNotContains("Hello World!"); $this->assertSession()->pageTextNotContains("Hello World!");
} }

6
tests/src/Functional/DerivativeReactionTest.php

@ -53,7 +53,7 @@ class DerivativeReactionTest extends IslandoraFunctionalTestBase {
'field_media_of[0][target_id]' => 'Test Node', 'field_media_of[0][target_id]' => 'Test Node',
]; ];
$this->drupalGet('media/add/' . $this->testMediaType->id()); $this->drupalGet('media/add/' . $this->testMediaType->id());
$this->submitForm($values, $this->t('Save')); $this->submitForm($values, 'Save');
// field_media_of is set and there's a file, so derivatives should fire. // field_media_of is set and there's a file, so derivatives should fire.
$this->assertSession()->pageTextContains("Hello World!"); $this->assertSession()->pageTextContains("Hello World!");
@ -71,9 +71,9 @@ class DerivativeReactionTest extends IslandoraFunctionalTestBase {
'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file2.txt', 'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file2.txt',
]; ];
$this->drupalGet($media_url . '/edit'); $this->drupalGet($media_url . '/edit');
$this->getSession()->getPage()->pressButton($this->t('Remove')); $this->getSession()->getPage()->pressButton('Remove');
$this->getSession()->getPage()->fillField('files[field_media_file_0]', __DIR__ . '/../../fixtures/test_file2.txt'); $this->getSession()->getPage()->fillField('files[field_media_file_0]', __DIR__ . '/../../fixtures/test_file2.txt');
$this->getSession()->getPage()->pressButton($this->t('Save')); $this->getSession()->getPage()->pressButton('Save');
$this->assertSession()->pageTextContains("Hello World!"); $this->assertSession()->pageTextContains("Hello World!");
} }

6
tests/src/Functional/EmitNodeEventTest.php

@ -44,7 +44,7 @@ class EmitNodeEventTest extends IslandoraFunctionalTestBase {
$this->addCondition('test', 'content_entity_type'); $this->addCondition('test', 'content_entity_type');
$this->getSession()->getPage()->checkField("edit-conditions-content-entity-type-types-node"); $this->getSession()->getPage()->checkField("edit-conditions-content-entity-type-types-node");
$this->getSession()->getPage()->findById("edit-conditions-content-entity-type-context-mapping-node")->selectOption("@node.node_route_context:node"); $this->getSession()->getPage()->findById("edit-conditions-content-entity-type-context-mapping-node")->selectOption("@node.node_route_context:node");
$this->getSession()->getPage()->pressButton($this->t('Save and continue')); $this->getSession()->getPage()->pressButton('Save and continue');
$this->addPresetReaction('test', 'index', $action_id); $this->addPresetReaction('test', 'index', $action_id);
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
@ -68,7 +68,7 @@ class EmitNodeEventTest extends IslandoraFunctionalTestBase {
protected function createEmitAction($entity_type, $event_type) { protected function createEmitAction($entity_type, $event_type) {
$this->drupalGet('admin/config/system/actions'); $this->drupalGet('admin/config/system/actions');
$this->getSession()->getPage()->findById("edit-action")->selectOption("Emit a $entity_type event to a queue/topic"); $this->getSession()->getPage()->findById("edit-action")->selectOption("Emit a $entity_type event to a queue/topic");
$this->getSession()->getPage()->pressButton($this->t('Create')); $this->getSession()->getPage()->pressButton('Create');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
$action_id = "emit_" . $entity_type . "_" . lcfirst($event_type); $action_id = "emit_" . $entity_type . "_" . lcfirst($event_type);
@ -76,7 +76,7 @@ class EmitNodeEventTest extends IslandoraFunctionalTestBase {
$this->getSession()->getPage()->fillField('edit-id', $action_id); $this->getSession()->getPage()->fillField('edit-id', $action_id);
$this->getSession()->getPage()->fillField('edit-queue', "emit-$entity_type-" . lcfirst($event_type)); $this->getSession()->getPage()->fillField('edit-queue', "emit-$entity_type-" . lcfirst($event_type));
$this->getSession()->getPage()->findById("edit-event")->selectOption($event_type); $this->getSession()->getPage()->findById("edit-event")->selectOption($event_type);
$this->getSession()->getPage()->pressButton($this->t('Save')); $this->getSession()->getPage()->pressButton('Save');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
return $action_id; return $action_id;

2
tests/src/Functional/EntityBundleTest.php

@ -27,7 +27,7 @@ class EntityBundleTest extends IslandoraFunctionalTestBase {
$this->addCondition('test', 'islandora_entity_bundle'); $this->addCondition('test', 'islandora_entity_bundle');
$this->getSession()->getPage()->checkField("edit-conditions-islandora-entity-bundle-bundles-test-type"); $this->getSession()->getPage()->checkField("edit-conditions-islandora-entity-bundle-bundles-test-type");
$this->getSession()->getPage()->findById("edit-conditions-islandora-entity-bundle-context-mapping-node")->selectOption("@node.node_route_context:node"); $this->getSession()->getPage()->findById("edit-conditions-islandora-entity-bundle-context-mapping-node")->selectOption("@node.node_route_context:node");
$this->getSession()->getPage()->pressButton($this->t('Save and continue')); $this->getSession()->getPage()->pressButton('Save and continue');
$this->addPresetReaction('test', 'index', 'hello_world'); $this->addPresetReaction('test', 'index', 'hello_world');
// Create a new test_type confirm Hello World! is printed to the screen. // Create a new test_type confirm Hello World! is printed to the screen.

2
tests/src/Functional/FormDisplayAlterReactionTest.php

@ -49,7 +49,7 @@ class FormDisplayAlterReactionTest extends IslandoraFunctionalTestBase {
$this->drupalGet("admin/structure/context/test/reaction/add/form_display_alter"); $this->drupalGet("admin/structure/context/test/reaction/add/form_display_alter");
$this->getSession()->getPage()->findById("edit-reactions-form-display-alter-mode")->selectOption('node.secondary'); $this->getSession()->getPage()->findById("edit-reactions-form-display-alter-mode")->selectOption('node.secondary');
$this->getSession()->getPage()->pressButton($this->t('Save and continue')); $this->getSession()->getPage()->pressButton('Save and continue');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
drupal_flush_all_caches(); drupal_flush_all_caches();

2
tests/src/Functional/IndexingTest.php

@ -66,7 +66,7 @@ class IndexingTest extends IslandoraFunctionalTestBase {
$this->drupalGet("$url/delete"); $this->drupalGet("$url/delete");
// Delete the node. // Delete the node.
$this->submitForm([], $this->t('Delete')); $this->submitForm([], 'Delete');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
// Confirm Goodbye, Cruel World! is printed to the screen. // Confirm Goodbye, Cruel World! is printed to the screen.

8
tests/src/Functional/IslandoraFunctionalTestBase.php

@ -306,7 +306,7 @@ EOD;
->getPage() ->getPage()
->findById("edit-reactions-$reaction_type-actions") ->findById("edit-reactions-$reaction_type-actions")
->selectOption($action_id); ->selectOption($action_id);
$this->getSession()->getPage()->pressButton($this->t('Save and continue')); $this->getSession()->getPage()->pressButton('Save and continue');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
} }
@ -315,7 +315,7 @@ EOD;
*/ */
protected function postNodeAddForm($bundle_id, $values, $button_text) { protected function postNodeAddForm($bundle_id, $values, $button_text) {
$this->drupalGet("node/add/$bundle_id"); $this->drupalGet("node/add/$bundle_id");
$this->submitForm($values, $this->t('@text', ['@text' => $button_text])); $this->submitForm($values, $button_text);
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
} }
@ -324,7 +324,7 @@ EOD;
*/ */
protected function postTermAddForm($taxomony_id, $values, $button_text) { protected function postTermAddForm($taxomony_id, $values, $button_text) {
$this->drupalGet("admin/structure/taxonomy/manage/$taxomony_id/add"); $this->drupalGet("admin/structure/taxonomy/manage/$taxomony_id/add");
$this->submitForm($values, $this->t('@text', ['@text' => $button_text])); $this->submitForm($values, $button_text);
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
} }
@ -333,7 +333,7 @@ EOD;
*/ */
protected function postEntityEditForm($entity_url, $values, $button_text) { protected function postEntityEditForm($entity_url, $values, $button_text) {
$this->drupalGet("$entity_url/edit"); $this->drupalGet("$entity_url/edit");
$this->submitForm($values, $this->t('@text', ['@text' => $button_text])); $this->submitForm($values, $button_text);
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
} }

10
tests/src/Functional/IslandoraSettingsFormTest.php

@ -38,23 +38,23 @@ class IslandoraSettingsFormTest extends IslandoraFunctionalTestBase {
$this->assertSession()->fieldValueEquals('edit-jwt-expiry', '+2 hour'); $this->assertSession()->fieldValueEquals('edit-jwt-expiry', '+2 hour');
$this->drupalGet('/admin/config/islandora/core'); $this->drupalGet('/admin/config/islandora/core');
// Blank is not allowed. // Blank is not allowed.
$this->submitForm(['edit-jwt-expiry' => ""], $this->t('Save configuration')); $this->submitForm(['edit-jwt-expiry' => ""], 'Save configuration');
$this->assertSession()->pageTextContainsOnce('"" is not a valid time or interval expression.'); $this->assertSession()->pageTextContainsOnce('"" is not a valid time or interval expression.');
$this->drupalGet('/admin/config/islandora/core'); $this->drupalGet('/admin/config/islandora/core');
// Negative is not allowed. // Negative is not allowed.
$this->submitForm(['edit-jwt-expiry' => "-2 hours"], $this->t('Save configuration')); $this->submitForm(['edit-jwt-expiry' => "-2 hours"], 'Save configuration');
$this->assertSession()->pageTextContainsOnce('Time or interval expression cannot be negative'); $this->assertSession()->pageTextContainsOnce('Time or interval expression cannot be negative');
$this->drupalGet('/admin/config/islandora/core'); $this->drupalGet('/admin/config/islandora/core');
// Must include an integer value. // Must include an integer value.
$this->submitForm(['edit-jwt-expiry' => "last hour"], $this->t('Save configuration')); $this->submitForm(['edit-jwt-expiry' => "last hour"], 'Save configuration');
$this->assertSession()->pageTextContainsOnce('No numeric interval specified, for example "1 day"'); $this->assertSession()->pageTextContainsOnce('No numeric interval specified, for example "1 day"');
$this->drupalGet('/admin/config/islandora/core'); $this->drupalGet('/admin/config/islandora/core');
// Must have an accepted interval. // Must have an accepted interval.
$this->submitForm(['edit-jwt-expiry' => "1 fortnight"], $this->t('Save configuration')); $this->submitForm(['edit-jwt-expiry' => "1 fortnight"], 'Save configuration');
$this->assertSession()->pageTextContainsOnce('No time interval found, please include one of'); $this->assertSession()->pageTextContainsOnce('No time interval found, please include one of');
$this->drupalGet('/admin/config/islandora/core'); $this->drupalGet('/admin/config/islandora/core');
// Test a valid setting. // Test a valid setting.
$this->submitForm(['edit-jwt-expiry' => "2 weeks"], $this->t('Save configuration')); $this->submitForm(['edit-jwt-expiry' => "2 weeks"], 'Save configuration');
$this->assertSession()->pageTextContainsOnce('The configuration options have been saved.'); $this->assertSession()->pageTextContainsOnce('The configuration options have been saved.');
} }

2
tests/src/Functional/JsonldSelfReferenceReactionTest.php

@ -60,7 +60,7 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase {
$this->postNodeAddForm('test_type', $this->postNodeAddForm('test_type',
['title[0][value]' => 'Test Node'], ['title[0][value]' => 'Test Node'],
$this->t('Save')); 'Save');
$this->assertSession()->pageTextContains("Test Node"); $this->assertSession()->pageTextContains("Test Node");
$url = $this->getUrl(); $url = $this->getUrl();

38
tests/src/Functional/JsonldTypeAlterReactionTest.php

@ -32,13 +32,13 @@ class JsonldTypeAlterReactionTest extends JsonldSelfReferenceReactionTest {
'label' => 'Typed Predicate', 'label' => 'Typed Predicate',
'field_name' => 'type_predicate', 'field_name' => 'type_predicate',
], 'Save and continue'); ], 'Save and continue');
$this->submitForm([], $this->t('Save field settings')); $this->submitForm([], 'Save field settings');
} }
else { elseif (version_compare(\Drupal::VERSION, '10.3.x-dev', 'lt')) {
$this->getSession()->getPage()->selectFieldOption('new_storage_type', 'plain_text'); $this->getSession()->getPage()->selectFieldOption('new_storage_type', 'plain_text');
// First need to submit the form with the elements displayed // For Drupal 10.2, we first need to submit the form with the elements
// on initial page load. The form is using AJAX to send a second element // displayed on initial page load. The form is using AJAX to send a
// after we selected the radio button above // second element after we selected the radio button above
// we can instead get the second element by submitting the form // we can instead get the second element by submitting the form
// and having it throw an error since the required field is missing. // and having it throw an error since the required field is missing.
// @todo refactor this as a functional javascript test. // @todo refactor this as a functional javascript test.
@ -46,7 +46,7 @@ class JsonldTypeAlterReactionTest extends JsonldSelfReferenceReactionTest {
'new_storage_type' => 'plain_text', 'new_storage_type' => 'plain_text',
'label' => 'Typed Predicate', 'label' => 'Typed Predicate',
'field_name' => 'type_predicate', 'field_name' => 'type_predicate',
], $this->t('Continue')); ], 'Continue');
// Now we can proceed, selecting the plain text (i.e. string) // Now we can proceed, selecting the plain text (i.e. string)
// for the second element now that the element is displayed after // for the second element now that the element is displayed after
@ -57,16 +57,34 @@ class JsonldTypeAlterReactionTest extends JsonldSelfReferenceReactionTest {
'label' => 'Typed Predicate', 'label' => 'Typed Predicate',
'field_name' => 'type_predicate', 'field_name' => 'type_predicate',
'group_field_options_wrapper' => 'string', 'group_field_options_wrapper' => 'string',
], $this->t('Continue')); ], 'Continue');
}
else {
$this->getSession()->getPage()->selectFieldOption('new_storage_type', 'plain_text');
// For Drupal 10.3 the label is not visible at first.
// @todo refactor this as a functional javascript test.
$this->submitForm([
'new_storage_type' => 'plain_text',
], 'Continue');
// Now we can proceed, entering a label and selecting Text (plain)
// for the second element now that the elements are displayed after
// the initial form submission.
$this->getSession()->getPage()->selectFieldOption('group_field_options_wrapper', 'string');
$this->submitForm([
'label' => 'Typed Predicate',
'field_name' => 'type_predicate',
'group_field_options_wrapper' => 'string',
], 'Continue');
} }
$this->submitForm([], $this->t('Save settings')); $this->submitForm([], 'Save settings');
$this->assertSession()->responseContains('field_type_predicate'); $this->assertSession()->responseContains('field_type_predicate');
// Add the test node. // Add the test node.
$this->postNodeAddForm('test_type', [ $this->postNodeAddForm('test_type', [
'title[0][value]' => 'Test Node', 'title[0][value]' => 'Test Node',
'field_type_predicate[0][value]' => 'schema:Organization', 'field_type_predicate[0][value]' => 'schema:Organization',
], $this->t('Save')); ], 'Save');
$this->assertSession()->pageTextContains("Test Node"); $this->assertSession()->pageTextContains("Test Node");
$url = $this->getUrl(); $url = $this->getUrl();
@ -103,7 +121,7 @@ class JsonldTypeAlterReactionTest extends JsonldSelfReferenceReactionTest {
$this->addCondition('test', 'islandora_entity_bundle'); $this->addCondition('test', 'islandora_entity_bundle');
$this->getSession()->getPage()->checkField("edit-conditions-islandora-entity-bundle-bundles-test-type"); $this->getSession()->getPage()->checkField("edit-conditions-islandora-entity-bundle-bundles-test-type");
$this->getSession()->getPage()->findById("edit-conditions-islandora-entity-bundle-context-mapping-node")->selectOption("@node.node_route_context:node"); $this->getSession()->getPage()->findById("edit-conditions-islandora-entity-bundle-context-mapping-node")->selectOption("@node.node_route_context:node");
$this->getSession()->getPage()->pressButton($this->t('Save and continue')); $this->getSession()->getPage()->pressButton('Save and continue');
// The first time a Context is saved, you need to clear the cache. // The first time a Context is saved, you need to clear the cache.
// Subsequent changes to the context don't need a cache rebuild, though. // Subsequent changes to the context don't need a cache rebuild, though.

4
tests/src/Functional/LinkHeaderTest.php

@ -142,7 +142,7 @@ class LinkHeaderTest extends IslandoraFunctionalTestBase {
$media_url = $this->media->toUrl('canonical', ['absolute' => TRUE])->toString(); $media_url = $this->media->toUrl('canonical', ['absolute' => TRUE])->toString();
// Perform a GET request as anonymous. // Perform a GET request as anonymous.
$this->drupalGet($media_url, [], ['Cache-Control: no-cache']); $this->drupalGet($media_url, [], ['Cache-Control' => 'no-cache']);
// Check link headers. // Check link headers.
$this->assertTrue( $this->assertTrue(
$this->validateLinkHeaderWithUrl('describes', $file_url, '', 'text/plain') == 1, $this->validateLinkHeaderWithUrl('describes', $file_url, '', 'text/plain') == 1,
@ -174,7 +174,7 @@ class LinkHeaderTest extends IslandoraFunctionalTestBase {
$this->drupalLogin($account); $this->drupalLogin($account);
// Perform a GET request with update media permissions. // Perform a GET request with update media permissions.
$this->drupalGet($media_url, [], ['Cache-Control: no-cache']); $this->drupalGet($media_url, [], ['Cache-Control' => 'no-cache']);
// Check link headers again, the edit-media link header should be present. // Check link headers again, the edit-media link header should be present.
$this->assertTrue( $this->assertTrue(

2
tests/src/Functional/ViewModeAlterReactionTest.php

@ -75,7 +75,7 @@ class ViewModeAlterReactionTest extends IslandoraFunctionalTestBase {
$this->drupalGet("admin/structure/context/test/reaction/add/view_mode_alter"); $this->drupalGet("admin/structure/context/test/reaction/add/view_mode_alter");
$this->getSession()->getPage()->findById("edit-reactions-view-mode-alter-mode")->selectOption('node.teaser'); $this->getSession()->getPage()->findById("edit-reactions-view-mode-alter-mode")->selectOption('node.teaser');
$this->getSession()->getPage()->pressButton($this->t('Save and continue')); $this->getSession()->getPage()->pressButton('Save and continue');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
drupal_flush_all_caches(); drupal_flush_all_caches();

39
tests/src/FunctionalJavascript/IntegerWeightTest.php

@ -8,6 +8,7 @@ use Drupal\Tests\field_ui\Traits\FieldUiTestTrait;
use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldConfig;
use Drupal\node\Entity\Node; use Drupal\node\Entity\Node;
use Drupal\views\Tests\ViewTestData;
/** /**
* Test integer weight selector. * Test integer weight selector.
@ -30,6 +31,7 @@ class IntegerWeightTest extends WebDriverTestBase {
'views', 'views',
'field_ui', 'field_ui',
'integer_weight_test_views', 'integer_weight_test_views',
'islandora',
]; ];
/** /**
@ -82,27 +84,16 @@ class IntegerWeightTest extends WebDriverTestBase {
*/ */
public function setUp(): void { public function setUp(): void {
parent::setUp(); parent::setUp();
$this->drupalCreateContentType([
'type' => 'repo_item',
'name' => 'Repository Item',
]);
$this->adminUser = $this->drupalCreateUser( $account = $this->createUser(['edit any repo_item content'], 'test', TRUE);
[ $this->drupalLogin($account);
'administer content types',
'administer node fields',
'administer node display',
]
);
// Create dummy repo_item type to sort (since we don't have
// repository_object without islandora_defaults).
$type = $this->container->get('entity_type.manager')->getStorage('node_type')
->create([
'type' => 'repo_item',
'name' => 'Repository Item',
]);
$type->save();
$this->container->get('router.builder')->rebuild();
$fieldStorage = FieldStorageConfig::create([ $fieldStorage = FieldStorageConfig::create([
'fieldName' => static::$fieldName, 'field_name' => static::$fieldName,
'entity_type' => 'node', 'entity_type' => 'node',
'type' => static::$fieldType, 'type' => static::$fieldType,
]); ]);
@ -124,16 +115,18 @@ class IntegerWeightTest extends WebDriverTestBase {
$this->nodes[] = $node; $this->nodes[] = $node;
} }
ViewsTestData::createTestViews(get_class($this), ['integer_weight_test_views']); ViewTestData::createTestViews(get_class($this), ['integer_weight_test_views']);
} }
/** /**
* Test integer weight selector. * Test integer weight selector.
*/ */
public function testIntegerWeightSelector() { public function testIntegerWeightSelector() {
$this->drupalGet('test-integer-weight'); $web_assert = $this->assertSession();
$page = $this->getSession()->getPage(); $this->drupalGet('/test-integer-weight');
$web_assert->pageTextContains('Item 1');
$page = $this->getSession()->getPage();
$weight_select1 = $page->findField("field_integer_weight[0][weight]"); $weight_select1 = $page->findField("field_integer_weight[0][weight]");
$weight_select2 = $page->findField("field_integer_weight[1][weight]"); $weight_select2 = $page->findField("field_integer_weight[1][weight]");
$weight_select3 = $page->findField("field_integer_weight[2][weight]"); $weight_select3 = $page->findField("field_integer_weight[2][weight]");
@ -153,8 +146,8 @@ class IntegerWeightTest extends WebDriverTestBase {
$this->assertSession()->pageTextNotContains('You have unsaved changes.'); $this->assertSession()->pageTextNotContains('You have unsaved changes.');
// Drag and drop 'Item 1' over 'Item 2'. // Drag and drop 'Item 1' over 'Item 2'.
$dragged = $this->xpath("//tr[@class='draggable'][1]//a[@class='tabledrag-handle']")[0]; $dragged = $this->xpath("//tr[contains(@class, 'draggable')][1]//a[contains(@class, 'tabledrag-handle')]")[0];
$target = $this->xpath("//tr[@class='draggable'][2]//a[@class='tabledrag-handle']")[0]; $target = $this->xpath("//tr[contains(@class, 'draggable')][2]//a[contains(@class, 'tabledrag-handle')]")[0];
$dragged->dragTo($target); $dragged->dragTo($target);
// Pause for javascript to do it's thing. // Pause for javascript to do it's thing.

Loading…
Cancel
Save