class TestDoubleFileView extends \OC\Files\View {
- public function __construct($updatables, $deletables, $canRename = true) {
+ public function __construct($creatables, $updatables, $deletables, $canRename = true) {
+ $this->creatables = $creatables;
$this->updatables = $updatables;
$this->deletables = $deletables;
$this->canRename = $canRename;
}
public function isUpdatable($path) {
- return $this->updatables[$path];
+ return !empty($this->updatables[$path]);
}
public function isCreatable($path) {
- return $this->updatables[$path];
+ return !empty($this->creatables[$path]);
}
public function isDeletable($path) {
- return $this->deletables[$path];
+ return !empty($this->deletables[$path]);
}
public function rename($path1, $path2) {
public function getFileInfo($path, $includeMountPoints = true) {
$objectTreeTest = new ObjectTreeTest();
- return $objectTreeTest->getFileInfoMock();
+ return $objectTreeTest->getFileInfoMock(
+ $this->isCreatable($path),
+ $this->isUpdatable($path),
+ $this->isDeletable($path)
+ );
}
}
*/
class ObjectTreeTest extends \Test\TestCase {
- public function getFileInfoMock() {
+ public function getFileInfoMock($create = true, $update = true, $delete = true) {
$mock = $this->getMockBuilder('\OCP\Files\FileInfo')
->disableOriginalConstructor()
->getMock();
$mock
->expects($this->any())
- ->method('isDeletable')
- ->willReturn(true);
+ ->method('isCreatable')
+ ->willReturn($create);
$mock
->expects($this->any())
->method('isUpdateable')
- ->willReturn(true);
+ ->willReturn($update);
+ $mock
+ ->expects($this->any())
+ ->method('isDeletable')
+ ->willReturn($delete);
return $mock;
}
* @expectedException \Sabre\DAV\Exception\Forbidden
*/
public function testMoveFailed($source, $destination, $updatables, $deletables) {
- $this->moveTest($source, $destination, $updatables, $deletables);
+ $this->moveTest($source, $destination, $updatables, $updatables, $deletables, true);
}
/**
* @dataProvider moveSuccessProvider
*/
public function testMoveSuccess($source, $destination, $updatables, $deletables) {
- $this->moveTest($source, $destination, $updatables, $deletables);
+ $this->moveTest($source, $destination, $updatables, $updatables, $deletables);
$this->assertTrue(true);
}
* @expectedException \OCA\DAV\Connector\Sabre\Exception\InvalidPath
*/
public function testMoveFailedInvalidChars($source, $destination, $updatables, $deletables) {
- $this->moveTest($source, $destination, $updatables, $deletables);
+ $this->moveTest($source, $destination, $updatables, $updatables, $deletables);
}
function moveFailedInvalidCharsProvider() {
/**
* @param $source
* @param $destination
+ * @param $creatables
* @param $updatables
+ * @param $deletables
+ * @param $throwsBeforeGetNode
*/
- private function moveTest($source, $destination, $updatables, $deletables) {
- $view = new TestDoubleFileView($updatables, $deletables);
+ private function moveTest($source, $destination, $creatables, $updatables, $deletables, $throwsBeforeGetNode = false) {
+ $view = new TestDoubleFileView($creatables, $updatables, $deletables);
$info = new FileInfo('', null, null, array(), null);
->setConstructorArgs([$rootDir, $view])
->getMock();
- $objectTree->expects($this->once())
+ $objectTree->expects($throwsBeforeGetNode ? $this->never() : $this->once())
->method('getNodeForPath')
->with($this->identicalTo($source))
->will($this->returnValue(false));
$updatables = array('a' => true, 'a/b' => true, 'b' => true, 'b/b' => false);
$deletables = array('a/b' => true);
- $view = new TestDoubleFileView($updatables, $deletables);
+ $view = new TestDoubleFileView($updatables, $updatables, $deletables);
$info = new FileInfo('', null, null, array(), null);