|
|
|
|
@ -38,13 +38,14 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase { |
|
|
|
|
$l10nMock->expects($this->any()) |
|
|
|
|
->method('t') |
|
|
|
|
->will($this->returnArgument(0)); |
|
|
|
|
$viewMock = $this->getMock('\OC\Files\View', array('rename', 'normalizePath'), array(), '', false); |
|
|
|
|
$viewMock = $this->getMock('\OC\Files\View', array('rename', 'normalizePath', 'getFileInfo'), array(), '', false); |
|
|
|
|
$viewMock->expects($this->any()) |
|
|
|
|
->method('normalizePath') |
|
|
|
|
->will($this->returnArgument(0)); |
|
|
|
|
$viewMock->expects($this->any()) |
|
|
|
|
->method('rename') |
|
|
|
|
->will($this->returnValue(true)); |
|
|
|
|
$this->viewMock = $viewMock; |
|
|
|
|
$this->files = new \OCA\Files\App($viewMock, $l10nMock); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -79,17 +80,28 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase { |
|
|
|
|
$oldname = 'Shared'; |
|
|
|
|
$newname = 'new_name'; |
|
|
|
|
|
|
|
|
|
$this->viewMock->expects($this->any()) |
|
|
|
|
->method('getFileInfo') |
|
|
|
|
->will($this->returnValue(array( |
|
|
|
|
'fileid' => 123, |
|
|
|
|
'type' => 'dir', |
|
|
|
|
'mimetype' => 'httpd/unix-directory', |
|
|
|
|
'size' => 18, |
|
|
|
|
'etag' => 'abcdef', |
|
|
|
|
'directory' => '/', |
|
|
|
|
'name' => 'new_name', |
|
|
|
|
))); |
|
|
|
|
|
|
|
|
|
$result = $this->files->rename($dir, $oldname, $newname); |
|
|
|
|
$expected = array( |
|
|
|
|
'success' => true, |
|
|
|
|
'data' => array( |
|
|
|
|
'dir' => $dir, |
|
|
|
|
'file' => $oldname, |
|
|
|
|
'newname' => $newname |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $result); |
|
|
|
|
$this->assertTrue($result['success']); |
|
|
|
|
$this->assertEquals(123, $result['data']['id']); |
|
|
|
|
$this->assertEquals('new_name', $result['data']['name']); |
|
|
|
|
$this->assertEquals('/test', $result['data']['directory']); |
|
|
|
|
$this->assertEquals(18, $result['data']['size']); |
|
|
|
|
$this->assertEquals('httpd/unix-directory', $result['data']['mime']); |
|
|
|
|
$this->assertEquals(\OC_Helper::mimetypeIcon('dir'), $result['data']['icon']); |
|
|
|
|
$this->assertFalse($result['data']['isPreviewAvailable']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -117,16 +129,29 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase { |
|
|
|
|
$oldname = 'oldname'; |
|
|
|
|
$newname = 'newname'; |
|
|
|
|
|
|
|
|
|
$this->viewMock->expects($this->any()) |
|
|
|
|
->method('getFileInfo') |
|
|
|
|
->will($this->returnValue(array( |
|
|
|
|
'fileid' => 123, |
|
|
|
|
'type' => 'dir', |
|
|
|
|
'mimetype' => 'httpd/unix-directory', |
|
|
|
|
'size' => 18, |
|
|
|
|
'etag' => 'abcdef', |
|
|
|
|
'directory' => '/', |
|
|
|
|
'name' => 'new_name', |
|
|
|
|
))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = $this->files->rename($dir, $oldname, $newname); |
|
|
|
|
$expected = array( |
|
|
|
|
'success' => true, |
|
|
|
|
'data' => array( |
|
|
|
|
'dir' => $dir, |
|
|
|
|
'file' => $oldname, |
|
|
|
|
'newname' => $newname |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $result); |
|
|
|
|
$this->assertTrue($result['success']); |
|
|
|
|
$this->assertEquals(123, $result['data']['id']); |
|
|
|
|
$this->assertEquals('newname', $result['data']['name']); |
|
|
|
|
$this->assertEquals('/', $result['data']['directory']); |
|
|
|
|
$this->assertEquals(18, $result['data']['size']); |
|
|
|
|
$this->assertEquals('httpd/unix-directory', $result['data']['mime']); |
|
|
|
|
$this->assertEquals('abcdef', $result['data']['etag']); |
|
|
|
|
$this->assertEquals(\OC_Helper::mimetypeIcon('dir'), $result['data']['icon']); |
|
|
|
|
$this->assertFalse($result['data']['isPreviewAvailable']); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|