Browse Source

Merge pull request #943 from rosiel/drupal10

Apply Drupal Rector to Islandora.
pull/955/head
Alexander O'Neill 1 year ago committed by GitHub
parent
commit
c41f574268
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .github/workflows/build-2.x.yml
  2. 2
      modules/islandora_advanced_search/islandora_advanced_search.module
  3. 3
      modules/islandora_audio/tests/src/Functional/GenerateAudioDerivativeTest.php
  4. 4
      modules/islandora_breadcrumbs/tests/src/Functional/BreadcrumbsTest.php
  5. 1
      modules/islandora_core_feature/config/install/views.view.all_taxonomy_terms.yml
  6. 1
      modules/islandora_core_feature/config/install/views.view.file_checksum.yml
  7. 1
      modules/islandora_core_feature/config/install/views.view.non_fedora_files.yml
  8. 3
      modules/islandora_image/tests/src/Functional/GenerateImageDerivativeTest.php
  9. 18
      modules/islandora_text_extraction/src/Controller/MediaSourceController.php
  10. 4
      modules/islandora_text_extraction/tests/src/Functional/LoadTest.php
  11. 3
      modules/islandora_video/tests/src/Functional/GenerateVideoDerivativeTest.php
  12. 6
      src/EventSubscriber/LinkHeaderSubscriber.php
  13. 4
      src/EventSubscriber/MediaLinkHeaderSubscriber.php
  14. 6
      src/EventSubscriber/NodeLinkHeaderSubscriber.php
  15. 14
      src/Flysystem/Adapter/FedoraAdapter.php
  16. 2
      tests/src/Functional/AddChildTest.php
  17. 2
      tests/src/Functional/AddMediaToNodeTest.php
  18. 3
      tests/src/Functional/ContentEntityTypeTest.php
  19. 4
      tests/src/Functional/DeleteMediaTest.php
  20. 5
      tests/src/Functional/DerivativeReactionTest.php
  21. 2
      tests/src/Functional/GenerateDerivativeTestBase.php
  22. 5
      tests/src/Functional/IndexingTest.php
  23. 11
      tests/src/Functional/IslandoraFunctionalTestBase.php
  24. 2
      tests/src/Functional/IslandoraImageFormatterTest.php
  25. 17
      tests/src/Functional/IslandoraSettingsFormTest.php
  26. 14
      tests/src/Functional/JsonldSelfReferenceReactionTest.php
  27. 15
      tests/src/Functional/JsonldTypeAlterReactionTest.php
  28. 2
      tests/src/Functional/LinkHeaderTest.php
  29. 2
      tests/src/Functional/MediaSourceUpdateTest.php
  30. 2
      tests/src/Functional/NodeHasTermTest.php
  31. 2
      tests/src/Functional/ViewModeAlterReactionTest.php
  32. 2
      tests/src/FunctionalJavascript/IntegerWeightTest.php
  33. 2
      tests/src/Kernel/EventGeneratorTest.php
  34. 12
      tests/src/Kernel/FedoraAdapterTest.php
  35. 4
      tests/src/Kernel/IslandoraKernelTestBase.php
  36. 4
      tests/src/Kernel/JwtEventSubscriberTest.php

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

@ -123,4 +123,3 @@ jobs:
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 }}"

2
modules/islandora_advanced_search/islandora_advanced_search.module

@ -48,7 +48,7 @@ function islandora_advanced_search_theme() {
function islandora_advanced_search_library_info_alter(&$libraries, $extension) { function islandora_advanced_search_library_info_alter(&$libraries, $extension) {
if ($extension == 'facets') { if ($extension == 'facets') {
// Override facets module javascript with customizations. // Override facets module javascript with customizations.
$path = '/' . drupal_get_path('module', 'islandora_advanced_search') . '/js/facets'; $path = '/' . \Drupal::service('extension.list.module')->getPath('islandora_advanced_search') . '/js/facets';
$libraries['soft-limit']['js'] = [ $libraries['soft-limit']['js'] = [
"$path/soft-limit.js" => [], "$path/soft-limit.js" => [],
]; ];

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

@ -68,7 +68,8 @@ class GenerateAudioDerivativeTest extends GenerateDerivativeTestBase {
'field_media_of[0][target_id]' => 'Test Node', 'field_media_of[0][target_id]' => 'Test Node',
'field_tags[0][target_id]' => 'Preservation Master', 'field_tags[0][target_id]' => 'Preservation Master',
]; ];
$this->drupalPostForm('media/add/' . $this->testMediaType->id(), $values, $this->t('Save')); $this->drupalGet('media/add/' . $this->testMediaType->id());
$this->submitForm($values, $this->t('Save'));
$expected = [ $expected = [
'source_uri' => 'test_file.txt', 'source_uri' => 'test_file.txt',

4
modules/islandora_breadcrumbs/tests/src/Functional/BreadcrumbsTest.php

@ -20,7 +20,7 @@ class BreadcrumbsTest extends IslandoraFunctionalTestBase {
* *
* @var array * @var array
*/ */
public static $modules = [ protected static $modules = [
'islandora_breadcrumbs', 'islandora_breadcrumbs',
]; ];
@ -56,7 +56,7 @@ class BreadcrumbsTest extends IslandoraFunctionalTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
// Create some nodes. // Create some nodes.

1
modules/islandora_core_feature/config/install/views.view.all_taxonomy_terms.yml

@ -168,4 +168,3 @@ display:
- url.query_args - url.query_args
- user.permissions - user.permissions
tags: { } tags: { }

1
modules/islandora_core_feature/config/install/views.view.file_checksum.yml

@ -304,4 +304,3 @@ display:
- url - url
- user.permissions - user.permissions
tags: { } tags: { }

1
modules/islandora_core_feature/config/install/views.view.non_fedora_files.yml

@ -194,4 +194,3 @@ display:
- url.query_args - url.query_args
- user.permissions - user.permissions
tags: { } tags: { }

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

@ -70,7 +70,8 @@ class GenerateImageDerivativeTest extends GenerateDerivativeTestBase {
'field_media_of[0][target_id]' => 'Test Node', 'field_media_of[0][target_id]' => 'Test Node',
'field_tags[0][target_id]' => 'Preservation Master', 'field_tags[0][target_id]' => 'Preservation Master',
]; ];
$this->drupalPostForm('media/add/' . $this->testMediaType->id(), $values, $this->t('Save')); $this->drupalGet('media/add/' . $this->testMediaType->id());
$this->submitForm($values, $this->t('Save'));
$expected = [ $expected = [
'source_uri' => 'test_file.txt', 'source_uri' => 'test_file.txt',

18
modules/islandora_text_extraction/src/Controller/MediaSourceController.php

@ -5,6 +5,7 @@ namespace Drupal\islandora_text_extraction\Controller;
use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\File\FileSystem; use Drupal\Core\File\FileSystem;
use Drupal\Core\File\FileSystemInterface; use Drupal\Core\File\FileSystemInterface;
use Drupal\file\FileRepository;
use Drupal\media\Entity\Media; use Drupal\media\Entity\Media;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -42,14 +43,24 @@ class MediaSourceController extends ControllerBase {
*/ */
protected $fileSystem; protected $fileSystem;
/**
* File repository service.
*
* @var \Drupal\file\FileRepository
*/
protected $fileRepository;
/** /**
* MediaSourceController constructor. * MediaSourceController constructor.
* *
* @param \Drupal\Core\File\FileSystem $fileSystem * @param \Drupal\Core\File\FileSystem $fileSystem
* Filesystem service. * Filesystem service.
* @param \Drupal\file\FileRepository $fileRepository
* File Repository service.
*/ */
public function __construct(FileSystem $fileSystem) { public function __construct(FileSystem $fileSystem, FileRepository $fileRepository) {
$this->fileSystem = $fileSystem; $this->fileSystem = $fileSystem;
$this->fileRepository = $fileRepository;
} }
/** /**
@ -63,7 +74,8 @@ class MediaSourceController extends ControllerBase {
*/ */
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('file_system') $container->get('file_system'),
$container->get('file.repository'),
); );
} }
@ -98,7 +110,7 @@ class MediaSourceController extends ControllerBase {
if (!$this->fileSystem->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) { if (!$this->fileSystem->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) {
throw new HttpException(500, "The destination directory does not exist, could not be created, or is not writable"); throw new HttpException(500, "The destination directory does not exist, could not be created, or is not writable");
} }
$file = file_save_data($contents, $content_location, FileSystemInterface::EXISTS_REPLACE); $file = $this->fileRepository->writeData($contents, $content_location, FileSystemInterface::EXISTS_REPLACE);
if ($media->hasField($destination_field)) { if ($media->hasField($destination_field)) {
$media->{$destination_field}->setValue([ $media->{$destination_field}->setValue([
'target_id' => $file->id(), 'target_id' => $file->id(),

4
modules/islandora_text_extraction/tests/src/Functional/LoadTest.php

@ -17,7 +17,7 @@ class LoadTest extends IslandoraFunctionalTestBase {
* *
* @var array * @var array
*/ */
public static $modules = ['islandora_text_extraction']; protected static $modules = ['islandora_text_extraction'];
/** /**
* A user with permission to administer site configuration. * A user with permission to administer site configuration.
@ -29,7 +29,7 @@ class LoadTest extends IslandoraFunctionalTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
$this->user = $this->drupalCreateUser(['administer site configuration']); $this->user = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($this->user); $this->drupalLogin($this->user);

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

@ -65,7 +65,8 @@ class GenerateVideoDerivativeTest extends GenerateDerivativeTestBase {
'field_media_of[0][target_id]' => 'Test Node', 'field_media_of[0][target_id]' => 'Test Node',
'field_tags[0][target_id]' => 'Preservation Master', 'field_tags[0][target_id]' => 'Preservation Master',
]; ];
$this->drupalPostForm('media/add/' . $this->testMediaType->id(), $values, $this->t('Save')); $this->drupalGet('media/add/' . $this->testMediaType->id());
$this->submitForm($values, $this->t('Save'));
$expected = [ $expected = [
'source_uri' => 'test_file.txt', 'source_uri' => 'test_file.txt',

6
src/EventSubscriber/LinkHeaderSubscriber.php

@ -2,6 +2,7 @@
namespace Drupal\islandora\EventSubscriber; namespace Drupal\islandora\EventSubscriber;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Drupal\Core\Access\AccessManagerInterface; use Drupal\Core\Access\AccessManagerInterface;
use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
@ -13,7 +14,6 @@ use Drupal\Core\Entity\Exception\UndefinedLinkTemplateException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\KernelEvents;
/** /**
@ -312,9 +312,9 @@ abstract class LinkHeaderSubscriber implements EventSubscriberInterface {
/** /**
* Adds resource-specific link headers to appropriate responses. * Adds resource-specific link headers to appropriate responses.
* *
* @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event * @param \Symfony\Component\HttpKernel\Event\ResponseEvent $event
* Event containing the response. * Event containing the response.
*/ */
abstract public function onResponse(FilterResponseEvent $event); abstract public function onResponse(ResponseEvent $event);
} }

4
src/EventSubscriber/MediaLinkHeaderSubscriber.php

@ -2,10 +2,10 @@
namespace Drupal\islandora\EventSubscriber; namespace Drupal\islandora\EventSubscriber;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\media\MediaInterface; use Drupal\media\MediaInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
/** /**
* Subscribes to MediaLinkHeader Event. * Subscribes to MediaLinkHeader Event.
@ -17,7 +17,7 @@ class MediaLinkHeaderSubscriber extends LinkHeaderSubscriber implements EventSub
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function onResponse(FilterResponseEvent $event) { public function onResponse(ResponseEvent $event) {
$response = $event->getResponse(); $response = $event->getResponse();
$media = $this->getObject($response, 'media'); $media = $this->getObject($response, 'media');

6
src/EventSubscriber/NodeLinkHeaderSubscriber.php

@ -2,9 +2,9 @@
namespace Drupal\islandora\EventSubscriber; namespace Drupal\islandora\EventSubscriber;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Drupal\node\NodeInterface; use Drupal\node\NodeInterface;
use Drupal\islandora\IslandoraUtils; use Drupal\islandora\IslandoraUtils;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/** /**
@ -17,10 +17,10 @@ class NodeLinkHeaderSubscriber extends LinkHeaderSubscriber implements EventSubs
/** /**
* Adds node-specific link headers to appropriate responses. * Adds node-specific link headers to appropriate responses.
* *
* @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event * @param \Symfony\Component\HttpKernel\Event\ResponseEvent $event
* Event containing the response. * Event containing the response.
*/ */
public function onResponse(FilterResponseEvent $event) { public function onResponse(ResponseEvent $event) {
$response = $event->getResponse(); $response = $event->getResponse();
$node = $this->getObject($response, 'node'); $node = $this->getObject($response, 'node');

14
src/Flysystem/Adapter/FedoraAdapter.php

@ -2,6 +2,8 @@
namespace Drupal\islandora\Flysystem\Adapter; namespace Drupal\islandora\Flysystem\Adapter;
use GuzzleHttp\Psr7\Header;
use function GuzzleHttp\Psr7\parse_header;
use Drupal\Core\Logger\LoggerChannelInterface; use Drupal\Core\Logger\LoggerChannelInterface;
use Islandora\Chullo\IFedoraApi; use Islandora\Chullo\IFedoraApi;
use League\Flysystem\AdapterInterface; use League\Flysystem\AdapterInterface;
@ -159,11 +161,11 @@ class FedoraAdapter implements AdapterInterface {
// directory. // directory.
$type = 'dir'; $type = 'dir';
// phpcs:disable // phpcs:disable
if (class_exists(\GuzzleHttp\Psr7\Header::class)) { if (class_exists(Header::class)) {
$links = \GuzzleHttp\Psr7\Header::parse($response->getHeader('Link')); $links = Header::parse($response->getHeader('Link'));
} }
else { else {
$links = \GuzzleHttp\Psr7\parse_header($response->getHeader('Link')); $links = parse_header($response->getHeader('Link'));
} }
// phpcs:enable // phpcs:enable
foreach ($links as $link) { foreach ($links as $link) {
@ -402,11 +404,11 @@ class FedoraAdapter implements AdapterInterface {
if ($response->getStatusCode() == 410) { if ($response->getStatusCode() == 410) {
$return = FALSE; $return = FALSE;
// phpcs:disable // phpcs:disable
if (class_exists(\GuzzleHttp\Psr7\Header::class)) { if (class_exists(Header::class)) {
$link_headers = \GuzzleHttp\Psr7\Header::parse($response->getHeader('Link')); $link_headers = Header::parse($response->getHeader('Link'));
} }
else { else {
$link_headers = \GuzzleHttp\Psr7\parse_header($response->getHeader('Link')); $link_headers = parse_header($response->getHeader('Link'));
} }
// phpcs:enable // phpcs:enable
if ($link_headers) { if ($link_headers) {

2
tests/src/Functional/AddChildTest.php

@ -12,7 +12,7 @@ class AddChildTest extends IslandoraFunctionalTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
$this->parent = $this->parent =

2
tests/src/Functional/AddMediaToNodeTest.php

@ -31,7 +31,7 @@ class AddMediaToNodeTest extends IslandoraFunctionalTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
$this->node = $this->container->get('entity_type.manager')->getStorage('node')->create([ $this->node = $this->container->get('entity_type.manager')->getStorage('node')->create([

3
tests/src/Functional/ContentEntityTypeTest.php

@ -52,7 +52,8 @@ class ContentEntityTypeTest extends IslandoraFunctionalTestBase {
'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',
]; ];
$this->drupalPostForm('media/add/' . $this->testMediaType->id(), $values, $this->t('Save')); $this->drupalGet('media/add/' . $this->testMediaType->id());
$this->submitForm($values, $this->t('Save'));
$this->assertSession()->pageTextNotContains("Hello World!"); $this->assertSession()->pageTextNotContains("Hello World!");
} }

4
tests/src/Functional/DeleteMediaTest.php

@ -16,7 +16,7 @@ class DeleteMediaTest extends IslandoraFunctionalTestBase {
* *
* @var array * @var array
*/ */
public static $modules = [ protected static $modules = [
'media_test_views', 'media_test_views',
'context_ui', 'context_ui',
'field_ui', 'field_ui',
@ -47,7 +47,7 @@ class DeleteMediaTest extends IslandoraFunctionalTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
// Create a test user. // Create a test user.

5
tests/src/Functional/DerivativeReactionTest.php

@ -19,7 +19,7 @@ class DerivativeReactionTest extends IslandoraFunctionalTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
$this->node = $this->container->get('entity_type.manager')->getStorage('node')->create([ $this->node = $this->container->get('entity_type.manager')->getStorage('node')->create([
@ -52,7 +52,8 @@ class DerivativeReactionTest extends IslandoraFunctionalTestBase {
'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',
]; ];
$this->drupalPostForm('media/add/' . $this->testMediaType->id(), $values, $this->t('Save')); $this->drupalGet('media/add/' . $this->testMediaType->id());
$this->submitForm($values, $this->t('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!");

2
tests/src/Functional/GenerateDerivativeTestBase.php

@ -29,7 +29,7 @@ abstract class GenerateDerivativeTestBase extends IslandoraFunctionalTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
$this->createUserAndLogin(); $this->createUserAndLogin();

5
tests/src/Functional/IndexingTest.php

@ -12,7 +12,7 @@ class IndexingTest extends IslandoraFunctionalTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
// Create an action that dsm's "Goodbye, Cruel World!". // Create an action that dsm's "Goodbye, Cruel World!".
@ -63,9 +63,10 @@ class IndexingTest extends IslandoraFunctionalTestBase {
// Add the Goodbye World reaction. // Add the Goodbye World reaction.
$this->addPresetReaction('test', 'delete', 'goodbye_world'); $this->addPresetReaction('test', 'delete', 'goodbye_world');
$this->drupalGet("$url/delete");
// Delete the node. // Delete the node.
$this->drupalPostForm("$url/delete", [], $this->t('Delete')); $this->submitForm([], $this->t('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.

11
tests/src/Functional/IslandoraFunctionalTestBase.php

@ -88,7 +88,7 @@ class IslandoraFunctionalTestBase extends BrowserTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
// Delete the node rest config that's bootstrapped with Drupal. // Delete the node rest config that's bootstrapped with Drupal.
@ -314,7 +314,8 @@ EOD;
* Create a new node by posting its add form. * Create a new node by posting its add form.
*/ */
protected function postNodeAddForm($bundle_id, $values, $button_text) { protected function postNodeAddForm($bundle_id, $values, $button_text) {
$this->drupalPostForm("node/add/$bundle_id", $values, $this->t('@text', ['@text' => $button_text])); $this->drupalGet("node/add/$bundle_id");
$this->submitForm($values, $this->t('@text', ['@text' => $button_text]));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
} }
@ -322,7 +323,8 @@ EOD;
* Create a new node by posting its add form. * Create a new node by posting its add form.
*/ */
protected function postTermAddForm($taxomony_id, $values, $button_text) { protected function postTermAddForm($taxomony_id, $values, $button_text) {
$this->drupalPostForm("admin/structure/taxonomy/manage/$taxomony_id/add", $values, $this->t('@text', ['@text' => $button_text])); $this->drupalGet("admin/structure/taxonomy/manage/$taxomony_id/add");
$this->submitForm($values, $this->t('@text', ['@text' => $button_text]));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
} }
@ -330,7 +332,8 @@ EOD;
* Edits a node by posting its edit form. * Edits a node by posting its edit form.
*/ */
protected function postEntityEditForm($entity_url, $values, $button_text) { protected function postEntityEditForm($entity_url, $values, $button_text) {
$this->drupalPostForm("$entity_url/edit", $values, $this->t('@text', ['@text' => $button_text])); $this->drupalGet("$entity_url/edit");
$this->submitForm($values, $this->t('@text', ['@text' => $button_text]));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
} }

2
tests/src/Functional/IslandoraImageFormatterTest.php

@ -92,7 +92,7 @@ class IslandoraImageFormatterTest extends IslandoraFunctionalTestBase {
':title' => 'Some Title', ':title' => 'Some Title',
] ]
); );
$this->assertEqual(count($elements), 1, 'Image linked to content formatter displaying points to Node and not Media.'); $this->assertEquals(count($elements), 1, 'Image linked to content formatter displaying points to Node and not Media.');
} }
} }

17
tests/src/Functional/IslandoraSettingsFormTest.php

@ -14,7 +14,7 @@ class IslandoraSettingsFormTest extends IslandoraFunctionalTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
// Create a test user. // Create a test user.
@ -36,20 +36,25 @@ class IslandoraSettingsFormTest extends IslandoraFunctionalTestBase {
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
$this->assertSession()->pageTextContains("JWT Expiry"); $this->assertSession()->pageTextContains("JWT Expiry");
$this->assertSession()->fieldValueEquals('edit-jwt-expiry', '+2 hour'); $this->assertSession()->fieldValueEquals('edit-jwt-expiry', '+2 hour');
$this->drupalGet('/admin/config/islandora/core');
// Blank is not allowed. // Blank is not allowed.
$this->drupalPostForm('/admin/config/islandora/core', ['edit-jwt-expiry' => ""], $this->t('Save configuration')); $this->submitForm(['edit-jwt-expiry' => ""], $this->t('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');
// Negative is not allowed. // Negative is not allowed.
$this->drupalPostForm('/admin/config/islandora/core', ['edit-jwt-expiry' => "-2 hours"], $this->t('Save configuration')); $this->submitForm(['edit-jwt-expiry' => "-2 hours"], $this->t('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');
// Must include an integer value. // Must include an integer value.
$this->drupalPostForm('/admin/config/islandora/core', ['edit-jwt-expiry' => "last hour"], $this->t('Save configuration')); $this->submitForm(['edit-jwt-expiry' => "last hour"], $this->t('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');
// Must have an accepted interval. // Must have an accepted interval.
$this->drupalPostForm('/admin/config/islandora/core', ['edit-jwt-expiry' => "1 fortnight"], $this->t('Save configuration')); $this->submitForm(['edit-jwt-expiry' => "1 fortnight"], $this->t('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');
// Test a valid setting. // Test a valid setting.
$this->drupalPostForm('/admin/config/islandora/core', ['edit-jwt-expiry' => "2 weeks"], $this->t('Save configuration')); $this->submitForm(['edit-jwt-expiry' => "2 weeks"], $this->t('Save configuration'));
$this->assertSession()->pageTextContainsOnce('The configuration options have been saved.'); $this->assertSession()->pageTextContainsOnce('The configuration options have been saved.');
} }

14
tests/src/Functional/JsonldSelfReferenceReactionTest.php

@ -2,6 +2,8 @@
namespace Drupal\Tests\islandora\Functional; namespace Drupal\Tests\islandora\Functional;
use function GuzzleHttp\json_decode;
/** /**
* Class MappingUriPredicateReactionTest. * Class MappingUriPredicateReactionTest.
* *
@ -13,7 +15,7 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
$types = ['schema:Thing']; $types = ['schema:Thing'];
@ -61,7 +63,7 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase {
$contents = $this->drupalGet($url . '?_format=jsonld'); $contents = $this->drupalGet($url . '?_format=jsonld');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
$json = \GuzzleHttp\json_decode($contents, TRUE); $json = json_decode($contents, TRUE);
$this->assertArrayHasKey('http://purl.org/dc/terms/title', $this->assertArrayHasKey('http://purl.org/dc/terms/title',
$json['@graph'][0], 'Missing dcterms:title key'); $json['@graph'][0], 'Missing dcterms:title key');
$this->assertEquals( $this->assertEquals(
@ -103,7 +105,7 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase {
drupal_flush_all_caches(); drupal_flush_all_caches();
$new_contents = $this->drupalGet($url . '?_format=jsonld'); $new_contents = $this->drupalGet($url . '?_format=jsonld');
$json = \GuzzleHttp\json_decode($new_contents, TRUE); $json = json_decode($new_contents, TRUE);
$this->assertEquals( $this->assertEquals(
'Test Node', 'Test Node',
$json['@graph'][0]['http://purl.org/dc/terms/title'][0]['@value'], $json['@graph'][0]['http://purl.org/dc/terms/title'][0]['@value'],
@ -123,7 +125,7 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase {
$this->assertSession() $this->assertSession()
->pageTextContains("The context $context_name has been saved"); ->pageTextContains("The context $context_name has been saved");
$new_contents = $this->drupalGet($url . '?_format=jsonld'); $new_contents = $this->drupalGet($url . '?_format=jsonld');
$json = \GuzzleHttp\json_decode($new_contents, TRUE); $json = json_decode($new_contents, TRUE);
$this->assertEquals( $this->assertEquals(
'Test Node', 'Test Node',
$json['@graph'][0]['http://purl.org/dc/terms/title'][0]['@value'], $json['@graph'][0]['http://purl.org/dc/terms/title'][0]['@value'],
@ -161,7 +163,7 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase {
$contents = $this->drupalGet($media_url . '?_format=jsonld'); $contents = $this->drupalGet($media_url . '?_format=jsonld');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
$json = \GuzzleHttp\json_decode($contents, TRUE); $json = json_decode($contents, TRUE);
$this->assertEquals( $this->assertEquals(
"$media_url?_format=jsonld", "$media_url?_format=jsonld",
$json['@graph'][0]['@id'], $json['@graph'][0]['@id'],
@ -186,7 +188,7 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase {
drupal_flush_all_caches(); drupal_flush_all_caches();
$new_contents = $this->drupalGet($media_url . '?_format=jsonld'); $new_contents = $this->drupalGet($media_url . '?_format=jsonld');
$json = \GuzzleHttp\json_decode($new_contents, TRUE); $json = json_decode($new_contents, TRUE);
$this->assertEquals( $this->assertEquals(
"$media_url?_format=jsonld", "$media_url?_format=jsonld",
$json['@graph'][0]['http://www.iana.org/assignments/relation/describedby'][0]['@id'], $json['@graph'][0]['http://www.iana.org/assignments/relation/describedby'][0]['@id'],

15
tests/src/Functional/JsonldTypeAlterReactionTest.php

@ -2,6 +2,8 @@
namespace Drupal\Tests\islandora\Functional; namespace Drupal\Tests\islandora\Functional;
use function GuzzleHttp\json_decode;
/** /**
* Tests Jsonld Alter Reaction. * Tests Jsonld Alter Reaction.
* *
@ -20,17 +22,18 @@ class JsonldTypeAlterReactionTest extends JsonldSelfReferenceReactionTest {
'administer node fields', 'administer node fields',
]); ]);
$this->drupalLogin($account); $this->drupalLogin($account);
$this->drupalGet('admin/structure/types/manage/test_type/fields/add-field');
// Add the typed predicate we will select in the reaction config. // Add the typed predicate we will select in the reaction config.
// Taken from FieldUiTestTrait->fieldUIAddNewField. // Taken from FieldUiTestTrait->fieldUIAddNewField.
$this->drupalPostForm('admin/structure/types/manage/test_type/fields/add-field', [ $this->submitForm([
'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')); ], $this->t('Save and continue'));
$this->drupalPostForm(NULL, [], $this->t('Save field settings')); $this->submitForm([], $this->t('Save field settings'));
$this->drupalPostForm(NULL, [], $this->t('Save settings')); $this->submitForm([], $this->t('Save settings'));
$this->assertRaw('field_type_predicate', 'Redirected to "Manage fields" page.'); $this->assertSession()->responseContains('field_type_predicate');
// Add the test node. // Add the test node.
$this->postNodeAddForm('test_type', [ $this->postNodeAddForm('test_type', [
@ -46,7 +49,7 @@ class JsonldTypeAlterReactionTest extends JsonldSelfReferenceReactionTest {
$contents = $this->drupalGet($url . '?_format=jsonld'); $contents = $this->drupalGet($url . '?_format=jsonld');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
$json = \GuzzleHttp\json_decode($contents, TRUE); $json = json_decode($contents, TRUE);
$this->assertArrayHasKey('@type', $this->assertArrayHasKey('@type',
$json['@graph'][0], 'Missing @type'); $json['@graph'][0], 'Missing @type');
$this->assertEquals( $this->assertEquals(
@ -81,7 +84,7 @@ class JsonldTypeAlterReactionTest extends JsonldSelfReferenceReactionTest {
// Check for the new @type from the field_type_predicate value. // Check for the new @type from the field_type_predicate value.
$new_contents = $this->drupalGet($url . '?_format=jsonld'); $new_contents = $this->drupalGet($url . '?_format=jsonld');
$json = \GuzzleHttp\json_decode($new_contents, TRUE); $json = json_decode($new_contents, TRUE);
$this->assertTrue( $this->assertTrue(
in_array('http://schema.org/Organization', $json['@graph'][0]['@type']), in_array('http://schema.org/Organization', $json['@graph'][0]['@type']),
'Missing altered @type value of http://schema.org/Organization' 'Missing altered @type value of http://schema.org/Organization'

2
tests/src/Functional/LinkHeaderTest.php

@ -42,7 +42,7 @@ class LinkHeaderTest extends IslandoraFunctionalTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
$account = $this->createUserAndLogin(); $account = $this->createUserAndLogin();

2
tests/src/Functional/MediaSourceUpdateTest.php

@ -35,7 +35,7 @@ class MediaSourceUpdateTest extends IslandoraFunctionalTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
// Make a user with appropriate permissions. // Make a user with appropriate permissions.

2
tests/src/Functional/NodeHasTermTest.php

@ -13,7 +13,7 @@ class NodeHasTermTest extends IslandoraFunctionalTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();

2
tests/src/Functional/ViewModeAlterReactionTest.php

@ -26,7 +26,7 @@ class ViewModeAlterReactionTest extends IslandoraFunctionalTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
// Node to be referenced via member of. // Node to be referenced via member of.

2
tests/src/FunctionalJavascript/IntegerWeightTest.php

@ -80,7 +80,7 @@ class IntegerWeightTest extends WebDriverTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
$this->adminUser = $this->drupalCreateUser( $this->adminUser = $this->drupalCreateUser(

2
tests/src/Kernel/EventGeneratorTest.php

@ -41,7 +41,7 @@ class EventGeneratorTest extends IslandoraKernelTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
// Create a test user. // Create a test user.

12
tests/src/Kernel/FedoraAdapterTest.php

@ -2,6 +2,9 @@
namespace Drupal\Tests\islandora\Kernel; namespace Drupal\Tests\islandora\Kernel;
use Prophecy\PhpUnit\ProphecyTrait;
use GuzzleHttp\Psr7\Utils;
use function GuzzleHttp\Psr7\stream_for;
use Drupal\Core\Logger\LoggerChannelInterface; use Drupal\Core\Logger\LoggerChannelInterface;
use Drupal\islandora\Flysystem\Adapter\FedoraAdapter; use Drupal\islandora\Flysystem\Adapter\FedoraAdapter;
use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Response;
@ -18,6 +21,7 @@ use Symfony\Component\Mime\MimeTypeGuesserInterface;
*/ */
class FedoraAdapterTest extends IslandoraKernelTestBase { class FedoraAdapterTest extends IslandoraKernelTestBase {
use ProphecyTrait;
/** /**
* A mimetype guesser prophecy. * A mimetype guesser prophecy.
* *
@ -35,7 +39,7 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
$this->mimeGuesser = $this->prophesize(MimeTypeGuesserInterface::class) $this->mimeGuesser = $this->prophesize(MimeTypeGuesserInterface::class)
->reveal(); ->reveal();
@ -58,10 +62,10 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$prophecy->getHeader('Content-Type')->willReturn(['text/plain']); $prophecy->getHeader('Content-Type')->willReturn(['text/plain']);
$prophecy->getHeader('Content-Length')->willReturn([strlen("DERP")]); $prophecy->getHeader('Content-Length')->willReturn([strlen("DERP")]);
// phpcs:disable // phpcs:disable
if (class_exists(\GuzzleHttp\Psr7\Utils::class)) { if (class_exists(Utils::class)) {
$prophecy->getBody()->willReturn(\GuzzleHttp\Psr7\Utils::streamFor("DERP")); $prophecy->getBody()->willReturn(Utils::streamFor("DERP"));
} else { } else {
$prophecy->getBody()->willReturn(\GuzzleHttp\Psr7\stream_for("DERP")); $prophecy->getBody()->willReturn(stream_for("DERP"));
} }
// phpcs:enable // phpcs:enable
return $prophecy; return $prophecy;

4
tests/src/Kernel/IslandoraKernelTestBase.php

@ -12,7 +12,7 @@ abstract class IslandoraKernelTestBase extends KernelTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static $modules = [ protected static $modules = [
'system', 'system',
'user', 'user',
'field', 'field',
@ -43,7 +43,7 @@ abstract class IslandoraKernelTestBase extends KernelTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
// Bootstrap minimal Drupal environment to run the tests. // Bootstrap minimal Drupal environment to run the tests.

4
tests/src/Kernel/JwtEventSubscriberTest.php

@ -2,6 +2,7 @@
namespace Drupal\Tests\islandora\Kernel; namespace Drupal\Tests\islandora\Kernel;
use Prophecy\PhpUnit\ProphecyTrait;
use Drupal\jwt\Authentication\Event\JwtAuthGenerateEvent; use Drupal\jwt\Authentication\Event\JwtAuthGenerateEvent;
use Drupal\jwt\Authentication\Event\JwtAuthValidEvent; use Drupal\jwt\Authentication\Event\JwtAuthValidEvent;
use Drupal\jwt\Authentication\Event\JwtAuthValidateEvent; use Drupal\jwt\Authentication\Event\JwtAuthValidateEvent;
@ -19,6 +20,7 @@ use Drupal\islandora\EventSubscriber\JwtEventSubscriber;
*/ */
class JwtEventSubscriberTest extends IslandoraKernelTestBase { class JwtEventSubscriberTest extends IslandoraKernelTestBase {
use ProphecyTrait;
use UserCreationTrait; use UserCreationTrait;
/** /**
@ -31,7 +33,7 @@ class JwtEventSubscriberTest extends IslandoraKernelTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
$this->user = $this->createUser(); $this->user = $this->createUser();

Loading…
Cancel
Save