Browse Source

coder_fixes (#797)

Co-authored-by: ajstanley <alanjarlathstanle@gmail.com>
pull/801/head
Alan Stanley 4 years ago committed by GitHub
parent
commit
a3d7a55bdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php
  2. 2
      modules/islandora_text_extraction/src/Controller/MediaSourceController.php
  3. 2
      src/Commands/IslandoraCommands.php
  4. 2
      src/Controller/MediaSourceController.php
  5. 2
      src/EventSubscriber/JwtEventSubscriber.php
  6. 2
      src/EventSubscriber/LinkHeaderSubscriber.php
  7. 2
      src/EventSubscriber/MediaLinkHeaderSubscriber.php
  8. 2
      src/EventSubscriber/NodeLinkHeaderSubscriber.php
  9. 3
      src/Flysystem/Adapter/FedoraAdapter.php
  10. 26
      src/IslandoraUtils.php
  11. 2
      src/Plugin/Condition/EntityBundle.php
  12. 170
      tests/src/Functional/IslandoraFunctionalTestBase.php
  13. 2
      tests/src/Functional/IslandoraSettingsFormTest.php
  14. 2
      tests/src/Functional/JsonldTypeAlterReactionTest.php
  15. 49
      tests/src/Functional/NodeHasTermTest.php
  16. 155
      tests/src/Kernel/FedoraAdapterTest.php
  17. 2
      tests/src/Kernel/GeminiClientFactoryTest.php
  18. 9
      tests/src/Kernel/GeminiLookupTest.php

2
modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php

@ -8,7 +8,7 @@ use Drupal\Component\Utility\UrlHelper;
use GuzzleHttp\Exception\ClientException; use GuzzleHttp\Exception\ClientException;
/** /**
* Class IslandoraIIIFConfigForm. * Form to configure IslandoraIIIF.
*/ */
class IslandoraIIIFConfigForm extends ConfigFormBase { class IslandoraIIIFConfigForm extends ConfigFormBase {

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

@ -10,7 +10,7 @@ use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\File\FileSystem; use Drupal\Core\File\FileSystem;
/** /**
* Class MediaSourceController. * Controller for Media Source.
*/ */
class MediaSourceController extends ControllerBase { class MediaSourceController extends ControllerBase {

2
src/Commands/IslandoraCommands.php

@ -38,7 +38,7 @@ class IslandoraCommands extends DrushCommands {
* @hook validate migrate:import * @hook validate migrate:import
*/ */
public function validateUserImport(CommandData $commandData) { public function validateUserImport(CommandData $commandData) {
$this->validateUser($commandData);; $this->validateUser($commandData);
} }
/** /**

2
src/Controller/MediaSourceController.php

@ -21,7 +21,7 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\HttpException;
/** /**
* Class MediaSourceController. * Controller for MediaSource.
* *
* @package Drupal\islandora\Controller * @package Drupal\islandora\Controller
*/ */

2
src/EventSubscriber/JwtEventSubscriber.php

@ -13,7 +13,7 @@ use Drupal\Core\Session\AccountInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/** /**
* Class JwtEventSubscriber. * Subscribes to Jwt Events.
* *
* @package Drupal\islandora\EventSubscriber * @package Drupal\islandora\EventSubscriber
*/ */

2
src/EventSubscriber/LinkHeaderSubscriber.php

@ -17,7 +17,7 @@ use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\KernelEvents;
/** /**
* Class LinkHeaderSubscriber. * Abstract class to subscribe to LinkHeader Event.
* *
* @package Drupal\islandora\EventSubscriber * @package Drupal\islandora\EventSubscriber
*/ */

2
src/EventSubscriber/MediaLinkHeaderSubscriber.php

@ -8,7 +8,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
/** /**
* Class MediaLinkHeaderSubscriber. * Subscribes to MediaLinkHeader Event.
* *
* @package Drupal\islandora\EventSubscriber * @package Drupal\islandora\EventSubscriber
*/ */

2
src/EventSubscriber/NodeLinkHeaderSubscriber.php

@ -8,7 +8,7 @@ use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/** /**
* Class NodeLinkHeaderSubscriber. * Subcribes to NodeLinkHeader.
* *
* @package Drupal\islandora\EventSubscriber * @package Drupal\islandora\EventSubscriber
*/ */

3
src/Flysystem/Adapter/FedoraAdapter.php

@ -11,7 +11,6 @@ use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\StreamWrapper; use GuzzleHttp\Psr7\StreamWrapper;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface; use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface;
use DateTime;
/** /**
* Fedora adapter for Flysystem. * Fedora adapter for Flysystem.
@ -255,7 +254,7 @@ class FedoraAdapter implements AdapterInterface {
]; ];
if ($this->has($path)) { if ($this->has($path)) {
$fedora_url = $path; $fedora_url = $path;
$date = new DateTime(); $date = new \DateTime();
$timestamp = $date->format("D, d M Y H:i:s O"); $timestamp = $date->format("D, d M Y H:i:s O");
// Create version in Fedora. // Create version in Fedora.
try { try {

26
src/IslandoraUtils.php

@ -4,8 +4,8 @@ namespace Drupal\islandora;
use Drupal\context\ContextManager; use Drupal\context\ContextManager;
use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\Query\QueryException; use Drupal\Core\Entity\Query\QueryException;
use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Entity\Query\QueryFactory;
@ -15,9 +15,9 @@ use Drupal\Core\Site\Settings;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\file\FileInterface; use Drupal\file\FileInterface;
use Drupal\flysystem\FlysystemFactory; use Drupal\flysystem\FlysystemFactory;
use Drupal\islandora\ContextProvider\NodeContextProvider;
use Drupal\islandora\ContextProvider\MediaContextProvider;
use Drupal\islandora\ContextProvider\FileContextProvider; use Drupal\islandora\ContextProvider\FileContextProvider;
use Drupal\islandora\ContextProvider\MediaContextProvider;
use Drupal\islandora\ContextProvider\NodeContextProvider;
use Drupal\islandora\ContextProvider\TermContextProvider; use Drupal\islandora\ContextProvider\TermContextProvider;
use Drupal\media\MediaInterface; use Drupal\media\MediaInterface;
use Drupal\node\NodeInterface; use Drupal\node\NodeInterface;
@ -29,7 +29,9 @@ use Drupal\taxonomy\TermInterface;
class IslandoraUtils { class IslandoraUtils {
const EXTERNAL_URI_FIELD = 'field_external_uri'; const EXTERNAL_URI_FIELD = 'field_external_uri';
const MEDIA_OF_FIELD = 'field_media_of'; const MEDIA_OF_FIELD = 'field_media_of';
const MEDIA_USAGE_FIELD = 'field_media_use'; const MEDIA_USAGE_FIELD = 'field_media_use';
/** /**
@ -151,10 +153,13 @@ class IslandoraUtils {
* Calling getStorage() throws if the storage handler couldn't be loaded. * Calling getStorage() throws if the storage handler couldn't be loaded.
*/ */
public function getMedia(NodeInterface $node) { public function getMedia(NodeInterface $node) {
if (!$this->entityTypeManager->getStorage('field_storage_config')->load('media.' . self::MEDIA_OF_FIELD)) { if (!$this->entityTypeManager->getStorage('field_storage_config')
->load('media.' . self::MEDIA_OF_FIELD)) {
return []; return [];
} }
$mids = $this->entityQuery->get('media')->condition(self::MEDIA_OF_FIELD, $node->id())->execute(); $mids = $this->entityQuery->get('media')
->condition(self::MEDIA_OF_FIELD, $node->id())
->execute();
if (empty($mids)) { if (empty($mids)) {
return []; return [];
} }
@ -217,7 +222,8 @@ class IslandoraUtils {
$query->condition($condition, $fid); $query->condition($condition, $fid);
} }
return $this->entityTypeManager->getStorage('media')->loadMultiple($query->execute()); return $this->entityTypeManager->getStorage('media')
->loadMultiple($query->execute());
} }
/** /**
@ -261,7 +267,8 @@ class IslandoraUtils {
return NULL; return NULL;
} }
return $this->entityTypeManager->getStorage('taxonomy_term')->load(reset($results)); return $this->entityTypeManager->getStorage('taxonomy_term')
->load(reset($results));
} }
/** /**
@ -587,7 +594,10 @@ class IslandoraUtils {
*/ */
public function getDownloadUrl(FileInterface $file) { public function getDownloadUrl(FileInterface $file) {
$undefined = $this->languageManager->getLanguage('und'); $undefined = $this->languageManager->getLanguage('und');
return $file->url('canonical', ['absolute' => TRUE, 'language' => $undefined]); return $file->url('canonical', [
'absolute' => TRUE,
'language' => $undefined,
]);
} }
/** /**

2
src/Plugin/Condition/EntityBundle.php

@ -44,7 +44,7 @@ class EntityBundle extends ConditionPluginBase {
'#default_value' => $this->configuration['bundles'], '#default_value' => $this->configuration['bundles'],
]; ];
return parent::buildConfigurationForm($form, $form_state);; return parent::buildConfigurationForm($form, $form_state);
} }
/** /**

170
tests/src/Functional/IslandoraFunctionalTestBase.php

@ -80,7 +80,10 @@ class IslandoraFunctionalTestBase extends BrowserTestBase {
parent::setUp(); parent::setUp();
// Delete the node rest config that's bootstrapped with Drupal. // Delete the node rest config that's bootstrapped with Drupal.
$this->container->get('entity_type.manager')->getStorage('rest_resource_config')->load('entity.node')->delete(); $this->container->get('entity_type.manager')
->getStorage('rest_resource_config')
->load('entity.node')
->delete();
// Set up JWT stuff. // Set up JWT stuff.
$key_value = <<<EOD $key_value = <<<EOD
@ -113,67 +116,80 @@ EOLIc/4JOdONrJKWYpWIjDhHLL8BacjLoh2bDY0KdYa69AfYvW4=
-----END RSA PRIVATE KEY----- -----END RSA PRIVATE KEY-----
EOD; EOD;
$key = $this->container->get('entity_type.manager')->getStorage('key')->create([ $key = $this->container->get('entity_type.manager')
'id' => 'test', ->getStorage('key')
'label' => 'Test', ->create([
'key_type' => 'jwt_rs', 'id' => 'test',
'key_type_settings' => [ 'label' => 'Test',
'algorithm' => 'RS256', 'key_type' => 'jwt_rs',
], 'key_type_settings' => [
'key_provider' => 'config', 'algorithm' => 'RS256',
'key_provider_settings' => [ ],
'key_value' => $key_value, 'key_provider' => 'config',
], 'key_provider_settings' => [
]); 'key_value' => $key_value,
],
]);
$key->save(); $key->save();
$jwt_config = $this->container->get('config.factory')->getEditable('jwt.config'); $jwt_config = $this->container->get('config.factory')
->getEditable('jwt.config');
$jwt_config->set('algorithm', 'RS256'); $jwt_config->set('algorithm', 'RS256');
$jwt_config->set('key_id', 'test'); $jwt_config->set('key_id', 'test');
$jwt_config->save(TRUE); $jwt_config->save(TRUE);
// Make some bundles and field by hand so hooks fire. // Make some bundles and field by hand so hooks fire.
// Create an action that dsm's "Hello World!". // Create an action that dsm's "Hello World!".
$hello_world = $this->container->get('entity_type.manager')->getStorage('action')->create([ $hello_world = $this->container->get('entity_type.manager')
'id' => 'hello_world', ->getStorage('action')
'label' => 'Hello World', ->create([
'type' => 'system', 'id' => 'hello_world',
'plugin' => 'action_message_action', 'label' => 'Hello World',
'configuration' => [ 'type' => 'system',
'message' => 'Hello World!', 'plugin' => 'action_message_action',
], 'configuration' => [
]); 'message' => 'Hello World!',
],
]);
$hello_world->save(); $hello_world->save();
// Create a vocabulary. // Create a vocabulary.
$this->testVocabulary = $this->container->get('entity_type.manager')->getStorage('taxonomy_vocabulary')->create([ $this->testVocabulary = $this->container->get('entity_type.manager')
'name' => 'Test Vocabulary', ->getStorage('taxonomy_vocabulary')
'vid' => 'test_vocabulary', ->create([
]); 'name' => 'Test Vocabulary',
'vid' => 'test_vocabulary',
]);
$this->testVocabulary->save(); $this->testVocabulary->save();
// Create an external_uri field for taxonomy terms. // Create an external_uri field for taxonomy terms.
$fieldStorage = $this->container->get('entity_type.manager')->getStorage('field_storage_config')->create([ $fieldStorage = $this->container->get('entity_type.manager')
'field_name' => 'field_external_uri', ->getStorage('field_storage_config')
'entity_type' => 'taxonomy_term', ->create([
'type' => 'link', 'field_name' => 'field_external_uri',
]); 'entity_type' => 'taxonomy_term',
'type' => 'link',
]);
$fieldStorage->save(); $fieldStorage->save();
$field = $this->container->get('entity_type.manager')->getStorage('field_config')->create([ $field = $this->container->get('entity_type.manager')
'field_storage' => $fieldStorage, ->getStorage('field_config')
'bundle' => $this->testVocabulary->id(), ->create([
'settings' => [ 'field_storage' => $fieldStorage,
'title' => 'External URI', 'bundle' => $this->testVocabulary->id(),
'link_type' => LinkItemInterface::LINK_EXTERNAL, 'settings' => [
], 'title' => 'External URI',
]); 'link_type' => LinkItemInterface::LINK_EXTERNAL,
],
]);
$field->save(); $field->save();
// Create a test content type. // Create a test content type.
$this->testType = $this->container->get('entity_type.manager')->getStorage('node_type')->create([ $this->testType = $this->container->get('entity_type.manager')
'type' => 'test_type', ->getStorage('node_type')
'name' => 'Test Type', ->create([
]); 'type' => 'test_type',
'name' => 'Test Type',
]);
$this->testType->save(); $this->testType->save();
$this->createEntityReferenceField('node', 'test_type', 'field_member_of', 'Member Of', 'node', 'default', [], 2); $this->createEntityReferenceField('node', 'test_type', 'field_member_of', 'Member Of', 'node', 'default', [], 2);
$this->createEntityReferenceField('node', 'test_type', 'field_tags', 'Tags', 'taxonomy_term', 'default', [], 2); $this->createEntityReferenceField('node', 'test_type', 'field_tags', 'Tags', 'taxonomy_term', 'default', [], 2);
@ -192,7 +208,8 @@ EOD;
$destination->write($name, $source->read($name)); $destination->write($name, $source->read($name));
} }
$media_settings = $this->container->get('config.factory')->getEditable('media.settings'); $media_settings = $this->container->get('config.factory')
->getEditable('media.settings');
$media_settings->set('standalone_url', TRUE); $media_settings->set('standalone_url', TRUE);
$media_settings->save(TRUE); $media_settings->save(TRUE);
@ -218,11 +235,13 @@ EOD;
*/ */
protected function createImageTag() { protected function createImageTag() {
// 'Image' tag. // 'Image' tag.
$this->imageTerm = $this->container->get('entity_type.manager')->getStorage('taxonomy_term')->create([ $this->imageTerm = $this->container->get('entity_type.manager')
'name' => 'Image', ->getStorage('taxonomy_term')
'vid' => $this->testVocabulary->id(), ->create([
'field_external_uri' => [['uri' => "http://purl.org/coar/resource_type/c_c513"]], 'name' => 'Image',
]); 'vid' => $this->testVocabulary->id(),
'field_external_uri' => [['uri' => "http://purl.org/coar/resource_type/c_c513"]],
]);
$this->imageTerm->save(); $this->imageTerm->save();
} }
@ -233,11 +252,13 @@ EOD;
*/ */
protected function createPreservationMasterTag() { protected function createPreservationMasterTag() {
// 'Preservation Master' tag. // 'Preservation Master' tag.
$this->preservationMasterTerm = $this->container->get('entity_type.manager')->getStorage('taxonomy_term')->create([ $this->preservationMasterTerm = $this->container->get('entity_type.manager')
'name' => 'Preservation Master', ->getStorage('taxonomy_term')
'vid' => $this->testVocabulary->id(), ->create([
'field_external_uri' => [['uri' => "http://pcdm.org/use#PreservationMasterFile"]], 'name' => 'Preservation Master',
]); 'vid' => $this->testVocabulary->id(),
'field_external_uri' => [['uri' => "http://pcdm.org/use#PreservationMasterFile"]],
]);
$this->preservationMasterTerm->save(); $this->preservationMasterTerm->save();
} }
@ -245,7 +266,11 @@ EOD;
* Creates a test context. * Creates a test context.
*/ */
protected function createContext($label, $name) { protected function createContext($label, $name) {
$this->drupalPostForm('admin/structure/context/add', ['label' => $label, 'name' => $name], t('Save')); $this->drupalPostForm('admin/structure/context/add', [
'label' => $label,
'name' => $name,
],
t('Save'));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
} }
@ -263,7 +288,10 @@ EOD;
*/ */
protected function addPresetReaction($context_id, $reaction_type, $action_id) { protected function addPresetReaction($context_id, $reaction_type, $action_id) {
$this->drupalGet("admin/structure/context/$context_id/reaction/add/$reaction_type"); $this->drupalGet("admin/structure/context/$context_id/reaction/add/$reaction_type");
$this->getSession()->getPage()->findById("edit-reactions-$reaction_type-actions")->selectOption($action_id); $this->getSession()
->getPage()
->findById("edit-reactions-$reaction_type-actions")
->selectOption($action_id);
$this->getSession()->getPage()->pressButton(t('Save and continue')); $this->getSession()->getPage()->pressButton(t('Save and continue'));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
} }
@ -386,13 +414,15 @@ EOD;
*/ */
protected function makeMediaAndFile(AccountInterface $account) { protected function makeMediaAndFile(AccountInterface $account) {
// Make a file for the Media. // Make a file for the Media.
$file = $this->container->get('entity_type.manager')->getStorage('file')->create([ $file = $this->container->get('entity_type.manager')
'uid' => $account->id(), ->getStorage('file')
'uri' => "public://test_file.txt", ->create([
'filename' => "test_file.txt", 'uid' => $account->id(),
'filemime' => "text/plain", 'uri' => "public://test_file.txt",
'status' => FILE_STATUS_PERMANENT, 'filename' => "test_file.txt",
]); 'filemime' => "text/plain",
'status' => FILE_STATUS_PERMANENT,
]);
$file->save(); $file->save();
// Get the source field for the media. // Get the source field for the media.
@ -400,11 +430,13 @@ EOD;
$source_field = $type_configuration['source_field']; $source_field = $type_configuration['source_field'];
// Make the media for the referencer. // Make the media for the referencer.
$media = $this->container->get('entity_type.manager')->getStorage('media')->create([ $media = $this->container->get('entity_type.manager')
'bundle' => $this->testMediaType->id(), ->getStorage('media')
'name' => 'Media', ->create([
"$source_field" => [$file->id()], 'bundle' => $this->testMediaType->id(),
]); 'name' => 'Media',
"$source_field" => [$file->id()],
]);
$media->save(); $media->save();
return [$file, $media]; return [$file, $media];

2
tests/src/Functional/IslandoraSettingsFormTest.php

@ -3,7 +3,7 @@
namespace Drupal\Tests\islandora\Functional; namespace Drupal\Tests\islandora\Functional;
/** /**
* Class IslandoraSettingsFormTest. * Tests Islandora Settings Form.
* *
* @package Drupal\Tests\islandora\Functional * @package Drupal\Tests\islandora\Functional
* @group islandora * @group islandora

2
tests/src/Functional/JsonldTypeAlterReactionTest.php

@ -3,7 +3,7 @@
namespace Drupal\Tests\islandora\Functional; namespace Drupal\Tests\islandora\Functional;
/** /**
* Class JsonldTypeAlterReactionTest. * Tests Jsonld Alter Reaction.
* *
* @package Drupal\Tests\islandora\Functional * @package Drupal\Tests\islandora\Functional
* @group islandora * @group islandora

49
tests/src/Functional/NodeHasTermTest.php

@ -30,11 +30,13 @@ class NodeHasTermTest extends IslandoraFunctionalTestBase {
public function testNodeHasTerm() { public function testNodeHasTerm() {
// Create a new node with the tag. // Create a new node with the tag.
$node = $this->container->get('entity_type.manager')->getStorage('node')->create([ $node = $this->container->get('entity_type.manager')
'type' => 'test_type', ->getStorage('node')
'title' => 'Test Node', ->create([
'field_tags' => [$this->imageTerm->id()], 'type' => 'test_type',
]); 'title' => 'Test Node',
'field_tags' => [$this->imageTerm->id()],
]);
// Create and execute the condition. // Create and execute the condition.
$condition_manager = $this->container->get('plugin.manager.condition'); $condition_manager = $this->container->get('plugin.manager.condition');
@ -48,20 +50,24 @@ class NodeHasTermTest extends IslandoraFunctionalTestBase {
$this->assertTrue($condition->execute(), "Condition should pass if node has the term"); $this->assertTrue($condition->execute(), "Condition should pass if node has the term");
// Create a new node without the tag. // Create a new node without the tag.
$node = $this->container->get('entity_type.manager')->getStorage('node')->create([ $node = $this->container->get('entity_type.manager')
'type' => 'test_type', ->getStorage('node')
'title' => 'Test Node', ->create([
]); 'type' => 'test_type',
'title' => 'Test Node',
]);
$condition->setContextValue('node', $node); $condition->setContextValue('node', $node);
$this->assertFalse($condition->execute(), "Condition should fail if the node does not have any terms"); $this->assertFalse($condition->execute(), "Condition should fail if the node does not have any terms");
// Create a new node with the wrong tag. // Create a new node with the wrong tag.
$node = $this->container->get('entity_type.manager')->getStorage('node')->create([ $node = $this->container->get('entity_type.manager')
'type' => 'test_type', ->getStorage('node')
'title' => 'Test Node', ->create([
'field_tags' => [$this->preservationMasterTerm->id()], 'type' => 'test_type',
]); 'title' => 'Test Node',
'field_tags' => [$this->preservationMasterTerm->id()],
]);
$condition->setContextValue('node', $node); $condition->setContextValue('node', $node);
$this->assertFalse($condition->execute(), "Condition should fail if the node has terms, but not the one we want."); $this->assertFalse($condition->execute(), "Condition should fail if the node has terms, but not the one we want.");
@ -90,11 +96,16 @@ class NodeHasTermTest extends IslandoraFunctionalTestBase {
$this->assertTrue($condition->execute(), "Condition should pass if has one of two terms using OR logic."); $this->assertTrue($condition->execute(), "Condition should pass if has one of two terms using OR logic.");
// Create a node with both tags and try it with OR. // Create a node with both tags and try it with OR.
$node = $this->container->get('entity_type.manager')->getStorage('node')->create([ $node = $this->container->get('entity_type.manager')
'type' => 'test_type', ->getStorage('node')
'title' => 'Test Node', ->create([
'field_tags' => [$this->imageTerm->id(), $this->preservationMasterTerm->id()], 'type' => 'test_type',
]); 'title' => 'Test Node',
'field_tags' => [
$this->imageTerm->id(),
$this->preservationMasterTerm->id(),
],
]);
$condition->setContextValue('node', $node); $condition->setContextValue('node', $node);
$this->assertTrue($condition->execute(), "Condition should pass if node has both terms using OR logic"); $this->assertTrue($condition->execute(), "Condition should pass if node has both terms using OR logic");

155
tests/src/Kernel/FedoraAdapterTest.php

@ -2,9 +2,9 @@
namespace Drupal\Tests\islandora\Kernel; namespace Drupal\Tests\islandora\Kernel;
use Drupal\islandora\Flysystem\Adapter\FedoraAdapter;
use GuzzleHttp\Psr7; use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Response;
use Drupal\islandora\Flysystem\Adapter\FedoraAdapter;
use Islandora\Chullo\IFedoraApi; use Islandora\Chullo\IFedoraApi;
use League\Flysystem\Config; use League\Flysystem\Config;
use Prophecy\Argument; use Prophecy\Argument;
@ -31,7 +31,8 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$prophecy->getResource('')->willReturn($response); $prophecy->getResource('')->willReturn($response);
$api = $prophecy->reveal(); $api = $prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)->reveal(); $mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)
->reveal();
return new FedoraAdapter($api, $mime_guesser); return new FedoraAdapter($api, $mime_guesser);
} }
@ -42,8 +43,13 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
protected function createAdapterForFile() { protected function createAdapterForFile() {
$prophecy = $this->prophesize(Response::class); $prophecy = $this->prophesize(Response::class);
$prophecy->getStatusCode()->willReturn(200); $prophecy->getStatusCode()->willReturn(200);
$prophecy->getHeader('Last-Modified')->willReturn(["Wed, 25 Jul 2018 17:42:04 GMT"]); $prophecy->getHeader('Last-Modified')
$prophecy->getHeader('Link')->willReturn(['<http://www.w3.org/ns/ldp#Resource>;rel="type"', '<http://www.w3.org/ns/ldp#NonRDFSource>;rel="type"']); ->willReturn(["Wed, 25 Jul 2018 17:42:04 GMT"]);
$prophecy->getHeader('Link')
->willReturn([
'<http://www.w3.org/ns/ldp#Resource>;rel="type"',
'<http://www.w3.org/ns/ldp#NonRDFSource>;rel="type"',
]);
$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")]);
$prophecy->getBody()->willReturn(PSR7\stream_for("DERP")); $prophecy->getBody()->willReturn(PSR7\stream_for("DERP"));
@ -54,7 +60,8 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$prophecy->getResource('')->willReturn($response); $prophecy->getResource('')->willReturn($response);
$api = $prophecy->reveal(); $api = $prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)->reveal(); $mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)
->reveal();
return new FedoraAdapter($api, $mime_guesser); return new FedoraAdapter($api, $mime_guesser);
} }
@ -65,15 +72,21 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
protected function createAdapterForDirectory() { protected function createAdapterForDirectory() {
$prophecy = $this->prophesize(Response::class); $prophecy = $this->prophesize(Response::class);
$prophecy->getStatusCode()->willReturn(200); $prophecy->getStatusCode()->willReturn(200);
$prophecy->getHeader('Last-Modified')->willReturn(["Wed, 25 Jul 2018 17:42:04 GMT"]); $prophecy->getHeader('Last-Modified')
$prophecy->getHeader('Link')->willReturn(['<http://www.w3.org/ns/ldp#Resource>;rel="type"', '<http://www.w3.org/ns/ldp#RDFSource>;rel="type"']); ->willReturn(["Wed, 25 Jul 2018 17:42:04 GMT"]);
$prophecy->getHeader('Link')
->willReturn([
'<http://www.w3.org/ns/ldp#Resource>;rel="type"',
'<http://www.w3.org/ns/ldp#RDFSource>;rel="type"',
]);
$response = $prophecy->reveal(); $response = $prophecy->reveal();
$prophecy = $this->prophesize(IFedoraApi::class); $prophecy = $this->prophesize(IFedoraApi::class);
$prophecy->getResourceHeaders('')->willReturn($response); $prophecy->getResourceHeaders('')->willReturn($response);
$api = $prophecy->reveal(); $api = $prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)->reveal(); $mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)
->reveal();
return new FedoraAdapter($api, $mime_guesser); return new FedoraAdapter($api, $mime_guesser);
} }
@ -87,16 +100,22 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$prophecy = $this->prophesize(Response::class); $prophecy = $this->prophesize(Response::class);
$prophecy->getStatusCode()->willReturn(201); $prophecy->getStatusCode()->willReturn(201);
$fedora_prophecy->createVersion('', Argument::any(), NULL, $fedora_prophecy->createVersion('', Argument::any(), NULL,
Argument::any())->willReturn($prophecy->reveal()); Argument::any())->willReturn($prophecy->reveal());
$prophecy = $this->prophesize(Response::class); $prophecy = $this->prophesize(Response::class);
$prophecy->getStatusCode()->willReturn(201); $prophecy->getStatusCode()->willReturn(201);
$fedora_prophecy->saveResource('', '', Argument::any())->willReturn($prophecy->reveal()); $fedora_prophecy->saveResource('', '', Argument::any())
->willReturn($prophecy->reveal());
$prophecy = $this->prophesize(Response::class); $prophecy = $this->prophesize(Response::class);
$prophecy->getStatusCode()->willReturn(200); $prophecy->getStatusCode()->willReturn(200);
$prophecy->getHeader('Last-Modified')->willReturn(["Wed, 25 Jul 2018 17:42:04 GMT"]); $prophecy->getHeader('Last-Modified')
$prophecy->getHeader('Link')->willReturn(['<http://www.w3.org/ns/ldp#Resource>;rel="type"', '<http://www.w3.org/ns/ldp#NonRDFSource>;rel="type"']); ->willReturn(["Wed, 25 Jul 2018 17:42:04 GMT"]);
$prophecy->getHeader('Link')
->willReturn([
'<http://www.w3.org/ns/ldp#Resource>;rel="type"',
'<http://www.w3.org/ns/ldp#NonRDFSource>;rel="type"',
]);
$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")]);
$prophecy->getBody()->willReturn(PSR7\stream_for("DERP")); $prophecy->getBody()->willReturn(PSR7\stream_for("DERP"));
@ -105,7 +124,8 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)->reveal(); $mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)
->reveal();
return new FedoraAdapter($api, $mime_guesser); return new FedoraAdapter($api, $mime_guesser);
} }
@ -122,11 +142,13 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$prophecy = $this->prophesize(Response::class); $prophecy = $this->prophesize(Response::class);
$prophecy->getStatusCode()->willReturn(500); $prophecy->getStatusCode()->willReturn(500);
$fedora_prophecy->saveResource('', '', Argument::any())->willReturn($prophecy->reveal()); $fedora_prophecy->saveResource('', '', Argument::any())
->willReturn($prophecy->reveal());
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)->reveal(); $mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)
->reveal();
return new FedoraAdapter($api, $mime_guesser); return new FedoraAdapter($api, $mime_guesser);
} }
@ -144,14 +166,20 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$prophecy = $this->prophesize(Response::class); $prophecy = $this->prophesize(Response::class);
$prophecy->getStatusCode()->willReturn(200); $prophecy->getStatusCode()->willReturn(200);
$prophecy->getHeader('Last-Modified')->willReturn(["Wed, 25 Jul 2018 17:42:04 GMT"]); $prophecy->getHeader('Last-Modified')
$prophecy->getHeader('Link')->willReturn(['<http://www.w3.org/ns/ldp#Resource>;rel="type"', '<http://www.w3.org/ns/ldp#RDFSource>;rel="type"']); ->willReturn(["Wed, 25 Jul 2018 17:42:04 GMT"]);
$prophecy->getHeader('Link')
->willReturn([
'<http://www.w3.org/ns/ldp#Resource>;rel="type"',
'<http://www.w3.org/ns/ldp#RDFSource>;rel="type"',
]);
$fedora_prophecy->getResourceHeaders('')->willReturn($prophecy->reveal()); $fedora_prophecy->getResourceHeaders('')->willReturn($prophecy->reveal());
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)->reveal(); $mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)
->reveal();
return new FedoraAdapter($api, $mime_guesser); return new FedoraAdapter($api, $mime_guesser);
} }
@ -169,7 +197,8 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$fedora_prophecy->getResourceHeaders('')->willReturn($prophecy->reveal()); $fedora_prophecy->getResourceHeaders('')->willReturn($prophecy->reveal());
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)->reveal(); $mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)
->reveal();
return new FedoraAdapter($api, $mime_guesser); return new FedoraAdapter($api, $mime_guesser);
} }
@ -187,7 +216,8 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)->reveal(); $mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)
->reveal();
return new FedoraAdapter($api, $mime_guesser); return new FedoraAdapter($api, $mime_guesser);
} }
@ -203,18 +233,22 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$head_prophecy = $this->prophesize(Response::class); $head_prophecy = $this->prophesize(Response::class);
$head_prophecy->getStatusCode()->willReturn(410); $head_prophecy->getStatusCode()->willReturn(410);
$head_prophecy->getHeader('Link')->willReturn('<some-path-to-a-tombstone>; rel="hasTombstone"'); $head_prophecy->getHeader('Link')
->willReturn('<some-path-to-a-tombstone>; rel="hasTombstone"');
$tombstone_prophecy = $this->prophesize(Response::class); $tombstone_prophecy = $this->prophesize(Response::class);
$tombstone_prophecy->getStatusCode()->willReturn(204); $tombstone_prophecy->getStatusCode()->willReturn(204);
$fedora_prophecy->deleteResource('')->willReturn($prophecy->reveal()); $fedora_prophecy->deleteResource('')->willReturn($prophecy->reveal());
$fedora_prophecy->getResourceHeaders('')->willReturn($head_prophecy->reveal()); $fedora_prophecy->getResourceHeaders('')
$fedora_prophecy->deleteResource('some-path-to-a-tombstone')->willReturn($tombstone_prophecy->reveal()); ->willReturn($head_prophecy->reveal());
$fedora_prophecy->deleteResource('some-path-to-a-tombstone')
->willReturn($tombstone_prophecy->reveal());
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)->reveal(); $mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)
->reveal();
return new FedoraAdapter($api, $mime_guesser); return new FedoraAdapter($api, $mime_guesser);
} }
@ -230,18 +264,22 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$head_prophecy = $this->prophesize(Response::class); $head_prophecy = $this->prophesize(Response::class);
$head_prophecy->getStatusCode()->willReturn(410); $head_prophecy->getStatusCode()->willReturn(410);
$head_prophecy->getHeader('Link')->willReturn('<some-path-to-a-tombstone>; rel="hasTombstone"'); $head_prophecy->getHeader('Link')
->willReturn('<some-path-to-a-tombstone>; rel="hasTombstone"');
$tombstone_prophecy = $this->prophesize(Response::class); $tombstone_prophecy = $this->prophesize(Response::class);
$tombstone_prophecy->getStatusCode()->willReturn(500); $tombstone_prophecy->getStatusCode()->willReturn(500);
$fedora_prophecy->deleteResource('')->willReturn($prophecy->reveal()); $fedora_prophecy->deleteResource('')->willReturn($prophecy->reveal());
$fedora_prophecy->getResourceHeaders('')->willReturn($head_prophecy->reveal()); $fedora_prophecy->getResourceHeaders('')
$fedora_prophecy->deleteResource('some-path-to-a-tombstone')->willReturn($tombstone_prophecy->reveal()); ->willReturn($head_prophecy->reveal());
$fedora_prophecy->deleteResource('some-path-to-a-tombstone')
->willReturn($tombstone_prophecy->reveal());
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)->reveal(); $mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)
->reveal();
return new FedoraAdapter($api, $mime_guesser); return new FedoraAdapter($api, $mime_guesser);
} }
@ -414,7 +452,8 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
public function testWriteFail() { public function testWriteFail() {
$adapter = $this->createAdapterForWriteFail(); $adapter = $this->createAdapterForWriteFail();
$this->assertTrue($adapter->write('', '', $this->prophesize(Config::class)->reveal()) == FALSE, "write() must return FALSE on non-201 or non-204"); $this->assertTrue($adapter->write('', '', $this->prophesize(Config::class)
->reveal()) == FALSE, "write() must return FALSE on non-201 or non-204");
} }
/** /**
@ -423,7 +462,8 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
public function testWrite() { public function testWrite() {
$adapter = $this->createAdapterForWrite(); $adapter = $this->createAdapterForWrite();
$metadata = $adapter->write('', '', $this->prophesize(Config::class)->reveal()); $metadata = $adapter->write('', '', $this->prophesize(Config::class)
->reveal());
$this->assertFileMetadata($metadata); $this->assertFileMetadata($metadata);
} }
@ -433,7 +473,8 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
public function testWriteStreamFail() { public function testWriteStreamFail() {
$adapter = $this->createAdapterForWriteFail(); $adapter = $this->createAdapterForWriteFail();
$this->assertTrue($adapter->writeStream('', '', $this->prophesize(Config::class)->reveal()) == FALSE, "writeStream() must return FALSE on non-201 or non-204"); $this->assertTrue($adapter->writeStream('', '', $this->prophesize(Config::class)
->reveal()) == FALSE, "writeStream() must return FALSE on non-201 or non-204");
} }
/** /**
@ -442,7 +483,8 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
public function testWriteStream() { public function testWriteStream() {
$adapter = $this->createAdapterForWrite(); $adapter = $this->createAdapterForWrite();
$metadata = $adapter->writeStream('', '', $this->prophesize(Config::class)->reveal()); $metadata = $adapter->writeStream('', '', $this->prophesize(Config::class)
->reveal());
$this->assertFileMetadata($metadata); $this->assertFileMetadata($metadata);
} }
@ -452,7 +494,8 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
public function testUpdateFail() { public function testUpdateFail() {
$adapter = $this->createAdapterForWriteFail(); $adapter = $this->createAdapterForWriteFail();
$this->assertTrue($adapter->update('', '', $this->prophesize(Config::class)->reveal()) == FALSE, "write() must return FALSE on non-201 or non-204"); $this->assertTrue($adapter->update('', '', $this->prophesize(Config::class)
->reveal()) == FALSE, "write() must return FALSE on non-201 or non-204");
} }
/** /**
@ -461,7 +504,8 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
public function testUpdate() { public function testUpdate() {
$adapter = $this->createAdapterForWrite(); $adapter = $this->createAdapterForWrite();
$metadata = $adapter->update('', '', $this->prophesize(Config::class)->reveal()); $metadata = $adapter->update('', '', $this->prophesize(Config::class)
->reveal());
$this->assertFileMetadata($metadata); $this->assertFileMetadata($metadata);
} }
@ -471,7 +515,8 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
public function testUpdateStreamFail() { public function testUpdateStreamFail() {
$adapter = $this->createAdapterForWriteFail(); $adapter = $this->createAdapterForWriteFail();
$this->assertTrue($adapter->updateStream('', '', $this->prophesize(Config::class)->reveal()) == FALSE, "writeStream() must return FALSE on non-201 or non-204"); $this->assertTrue($adapter->updateStream('', '', $this->prophesize(Config::class)
->reveal()) == FALSE, "writeStream() must return FALSE on non-201 or non-204");
} }
/** /**
@ -480,7 +525,8 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
public function testUpdateStream() { public function testUpdateStream() {
$adapter = $this->createAdapterForWrite(); $adapter = $this->createAdapterForWrite();
$metadata = $adapter->updateStream('', '', $this->prophesize(Config::class)->reveal()); $metadata = $adapter->updateStream('', '', $this->prophesize(Config::class)
->reveal());
$this->assertFileMetadata($metadata); $this->assertFileMetadata($metadata);
} }
@ -555,8 +601,13 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
public function testRename() { public function testRename() {
$prophecy = $this->prophesize(Response::class); $prophecy = $this->prophesize(Response::class);
$prophecy->getStatusCode()->willReturn(200); $prophecy->getStatusCode()->willReturn(200);
$prophecy->getHeader('Last-Modified')->willReturn(["Wed, 25 Jul 2018 17:42:04 GMT"]); $prophecy->getHeader('Last-Modified')
$prophecy->getHeader('Link')->willReturn(['<http://www.w3.org/ns/ldp#Resource>;rel="type"', '<http://www.w3.org/ns/ldp#NonRDFSource>;rel="type"']); ->willReturn(["Wed, 25 Jul 2018 17:42:04 GMT"]);
$prophecy->getHeader('Link')
->willReturn([
'<http://www.w3.org/ns/ldp#Resource>;rel="type"',
'<http://www.w3.org/ns/ldp#NonRDFSource>;rel="type"',
]);
$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")]);
$prophecy->getBody()->willReturn(PSR7\stream_for("DERP")); $prophecy->getBody()->willReturn(PSR7\stream_for("DERP"));
@ -573,21 +624,27 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$timestamp = $date->format("D, d M Y H:i:s O"); $timestamp = $date->format("D, d M Y H:i:s O");
$fedora_prophecy->createVersion('', $fedora_prophecy->createVersion('',
Argument::any(), NULL, Argument::any(), NULL,
Argument::any())->willReturn($prophecy->reveal()); Argument::any())->willReturn($prophecy->reveal());
$prophecy = $this->prophesize(Response::class); $prophecy = $this->prophesize(Response::class);
$prophecy->getStatusCode()->willReturn(201); $prophecy->getStatusCode()->willReturn(201);
$fedora_prophecy->saveResource(Argument::any(), Argument::any(), Argument::any())->willReturn($response); $fedora_prophecy->saveResource(Argument::any(), Argument::any(), Argument::any())
->willReturn($response);
$prophecy = $this->prophesize(Response::class); $prophecy = $this->prophesize(Response::class);
$prophecy->getStatusCode()->willReturn(200); $prophecy->getStatusCode()->willReturn(200);
$prophecy->getHeader('Last-Modified')->willReturn(["Wed, 25 Jul 2018 17:42:04 GMT"]); $prophecy->getHeader('Last-Modified')
$prophecy->getHeader('Link')->willReturn(['<http://www.w3.org/ns/ldp#Resource>;rel="type"', '<http://www.w3.org/ns/ldp#NonRDFSource>;rel="type"']); ->willReturn(["Wed, 25 Jul 2018 17:42:04 GMT"]);
$prophecy->getHeader('Link')->willReturn([
'<http://www.w3.org/ns/ldp#Resource>;rel="type"',
'<http://www.w3.org/ns/ldp#NonRDFSource>;rel="type"',
]);
$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")]);
$response = $prophecy->reveal(); $response = $prophecy->reveal();
$fedora_prophecy->getResourceHeaders(Argument::any())->willReturn($response); $fedora_prophecy->getResourceHeaders(Argument::any())
->willReturn($response);
$prophecy = $this->prophesize(Response::class); $prophecy = $this->prophesize(Response::class);
$prophecy->getStatusCode()->willReturn(204); $prophecy->getStatusCode()->willReturn(204);
@ -597,7 +654,8 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)->reveal(); $mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)
->reveal();
$adapter = new FedoraAdapter($api, $mime_guesser); $adapter = new FedoraAdapter($api, $mime_guesser);
@ -616,11 +674,13 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)->reveal(); $mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)
->reveal();
$adapter = new FedoraAdapter($api, $mime_guesser); $adapter = new FedoraAdapter($api, $mime_guesser);
$this->assertTrue($adapter->createDir('', $this->prophesize(Config::class)->reveal()) == FALSE, "createDir() must return FALSE on fail"); $this->assertTrue($adapter->createDir('', $this->prophesize(Config::class)
->reveal()) == FALSE, "createDir() must return FALSE on fail");
} }
/** /**
@ -629,7 +689,8 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
public function testCreateDir() { public function testCreateDir() {
$adapter = $this->createAdapterForCreateDir(); $adapter = $this->createAdapterForCreateDir();
$metadata = $adapter->createDir('', $this->prophesize(Config::class)->reveal()); $metadata = $adapter->createDir('', $this->prophesize(Config::class)
->reveal());
$this->assertDirMetadata($metadata); $this->assertDirMetadata($metadata);
} }

2
tests/src/Kernel/GeminiClientFactoryTest.php

@ -10,7 +10,7 @@ use Prophecy\Argument;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
/** /**
* Class GeminiClientFactoryTest. * Tests GeminiClientFactory.
* *
* @package Drupal\Tests\islandora\Kernel * @package Drupal\Tests\islandora\Kernel
* @group islandora * @group islandora

9
tests/src/Kernel/GeminiLookupTest.php

@ -4,10 +4,10 @@ namespace Drupal\Tests\islandora\Kernel;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\file\FileInterface; use Drupal\file\FileInterface;
use Drupal\media\MediaInterface;
use Drupal\islandora\GeminiLookup; use Drupal\islandora\GeminiLookup;
use Drupal\islandora\MediaSource\MediaSourceService; use Drupal\islandora\MediaSource\MediaSourceService;
use Drupal\jwt\Authentication\Provider\JwtAuth; use Drupal\jwt\Authentication\Provider\JwtAuth;
use Drupal\media\MediaInterface;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Response;
use Islandora\Crayfish\Commons\Client\GeminiClient; use Islandora\Crayfish\Commons\Client\GeminiClient;
@ -16,7 +16,7 @@ use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
* Class GeminiLookupTest. * Tests Gemini Lookup.
* *
* @group islandora * @group islandora
* @coversDefaultClass \Drupal\islandora\GeminiLookup * @coversDefaultClass \Drupal\islandora\GeminiLookup
@ -125,7 +125,10 @@ class GeminiLookupTest extends IslandoraKernelTestBase {
private function mockGeminiClientForSuccess() { private function mockGeminiClientForSuccess() {
$prophecy = $this->prophesize(GeminiClient::class); $prophecy = $this->prophesize(GeminiClient::class);
$prophecy->getUrls(Argument::any(), Argument::any()) $prophecy->getUrls(Argument::any(), Argument::any())
->willReturn(['drupal' => '', 'fedora' => 'http://localhost:8080/fcrepo/rest/abc123']); ->willReturn([
'drupal' => '',
'fedora' => 'http://localhost:8080/fcrepo/rest/abc123',
]);
$this->geminiClient = $prophecy->reveal(); $this->geminiClient = $prophecy->reveal();
} }

Loading…
Cancel
Save