summaryrefslogtreecommitdiffstats
path: root/apps/files/tests/ajax_rename.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/tests/ajax_rename.php')
-rw-r--r--apps/files/tests/ajax_rename.php46
1 files changed, 42 insertions, 4 deletions
diff --git a/apps/files/tests/ajax_rename.php b/apps/files/tests/ajax_rename.php
index fed366aa8eb..5ed8b1931f4 100644
--- a/apps/files/tests/ajax_rename.php
+++ b/apps/files/tests/ajax_rename.php
@@ -73,10 +73,14 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase {
$oldname = 'oldname';
$newname = 'newname';
- $this->viewMock->expects($this->at(0))
+ $this->viewMock->expects($this->any())
->method('file_exists')
- ->with('/')
- ->will($this->returnValue(true));
+ ->with($this->anything())
+ ->will($this->returnValueMap(array(
+ array('/', true),
+ array('/oldname', true)
+ )));
+
$this->viewMock->expects($this->any())
->method('getFileInfo')
@@ -119,7 +123,7 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase {
$this->viewMock->expects($this->at(0))
->method('file_exists')
- ->with('/unexist')
+ ->with('/unexist/oldname')
->will($this->returnValue(false));
$this->viewMock->expects($this->any())
@@ -137,6 +141,40 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase {
$result = $this->files->rename($dir, $oldname, $newname);
$this->assertFalse($result['success']);
+ $this->assertEquals('sourcenotfound', $result['data']['code']);
+ }
+
+ /**
+ * Test move to a folder that doesn't exist any more
+ */
+ function testRenameToNonExistingFolder() {
+ $dir = '/';
+ $oldname = 'oldname';
+ $newname = '/unexist/newname';
+
+ $this->viewMock->expects($this->any())
+ ->method('file_exists')
+ ->with($this->anything())
+ ->will($this->returnValueMap(array(
+ array('/oldname', true),
+ array('/unexist', false)
+ )));
+
+ $this->viewMock->expects($this->any())
+ ->method('getFileInfo')
+ ->will($this->returnValue(array(
+ 'fileid' => 123,
+ 'type' => 'dir',
+ 'mimetype' => 'httpd/unix-directory',
+ 'size' => 18,
+ 'etag' => 'abcdef',
+ 'directory' => '/unexist',
+ 'name' => 'new_name',
+ )));
+
+ $result = $this->files->rename($dir, $oldname, $newname);
+
+ $this->assertFalse($result['success']);
$this->assertEquals('targetnotfound', $result['data']['code']);
}
}