commit
629faf6d34
@ -0,0 +1,13 @@ |
||||
BEGIN:VCALENDAR |
||||
PRODID:-//some random cal software//EN |
||||
VERSION:2.0 |
||||
BEGIN:VEVENT |
||||
CREATED:20130102T120000Z |
||||
LAST-MODIFIED:20130102T120000Z |
||||
DTSTAMP:20130102T120000Z |
||||
UID:f106ecdf-c716-43ef-9d94-4e6f19f2fcfb |
||||
SUMMARY:a test cal file |
||||
DTSTART;VALUE=DATE:20130101 |
||||
DTEND;VALUE=DATE:20130102 |
||||
END:VEVENT |
||||
END:VCALENDAR |
@ -0,0 +1,6 @@ |
||||
BEGIN:VCARD |
||||
VERSION:3.0 |
||||
PRODID:-//some random contact software//EN |
||||
N:def;abc;;; |
||||
FN:abc def |
||||
END:VCARD |
@ -0,0 +1,87 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2013 Thomas Müller <thomas.mueller@tmit.eu> |
||||
* This file is licensed under the Affero General Public License version 3 or |
||||
* later. |
||||
* See the COPYING-README file. |
||||
*/ |
||||
|
||||
namespace Test\OC\Connector\Sabre; |
||||
|
||||
|
||||
use OC_Connector_Sabre_Directory; |
||||
use PHPUnit_Framework_TestCase; |
||||
use Sabre_DAV_Exception_Forbidden; |
||||
|
||||
class TestDoubleFileView extends \OC\Files\View{ |
||||
|
||||
public function __construct($updatables, $canRename = true) { |
||||
$this->updatables = $updatables; |
||||
$this->canRename = $canRename; |
||||
} |
||||
|
||||
public function isUpdatable($path) { |
||||
return $this->updatables[$path]; |
||||
} |
||||
|
||||
public function rename($path1, $path2) { |
||||
return $this->canRename; |
||||
} |
||||
} |
||||
|
||||
class ObjectTree extends PHPUnit_Framework_TestCase { |
||||
|
||||
/** |
||||
* @dataProvider moveFailedProvider |
||||
* @expectedException Sabre_DAV_Exception_Forbidden |
||||
*/ |
||||
public function testMoveFailed($source, $dest, $updatables) { |
||||
$this->moveTest($source, $dest, $updatables); |
||||
} |
||||
|
||||
/** |
||||
* @dataProvider moveSuccessProvider |
||||
*/ |
||||
public function testMoveSuccess($source, $dest, $updatables) { |
||||
$this->moveTest($source, $dest, $updatables); |
||||
$this->assertTrue(true); |
||||
} |
||||
|
||||
function moveFailedProvider() { |
||||
return array( |
||||
array('a/b', 'a/c', array('a' => false, 'a/b' => false, 'a/c' => false)), |
||||
array('a/b', 'b/b', array('a' => false, 'a/b' => false, 'b' => false, 'b/b' => false)), |
||||
array('a/b', 'b/b', array('a' => false, 'a/b' => true, 'b' => false, 'b/b' => false)), |
||||
array('a/b', 'b/b', array('a' => true, 'a/b' => true, 'b' => false, 'b/b' => false)), |
||||
); |
||||
} |
||||
|
||||
function moveSuccessProvider() { |
||||
return array( |
||||
array('a/b', 'a/c', array('a' => false, 'a/b' => true, 'a/c' => false)), |
||||
array('a/b', 'b/b', array('a' => true, 'a/b' => true, 'b' => true, 'b/b' => false)), |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param $source |
||||
* @param $dest |
||||
* @param $updatables |
||||
*/ |
||||
private function moveTest($source, $dest, $updatables) { |
||||
$rootDir = new OC_Connector_Sabre_Directory(''); |
||||
$objectTree = $this->getMock('\OC\Connector\Sabre\ObjectTree', |
||||
array('nodeExists', 'getNodeForPath'), |
||||
array($rootDir)); |
||||
|
||||
$objectTree->expects($this->once()) |
||||
->method('getNodeForPath') |
||||
->with($this->identicalTo($source)) |
||||
->will($this->returnValue(false)); |
||||
|
||||
/** @var $objectTree \OC\Connector\Sabre\ObjectTree */ |
||||
$objectTree->fileView = new TestDoubleFileView($updatables); |
||||
$objectTree->move($source, $dest); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue