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) {
if ($extension == 'facets') {
// 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'] = [
"$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_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 = [
'source_uri' => 'test_file.txt',

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

@ -20,7 +20,7 @@ class BreadcrumbsTest extends IslandoraFunctionalTestBase {
*
* @var array
*/
public static $modules = [
protected static $modules = [
'islandora_breadcrumbs',
];
@ -56,7 +56,7 @@ class BreadcrumbsTest extends IslandoraFunctionalTestBase {
/**
* {@inheritdoc}
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
// 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\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Url;
@ -92,17 +91,10 @@ class IIIFManifest extends StylePluginBase {
*/
protected $messenger;
/**
* Module Handler for running hooks.
*
* @var \Drupal\Core\Extention\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* {@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);
$this->serializer = $serializer;
@ -112,7 +104,6 @@ class IIIFManifest extends StylePluginBase {
$this->fileSystem = $file_system;
$this->httpClient = $http_client;
$this->messenger = $messenger;
$this->moduleHandler = $moduleHandler;
}
/**
@ -129,21 +120,10 @@ class IIIFManifest extends StylePluginBase {
$container->get('entity_type.manager'),
$container->get('file_system'),
$container->get('http_client'),
$container->get('messenger'),
$container->get('module_handler')
$container->get('messenger')
);
}
/**
* Return the request property.
*
* @return \Symfony\Component\HttpFoundation\Request
* The Symfony request object
*/
public function getRequest() {
return $this->request;
}
/**
* {@inheritdoc}
*/
@ -190,9 +170,6 @@ class IIIFManifest extends StylePluginBase {
$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]);
}
@ -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;
}
}

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_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 = [
'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)) {
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)) {
$media->{$destination_field}->setValue([
'target_id' => $file->id(),

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

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

6
src/EventSubscriber/LinkHeaderSubscriber.php

@ -2,6 +2,7 @@
namespace Drupal\islandora\EventSubscriber;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Drupal\Core\Access\AccessManagerInterface;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityInterface;
@ -13,7 +14,6 @@ use Drupal\Core\Entity\Exception\UndefinedLinkTemplateException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
/**
@ -312,9 +312,9 @@ abstract class LinkHeaderSubscriber implements EventSubscriberInterface {
/**
* 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.
*/
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;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Drupal\Core\Url;
use Drupal\media\MediaInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
/**
* Subscribes to MediaLinkHeader Event.
@ -17,7 +17,7 @@ class MediaLinkHeaderSubscriber extends LinkHeaderSubscriber implements EventSub
/**
* {@inheritdoc}
*/
public function onResponse(FilterResponseEvent $event) {
public function onResponse(ResponseEvent $event) {
$response = $event->getResponse();
$media = $this->getObject($response, 'media');

6
src/EventSubscriber/NodeLinkHeaderSubscriber.php

@ -2,9 +2,9 @@
namespace Drupal\islandora\EventSubscriber;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Drupal\node\NodeInterface;
use Drupal\islandora\IslandoraUtils;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
@ -17,10 +17,10 @@ class NodeLinkHeaderSubscriber extends LinkHeaderSubscriber implements EventSubs
/**
* 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.
*/
public function onResponse(FilterResponseEvent $event) {
public function onResponse(ResponseEvent $event) {
$response = $event->getResponse();
$node = $this->getObject($response, 'node');

14
src/Flysystem/Adapter/FedoraAdapter.php

@ -2,6 +2,8 @@
namespace Drupal\islandora\Flysystem\Adapter;
use GuzzleHttp\Psr7\Header;
use function GuzzleHttp\Psr7\parse_header;
use Drupal\Core\Logger\LoggerChannelInterface;
use Islandora\Chullo\IFedoraApi;
use League\Flysystem\AdapterInterface;
@ -159,11 +161,11 @@ class FedoraAdapter implements AdapterInterface {
// directory.
$type = 'dir';
// phpcs:disable
if (class_exists(\GuzzleHttp\Psr7\Header::class)) {
$links = \GuzzleHttp\Psr7\Header::parse($response->getHeader('Link'));
if (class_exists(Header::class)) {
$links = Header::parse($response->getHeader('Link'));
}
else {
$links = \GuzzleHttp\Psr7\parse_header($response->getHeader('Link'));
$links = parse_header($response->getHeader('Link'));
}
// phpcs:enable
foreach ($links as $link) {
@ -402,11 +404,11 @@ class FedoraAdapter implements AdapterInterface {
if ($response->getStatusCode() == 410) {
$return = FALSE;
// phpcs:disable
if (class_exists(\GuzzleHttp\Psr7\Header::class)) {
$link_headers = \GuzzleHttp\Psr7\Header::parse($response->getHeader('Link'));
if (class_exists(Header::class)) {
$link_headers = Header::parse($response->getHeader('Link'));
}
else {
$link_headers = \GuzzleHttp\Psr7\parse_header($response->getHeader('Link'));
$link_headers = parse_header($response->getHeader('Link'));
}
// phpcs:enable
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
*/
protected ?AbstractBatchProcessor $batchProcessor;
private \static $static;
public function __construct(\static $static)
{
$this->static = $static;
}
/**
* {@inheritdoc}
@ -49,7 +54,7 @@ abstract class AbstractFileSelectionForm extends FormBase {
$instance->entityFieldManager = $container->get('entity_field.manager');
$instance->currentUser = $container->get('current_user');
$instance->batchProcessor = $container->get(static::BATCH_PROCESSOR);
$instance->batchProcessor = $this->static;
return $instance;
}

2
tests/src/Functional/AddChildTest.php

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

2
tests/src/Functional/AddMediaToNodeTest.php

@ -31,7 +31,7 @@ class AddMediaToNodeTest extends IslandoraFunctionalTestBase {
/**
* {@inheritdoc}
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$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',
'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!");
}

4
tests/src/Functional/DeleteMediaTest.php

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

5
tests/src/Functional/DerivativeReactionTest.php

@ -19,7 +19,7 @@ class DerivativeReactionTest extends IslandoraFunctionalTestBase {
/**
* {@inheritdoc}
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$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',
'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.
$this->assertSession()->pageTextContains("Hello World!");

2
tests/src/Functional/GenerateDerivativeTestBase.php

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

5
tests/src/Functional/IndexingTest.php

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

11
tests/src/Functional/IslandoraFunctionalTestBase.php

@ -88,7 +88,7 @@ class IslandoraFunctionalTestBase extends BrowserTestBase {
/**
* {@inheritdoc}
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
// Delete the node rest config that's bootstrapped with Drupal.
@ -314,7 +314,8 @@ EOD;
* Create a new node by posting its add form.
*/
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);
}
@ -322,7 +323,8 @@ EOD;
* Create a new node by posting its add form.
*/
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);
}
@ -330,7 +332,8 @@ EOD;
* Edits a node by posting its edit form.
*/
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);
}

2
tests/src/Functional/IslandoraImageFormatterTest.php

@ -92,7 +92,7 @@ class IslandoraImageFormatterTest extends IslandoraFunctionalTestBase {
':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}
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
// Create a test user.
@ -36,20 +36,25 @@ class IslandoraSettingsFormTest extends IslandoraFunctionalTestBase {
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->pageTextContains("JWT Expiry");
$this->assertSession()->fieldValueEquals('edit-jwt-expiry', '+2 hour');
$this->drupalGet('/admin/config/islandora/core');
// 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->drupalGet('/admin/config/islandora/core');
// 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->drupalGet('/admin/config/islandora/core');
// 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->drupalGet('/admin/config/islandora/core');
// 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->drupalGet('/admin/config/islandora/core');
// 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.');
}

13
tests/src/Functional/JsonldSelfReferenceReactionTest.php

@ -2,6 +2,7 @@
namespace Drupal\Tests\islandora\Functional;
use function GuzzleHttp\json_decode;
/**
* Class MappingUriPredicateReactionTest.
*
@ -13,7 +14,7 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase {
/**
* {@inheritdoc}
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$types = ['schema:Thing'];
@ -61,7 +62,7 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase {
$contents = $this->drupalGet($url . '?_format=jsonld');
$this->assertSession()->statusCodeEquals(200);
$json = \GuzzleHttp\json_decode($contents, TRUE);
$json = json_decode($contents, TRUE);
$this->assertArrayHasKey('http://purl.org/dc/terms/title',
$json['@graph'][0], 'Missing dcterms:title key');
$this->assertEquals(
@ -103,7 +104,7 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase {
drupal_flush_all_caches();
$new_contents = $this->drupalGet($url . '?_format=jsonld');
$json = \GuzzleHttp\json_decode($new_contents, TRUE);
$json = json_decode($new_contents, TRUE);
$this->assertEquals(
'Test Node',
$json['@graph'][0]['http://purl.org/dc/terms/title'][0]['@value'],
@ -123,7 +124,7 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase {
$this->assertSession()
->pageTextContains("The context $context_name has been saved");
$new_contents = $this->drupalGet($url . '?_format=jsonld');
$json = \GuzzleHttp\json_decode($new_contents, TRUE);
$json = json_decode($new_contents, TRUE);
$this->assertEquals(
'Test Node',
$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');
$this->assertSession()->statusCodeEquals(200);
$json = \GuzzleHttp\json_decode($contents, TRUE);
$json = json_decode($contents, TRUE);
$this->assertEquals(
"$media_url?_format=jsonld",
$json['@graph'][0]['@id'],
@ -186,7 +187,7 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase {
drupal_flush_all_caches();
$new_contents = $this->drupalGet($media_url . '?_format=jsonld');
$json = \GuzzleHttp\json_decode($new_contents, TRUE);
$json = json_decode($new_contents, TRUE);
$this->assertEquals(
"$media_url?_format=jsonld",
$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;
use function GuzzleHttp\json_decode;
/**
* Tests Jsonld Alter Reaction.
*
@ -20,17 +21,18 @@ class JsonldTypeAlterReactionTest extends JsonldSelfReferenceReactionTest {
'administer node fields',
]);
$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.
// Taken from FieldUiTestTrait->fieldUIAddNewField.
$this->drupalPostForm('admin/structure/types/manage/test_type/fields/add-field', [
$this->submitForm([
'new_storage_type' => 'string',
'label' => 'Typed Predicate',
'field_name' => 'type_predicate',
], $this->t('Save and continue'));
$this->drupalPostForm(NULL, [], $this->t('Save field settings'));
$this->drupalPostForm(NULL, [], $this->t('Save settings'));
$this->assertRaw('field_type_predicate', 'Redirected to "Manage fields" page.');
$this->submitForm([], $this->t('Save field settings'));
$this->submitForm([], $this->t('Save settings'));
$this->assertSession()->responseContains('field_type_predicate');
// Add the test node.
$this->postNodeAddForm('test_type', [
@ -46,7 +48,7 @@ class JsonldTypeAlterReactionTest extends JsonldSelfReferenceReactionTest {
$contents = $this->drupalGet($url . '?_format=jsonld');
$this->assertSession()->statusCodeEquals(200);
$json = \GuzzleHttp\json_decode($contents, TRUE);
$json = json_decode($contents, TRUE);
$this->assertArrayHasKey('@type',
$json['@graph'][0], 'Missing @type');
$this->assertEquals(
@ -81,7 +83,7 @@ class JsonldTypeAlterReactionTest extends JsonldSelfReferenceReactionTest {
// Check for the new @type from the field_type_predicate value.
$new_contents = $this->drupalGet($url . '?_format=jsonld');
$json = \GuzzleHttp\json_decode($new_contents, TRUE);
$json = json_decode($new_contents, TRUE);
$this->assertTrue(
in_array('http://schema.org/Organization', $json['@graph'][0]['@type']),
'Missing altered @type value of http://schema.org/Organization'

2
tests/src/Functional/LinkHeaderTest.php

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

2
tests/src/Functional/MediaSourceUpdateTest.php

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

2
tests/src/Functional/NodeHasTermTest.php

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

2
tests/src/Functional/ViewModeAlterReactionTest.php

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

2
tests/src/FunctionalJavascript/IntegerWeightTest.php

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

2
tests/src/Kernel/EventGeneratorTest.php

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

12
tests/src/Kernel/FedoraAdapterTest.php

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

4
tests/src/Kernel/IslandoraKernelTestBase.php

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

4
tests/src/Kernel/JwtEventSubscriberTest.php

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

Loading…
Cancel
Save