Browse Source

Drupal Rector.

pull/943/head
Rosie Le Faive 2 years ago
parent
commit
06f2a5754e
  1. 2
      modules/islandora_advanced_search/islandora_advanced_search.module
  2. 3
      modules/islandora_audio/tests/src/Functional/GenerateAudioDerivativeTest.php
  3. 4
      modules/islandora_breadcrumbs/tests/src/Functional/BreadcrumbsTest.php
  4. 34
      modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php
  5. 3
      modules/islandora_image/tests/src/Functional/GenerateImageDerivativeTest.php
  6. 2
      modules/islandora_text_extraction/src/Controller/MediaSourceController.php
  7. 4
      modules/islandora_text_extraction/tests/src/Functional/LoadTest.php
  8. 3
      modules/islandora_video/tests/src/Functional/GenerateVideoDerivativeTest.php
  9. 6
      src/EventSubscriber/LinkHeaderSubscriber.php
  10. 4
      src/EventSubscriber/MediaLinkHeaderSubscriber.php
  11. 6
      src/EventSubscriber/NodeLinkHeaderSubscriber.php
  12. 14
      src/Flysystem/Adapter/FedoraAdapter.php
  13. 7
      src/Form/AddChildrenWizard/AbstractFileSelectionForm.php
  14. 2
      tests/src/Functional/AddChildTest.php
  15. 2
      tests/src/Functional/AddMediaToNodeTest.php
  16. 3
      tests/src/Functional/ContentEntityTypeTest.php
  17. 4
      tests/src/Functional/DeleteMediaTest.php
  18. 5
      tests/src/Functional/DerivativeReactionTest.php
  19. 2
      tests/src/Functional/GenerateDerivativeTestBase.php
  20. 5
      tests/src/Functional/IndexingTest.php
  21. 11
      tests/src/Functional/IslandoraFunctionalTestBase.php
  22. 2
      tests/src/Functional/IslandoraImageFormatterTest.php
  23. 17
      tests/src/Functional/IslandoraSettingsFormTest.php
  24. 13
      tests/src/Functional/JsonldSelfReferenceReactionTest.php
  25. 14
      tests/src/Functional/JsonldTypeAlterReactionTest.php
  26. 2
      tests/src/Functional/LinkHeaderTest.php
  27. 2
      tests/src/Functional/MediaSourceUpdateTest.php
  28. 2
      tests/src/Functional/NodeHasTermTest.php
  29. 2
      tests/src/Functional/ViewModeAlterReactionTest.php
  30. 2
      tests/src/FunctionalJavascript/IntegerWeightTest.php
  31. 2
      tests/src/Kernel/EventGeneratorTest.php
  32. 12
      tests/src/Kernel/FedoraAdapterTest.php
  33. 4
      tests/src/Kernel/IslandoraKernelTestBase.php
  34. 4
      tests/src/Kernel/JwtEventSubscriberTest.php

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.

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

@ -4,7 +4,6 @@ namespace Drupal\islandora_iiif\Plugin\views\style;
use Drupal\views\Plugin\views\style\StylePluginBase; use Drupal\views\Plugin\views\style\StylePluginBase;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
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;
@ -92,17 +91,10 @@ class IIIFManifest extends StylePluginBase {
*/ */
protected $messenger; protected $messenger;
/**
* Module Handler for running hooks.
*
* @var \Drupal\Core\Extention\ModuleHandlerInterface
*/
protected $moduleHandler;
/** /**
* {@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) {
parent::__construct($configuration, $plugin_id, $plugin_definition); parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->serializer = $serializer; $this->serializer = $serializer;
@ -112,7 +104,6 @@ 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->moduleHandler = $moduleHandler;
} }
/** /**
@ -129,21 +120,10 @@ class IIIFManifest extends StylePluginBase {
$container->get('entity_type.manager'), $container->get('entity_type.manager'),
$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')
); );
} }
/**
* Return the request property.
*
* @return \Symfony\Component\HttpFoundation\Request
* The Symfony request object
*/
public function getRequest() {
return $this->request;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -190,9 +170,6 @@ class IIIFManifest extends StylePluginBase {
$content_type = 'json'; $content_type = 'json';
// Give other modules a chance to alter the manifest.
$this->moduleHandler->alter('islandora_iiif_manifest', $json, $this);
return $this->serializer->serialize($json, $content_type, ['views_style_plugin' => $this]); return $this->serializer->serialize($json, $content_type, ['views_style_plugin' => $this]);
} }
@ -311,13 +288,6 @@ class IIIFManifest extends StylePluginBase {
]; ];
} }
// Give other modules a chance to alter the canvas.
$alter_options = [
'options' => $this->options,
'views_plugin' => $this,
];
$this->moduleHandler->alter('islandora_iiif_manifest_canvas', $tmp_canvas, $row, $alter_options);
$canvases[] = $tmp_canvas; $canvases[] = $tmp_canvas;
} }
} }

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',

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

@ -98,7 +98,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 = \Drupal::service('file.repository')->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) {

7
src/Form/AddChildrenWizard/AbstractFileSelectionForm.php

@ -37,6 +37,11 @@ abstract class AbstractFileSelectionForm extends FormBase {
* @var \Drupal\islandora\Form\AddChildrenWizard\AbstractBatchProcessor|null * @var \Drupal\islandora\Form\AddChildrenWizard\AbstractBatchProcessor|null
*/ */
protected ?AbstractBatchProcessor $batchProcessor; protected ?AbstractBatchProcessor $batchProcessor;
private \static $static;
public function __construct(\static $static)
{
$this->static = $static;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -49,7 +54,7 @@ abstract class AbstractFileSelectionForm extends FormBase {
$instance->entityFieldManager = $container->get('entity_field.manager'); $instance->entityFieldManager = $container->get('entity_field.manager');
$instance->currentUser = $container->get('current_user'); $instance->currentUser = $container->get('current_user');
$instance->batchProcessor = $container->get(static::BATCH_PROCESSOR); $instance->batchProcessor = $this->static;
return $instance; return $instance;
} }

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.');
} }

13
tests/src/Functional/JsonldSelfReferenceReactionTest.php

@ -2,6 +2,7 @@
namespace Drupal\Tests\islandora\Functional; namespace Drupal\Tests\islandora\Functional;
use function GuzzleHttp\json_decode;
/** /**
* Class MappingUriPredicateReactionTest. * Class MappingUriPredicateReactionTest.
* *
@ -13,7 +14,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 +62,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 +104,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 +124,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 +162,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 +187,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'],

14
tests/src/Functional/JsonldTypeAlterReactionTest.php

@ -2,6 +2,7 @@
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 +21,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 +48,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 +83,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