Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version files #793

Merged
merged 10 commits into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Flysystem/Adapter/FedoraAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ public function write($path, $contents, Config $config) {
$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");
Expand Down
15 changes: 15 additions & 0 deletions tests/src/Kernel/FedoraAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ protected function createAdapterForDirectory() {
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);

Expand Down Expand Up @@ -111,6 +115,9 @@ protected function createAdapterForWrite() {
*/
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);
Expand Down Expand Up @@ -562,6 +569,14 @@ public function testRename() {
$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);
Expand Down