Skip to content

Commit

Permalink
Add trailing slash for deleteDir
Browse files Browse the repository at this point in the history
  • Loading branch information
vasileknik76 authored and Nikita Vasilchenko committed Sep 3, 2020
1 parent b5c3c75 commit eb0c593
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/WebDAVAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ public function createDir($path, Config $config)
*/
public function deleteDir($dirname)
{
return $this->delete($dirname);
$path = rtrim($dirname, $this->pathSeparator) . $this->pathSeparator;
return $this->delete($path);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/WebDAVTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function testRenameFailException()
public function testDeleteDir()
{
$mock = $this->getClient();
$mock->shouldReceive('request')->with('DELETE', 'some/dirname')->once()->andReturn(['statusCode' => 200]);
$mock->shouldReceive('request')->with('DELETE', 'some/dirname/')->once()->andReturn(['statusCode' => 200]);
$adapter = new WebDAVAdapter($mock);
$result = $adapter->deleteDir('some/dirname');
$this->assertTrue($result);
Expand All @@ -193,7 +193,7 @@ public function testDeleteDir()
public function testDeleteDirFailNotFound()
{
$mock = $this->getClient();
$mock->shouldReceive('request')->with('DELETE', 'some/dirname')->once()->andThrow('Sabre\DAV\Exception\NotFound');
$mock->shouldReceive('request')->with('DELETE', 'some/dirname/')->once()->andThrow('Sabre\DAV\Exception\NotFound');
$adapter = new WebDAVAdapter($mock);
$result = $adapter->deleteDir('some/dirname');
$this->assertFalse($result);
Expand All @@ -202,7 +202,7 @@ public function testDeleteDirFailNotFound()
public function testDeleteDirFailNot200Status()
{
$mock = $this->getClient();
$mock->shouldReceive('request')->with('DELETE', 'some/dirname')->once()->andReturn(['statusCode' => 403]);
$mock->shouldReceive('request')->with('DELETE', 'some/dirname/')->once()->andReturn(['statusCode' => 403]);
$adapter = new WebDAVAdapter($mock);
$result = $adapter->deleteDir('some/dirname');
$this->assertFalse($result);
Expand Down

0 comments on commit eb0c593

Please sign in to comment.