|
|
@ -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"); |
|
|
|