Browse Source

Fix tests

pull/940/head
Jared Whiklo 2 years ago committed by Seth Shaw
parent
commit
a02738bd3f
  1. 87
      tests/src/Kernel/FedoraAdapterTest.php
  2. 8
      tests/src/Kernel/FedoraPluginTest.php

87
tests/src/Kernel/FedoraAdapterTest.php

@ -2,12 +2,13 @@
namespace Drupal\Tests\islandora\Kernel; namespace Drupal\Tests\islandora\Kernel;
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;
use Islandora\Chullo\IFedoraApi; use Islandora\Chullo\IFedoraApi;
use League\Flysystem\Config; use League\Flysystem\Config;
use Prophecy\Argument; use Prophecy\Argument;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface; use Symfony\Component\Mime\MimeTypeGuesserInterface;
/** /**
* Tests the Fedora adapter for Flysystem. * Tests the Fedora adapter for Flysystem.
@ -17,6 +18,30 @@ use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface;
*/ */
class FedoraAdapterTest extends IslandoraKernelTestBase { class FedoraAdapterTest extends IslandoraKernelTestBase {
/**
* A mimetype guesser prophecy.
*
* @var \Prophecy\Prophecy\ObjectProphecy
*/
private $mime_guesser;
/**
* A logger prophecy.
*
* @var \Prophecy\Prophecy\ObjectProphecy
*/
private $logger;
/**
* @inheritdoc
*/
public function setUp() {
parent::setUp();
$this->mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)
->reveal();
$this->logger = $this->prophesize(LoggerChannelInterface::class)->reveal();
}
/** /**
* Shared functionality for an adapter. * Shared functionality for an adapter.
*/ */
@ -55,10 +80,7 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$prophecy->getResource('', ['Connection' => 'close'])->willReturn($response); $prophecy->getResource('', ['Connection' => 'close'])->willReturn($response);
$api = $prophecy->reveal(); $api = $prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class) return new FedoraAdapter($api, $this->mime_guesser, $this->logger);
->reveal();
return new FedoraAdapter($api, $mime_guesser);
} }
/** /**
@ -73,10 +95,7 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$prophecy->getResource('', ['Connection' => 'close'])->willReturn($response); $prophecy->getResource('', ['Connection' => 'close'])->willReturn($response);
$api = $prophecy->reveal(); $api = $prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class) return new FedoraAdapter($api, $this->mime_guesser, $this->logger);
->reveal();
return new FedoraAdapter($api, $mime_guesser);
} }
/** /**
@ -98,10 +117,7 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$prophecy->getResourceHeaders('', ['Connection' => 'close'])->willReturn($response); $prophecy->getResourceHeaders('', ['Connection' => 'close'])->willReturn($response);
$api = $prophecy->reveal(); $api = $prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class) return new FedoraAdapter($api, $this->mime_guesser, $this->logger);
->reveal();
return new FedoraAdapter($api, $mime_guesser);
} }
/** /**
@ -126,10 +142,7 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class) return new FedoraAdapter($api, $this->mime_guesser, $this->logger);
->reveal();
return new FedoraAdapter($api, $mime_guesser);
} }
/** /**
@ -149,10 +162,7 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class) return new FedoraAdapter($api, $this->mime_guesser, $this->logger);
->reveal();
return new FedoraAdapter($api, $mime_guesser);
} }
/** /**
@ -180,10 +190,7 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class) return new FedoraAdapter($api, $this->mime_guesser, $this->logger);
->reveal();
return new FedoraAdapter($api, $mime_guesser);
} }
/** /**
@ -199,10 +206,7 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$fedora_prophecy->getResourceHeaders('', ['Connection' => 'close'])->willReturn($prophecy->reveal()); $fedora_prophecy->getResourceHeaders('', ['Connection' => 'close'])->willReturn($prophecy->reveal());
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class) return new FedoraAdapter($api, $this->mime_guesser, $this->logger);
->reveal();
return new FedoraAdapter($api, $mime_guesser);
} }
/** /**
@ -218,10 +222,7 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class) return new FedoraAdapter($api, $this->mime_guesser, $this->logger);
->reveal();
return new FedoraAdapter($api, $mime_guesser);
} }
/** /**
@ -249,10 +250,7 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class) return new FedoraAdapter($api, $this->mime_guesser, $this->logger);
->reveal();
return new FedoraAdapter($api, $mime_guesser);
} }
/** /**
@ -280,10 +278,7 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class) return new FedoraAdapter($api, $this->mime_guesser, $this->logger);
->reveal();
return new FedoraAdapter($api, $mime_guesser);
} }
/** /**
@ -644,10 +639,7 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class) $adapter = new FedoraAdapter($api, $this->mime_guesser, $this->logger);
->reveal();
$adapter = new FedoraAdapter($api, $mime_guesser);
$this->assertTrue($adapter->rename('', '') == TRUE, "rename() must return TRUE on success"); $this->assertTrue($adapter->rename('', '') == TRUE, "rename() must return TRUE on success");
} }
@ -664,10 +656,7 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$api = $fedora_prophecy->reveal(); $api = $fedora_prophecy->reveal();
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class) $adapter = new FedoraAdapter($api, $this->mime_guesser, $this->logger);
->reveal();
$adapter = new FedoraAdapter($api, $mime_guesser);
$this->assertTrue($adapter->createDir('', $this->prophesize(Config::class) $this->assertTrue($adapter->createDir('', $this->prophesize(Config::class)
->reveal()) == FALSE, "createDir() must return FALSE on fail"); ->reveal()) == FALSE, "createDir() must return FALSE on fail");

8
tests/src/Kernel/FedoraPluginTest.php

@ -2,11 +2,12 @@
namespace Drupal\Tests\islandora\Kernel; namespace Drupal\Tests\islandora\Kernel;
use Drupal\Core\Logger\LoggerChannelInterface;
use Drupal\islandora\Flysystem\Fedora; use Drupal\islandora\Flysystem\Fedora;
use League\Flysystem\AdapterInterface;
use Islandora\Chullo\IFedoraApi; use Islandora\Chullo\IFedoraApi;
use League\Flysystem\AdapterInterface;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface; use Symfony\Component\Mime\MimeTypeGuesserInterface;
/** /**
* Tests the Fedora plugin for Flysystem. * Tests the Fedora plugin for Flysystem.
@ -32,8 +33,9 @@ class FedoraPluginTest extends IslandoraKernelTestBase {
$mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)->reveal(); $mime_guesser = $this->prophesize(MimeTypeGuesserInterface::class)->reveal();
$language_manager = $this->container->get('language_manager'); $language_manager = $this->container->get('language_manager');
$logger = $this->prophesize(LoggerChannelInterface::class)->reveal();
return new Fedora($api, $mime_guesser, $language_manager); return new Fedora($api, $mime_guesser, $language_manager, $logger);
} }
/** /**

Loading…
Cancel
Save