Browse Source

improve header check in the case that it fails and update tests since they now make another fedora call

pull/793/head
elizoller 4 years ago
parent
commit
316917a12c
  1. 3
      src/Flysystem/Adapter/FedoraAdapter.php
  2. 15
      tests/src/Kernel/FedoraAdapterTest.php

3
src/Flysystem/Adapter/FedoraAdapter.php

@ -253,7 +253,8 @@ class FedoraAdapter implements AdapterInterface {
$headers = [
'Content-Type' => $this->mimeTypeGuesser->guess($path),
];
if ($this->has($path)) {
$heads_response = $this->fedora->getResourceHeaders($path);
if (isset($heads_response) && $heads_response->getStatusCode() == 200) {
$fedora_url = $path;
$date = new DateTime();
$timestamp = $date->format("D, d M Y H:i:s O");

15
tests/src/Kernel/FedoraAdapterTest.php

@ -84,6 +84,10 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
protected function createAdapterForWrite() {
$fedora_prophecy = $this->prophesize(IFedoraApi::class);
$prophecy = $this->prophesize(Response::class);
$prophecy->getStatusCode()->willReturn(201);
$fedora_prophecy->createVersion('', Argument::any(), NULL,
Argument::any())->willReturn($prophecy->reveal());
$prophecy = $this->prophesize(Response::class);
$prophecy->getStatusCode()->willReturn(201);
@ -111,6 +115,9 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
*/
protected function createAdapterForWriteFail() {
$fedora_prophecy = $this->prophesize(IFedoraApi::class);
$prophecy = $this->prophesize(Response::class);
$prophecy->getStatusCode()->willReturn(500);
$fedora_prophecy->getResourceHeaders('')->willReturn($prophecy->reveal());
$prophecy = $this->prophesize(Response::class);
$prophecy->getStatusCode()->willReturn(500);
@ -562,6 +569,14 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$prophecy->getStatusCode()->willReturn(201);
$response = $prophecy->reveal();
$date = new \DateTime();
$timestamp = $date->format("D, d M Y H:i:s O");
$fedora_prophecy->createVersion('',
Argument::any(), NULL,
Argument::any())->willReturn($prophecy->reveal());
$prophecy = $this->prophesize(Response::class);
$prophecy->getStatusCode()->willReturn(201);
$fedora_prophecy->saveResource(Argument::any(), Argument::any(), Argument::any())->willReturn($response);
$prophecy = $this->prophesize(Response::class);

Loading…
Cancel
Save