fixing namespaces and PHPDoc

remotes/origin/external-backend-ondemand
Thomas Müller 11 years ago
parent 4bac595068
commit 49e1a81eba
  1. 16
      lib/private/connector/sabre/exception/invalidpath.php
  2. 40
      lib/private/connector/sabre/node.php
  3. 3
      lib/private/connector/sabre/objecttree.php
  4. 5
      lib/private/files/view.php
  5. 2
      tests/lib/connector/sabre/directory.php
  6. 11
      tests/lib/connector/sabre/exception/invalidpathtest.php
  7. 19
      tests/lib/connector/sabre/file.php
  8. 3
      tests/lib/connector/sabre/node.php
  9. 22
      tests/lib/connector/sabre/objecttree.php

@ -1,12 +1,17 @@
<?php
/**
* Copyright (c) 2015 Thomas Müller <deepdiver@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file. */
class OC_Connector_Sabre_Exception_InvalidPath extends \Sabre\DAV\Exception {
namespace OC\Connector\Sabre\Exception;
use Sabre\DAV\Exception;
class InvalidPath extends Exception {
const NS_OWNCLOUD = 'http://owncloud.org/ns';
/**
* @var bool
@ -34,7 +39,8 @@ class OC_Connector_Sabre_Exception_InvalidPath extends \Sabre\DAV\Exception {
}
/**
* This method allows the exception to include additional information into the WebDAV error response
* This method allows the exception to include additional information
* into the WebDAV error response
*
* @param \Sabre\DAV\Server $server
* @param \DOMElement $errorNode
@ -42,8 +48,8 @@ class OC_Connector_Sabre_Exception_InvalidPath extends \Sabre\DAV\Exception {
*/
public function serialize(\Sabre\DAV\Server $server,\DOMElement $errorNode) {
// set owncloud namespace
$errorNode->setAttribute('xmlns:o', OC_Connector_Sabre_FilesPlugin::NS_OWNCLOUD);
// set ownCloud namespace
$errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD);
// adding the retry node
$error = $errorNode->ownerDocument->createElementNS('o:','o:retry', var_export($this->retry, true));

@ -1,28 +1,40 @@
<?php
/**
* ownCloud
* @author Arthur Schiwon <blizzz@owncloud.com>
* @author Bart Visscher <bartv@thisnet.nl>
* @author Björn Schießle <schiessle@owncloud.com>
* @author Jakob Sack <mail@jakobsack.de>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Klaas Freitag <freitag@owncloud.com>
* @author Markus Goetz <markus@woboq.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <icewind@owncloud.com>
* @author Sam Tuke <mail@samtuke.com>
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Vincent Petry <pvince81@owncloud.com>
*
* @author Jakob Sack
* @copyright 2011 Jakob Sack kde@jakobsack.de
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OC\Connector\Sabre;
use OC\Connector\Sabre\Exception\InvalidPath;
abstract class Node implements \Sabre\DAV\INode {
/**
* Allow configuring the method used to generate Etags
@ -235,7 +247,7 @@ abstract class Node implements \Sabre\DAV\INode {
$fileName = basename($this->info->getPath());
$this->fileView->verifyPath($this->path, $fileName);
} catch (\OCP\Files\InvalidPathException $ex) {
throw new OC_Connector_Sabre_Exception_InvalidPath($ex->getMessage());
throw new InvalidPath($ex->getMessage());
}
}
}

@ -8,6 +8,7 @@
namespace OC\Connector\Sabre;
use OC\Connector\Sabre\Exception\InvalidPath;
use OC\Files\FileInfo;
use OC\Files\Filesystem;
use OC\Files\Mount\MoveableMount;
@ -189,7 +190,7 @@ class ObjectTree extends \Sabre\DAV\Tree {
try {
$this->fileView->verifyPath($destinationDir, $fileName);
} catch (\OCP\Files\InvalidPathException $ex) {
throw new OC_Connector_Sabre_Exception_InvalidPath($ex->getMessage());
throw new InvalidPath($ex->getMessage());
}
$renameOkay = $this->fileView->rename($sourcePath, $destinationPath);

@ -1536,6 +1536,11 @@ class View {
return $this->updater;
}
/**
* @param string $path
* @param string $fileName
* @throws InvalidPathException
*/
public function verifyPath($path, $fileName) {
// verify empty and dot files

@ -8,7 +8,9 @@
*/
class Test_OC_Connector_Sabre_Directory extends \Test\TestCase {
/** @var OC\Files\View | PHPUnit_Framework_MockObject_MockObject */
private $view;
/** @var OC\Files\FileInfo | PHPUnit_Framework_MockObject_MockObject */
private $info;
protected function setUp() {

@ -1,12 +1,16 @@
<?php
namespace Test\Connector\Sabre\Exception;
use OC\Connector\Sabre\Exception\InvalidPath;
/**
* Copyright (c) 2015 Thomas Müller <deepdiver@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
class Test_OC_Connector_Sabre_Exception_InvalidPath extends \Test\TestCase {
class InvalidPathTest extends \Test\TestCase {
public function testSerialization() {
@ -14,7 +18,7 @@ class Test_OC_Connector_Sabre_Exception_InvalidPath extends \Test\TestCase {
$DOM = new \DOMDocument('1.0','utf-8');
$DOM->formatOutput = true;
$error = $DOM->createElementNS('DAV:','d:error');
$error->setAttribute('xmlns:s', Sabre\DAV\Server::NS_SABREDAV);
$error->setAttribute('xmlns:s', \Sabre\DAV\Server::NS_SABREDAV);
$DOM->appendChild($error);
// serialize the exception
@ -29,8 +33,7 @@ class Test_OC_Connector_Sabre_Exception_InvalidPath extends \Test\TestCase {
EOD;
$ex = new OC_Connector_Sabre_Exception_InvalidPath($message, $retry);
$ex = new InvalidPath($message, $retry);
$server = $this->getMock('Sabre\DAV\Server');
$ex->serialize($server, $error);

@ -6,7 +6,12 @@
* See the COPYING-README file.
*/
class Test_OC_Connector_Sabre_File extends \Test\TestCase {
namespace Test\Connector\Sabre;
use OC_Connector_Sabre_File;
class File extends \Test\TestCase {
/**
* @expectedException \Sabre\DAV\Exception
@ -93,7 +98,7 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase {
}
/**
* @expectedException \Sabre\DAV\Exception\BadRequest
* @expectedException \OC\Connector\Sabre\Exception\InvalidPath
*/
public function testSimplePutInvalidChars() {
// setup
@ -104,9 +109,9 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase {
$view->expects($this->any())
->method('getRelativePath')
->will($this->returnValue('/super*star.txt'));
->will($this->returnValue('/*'));
$info = new \OC\Files\FileInfo('/super*star.txt', null, null, array(
$info = new \OC\Files\FileInfo('/*', null, null, array(
'permissions' => \OCP\Constants::PERMISSION_ALL
), null);
$file = new \OC\Connector\Sabre\File($view, $info);
@ -117,7 +122,7 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase {
/**
* Test setting name with setName() with invalid chars
* @expectedException \Sabre\DAV\Exception\BadRequest
* @expectedException \OC\Connector\Sabre\Exception\InvalidPath
*/
public function testSetNameInvalidChars() {
// setup
@ -125,9 +130,9 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase {
$view->expects($this->any())
->method('getRelativePath')
->will($this->returnValue('/super*star.txt'));
->will($this->returnValue('/*'));
$info = new \OC\Files\FileInfo('/super*star.txt', null, null, array(
$info = new \OC\Files\FileInfo('/*', null, null, array(
'permissions' => \OCP\Constants::PERMISSION_ALL
), null);
$file = new \OC\Connector\Sabre\File($view, $info);

@ -9,9 +9,6 @@
namespace Test\Connector\Sabre;
use OC\Files\FileInfo;
use OC\Files\View;
class Node extends \Test\TestCase {
public function davPermissionsProvider() {
return array(

@ -47,29 +47,29 @@ class ObjectTree extends \Test\TestCase {
* @dataProvider moveFailedProvider
* @expectedException \Sabre\DAV\Exception\Forbidden
*/
public function testMoveFailed($source, $dest, $updatables, $deletables) {
$this->moveTest($source, $dest, $updatables, $deletables);
public function testMoveFailed($source, $destination, $updatables, $deletables) {
$this->moveTest($source, $destination, $updatables, $deletables);
}
/**
* @dataProvider moveSuccessProvider
*/
public function testMoveSuccess($source, $dest, $updatables, $deletables) {
$this->moveTest($source, $dest, $updatables, $deletables);
public function testMoveSuccess($source, $destination, $updatables, $deletables) {
$this->moveTest($source, $destination, $updatables, $deletables);
$this->assertTrue(true);
}
/**
* @dataProvider moveFailedInvalidCharsProvider
* @expectedException \Sabre\DAV\Exception\BadRequest
* @expectedException \OC\Connector\Sabre\Exception\InvalidPath
*/
public function testMoveFailedInvalidChars($source, $dest, $updatables, $deletables) {
$this->moveTest($source, $dest, $updatables, $deletables);
public function testMoveFailedInvalidChars($source, $destination, $updatables, $deletables) {
$this->moveTest($source, $destination, $updatables, $deletables);
}
function moveFailedInvalidCharsProvider() {
return array(
array('a/b', 'a/c*', array('a' => false, 'a/b' => true, 'a/c*' => false), array()),
array('a/b', 'a/*', array('a' => false, 'a/b' => true, 'a/c*' => false), array()),
);
}
@ -94,10 +94,10 @@ class ObjectTree extends \Test\TestCase {
/**
* @param $source
* @param $dest
* @param $destination
* @param $updatables
*/
private function moveTest($source, $dest, $updatables, $deletables) {
private function moveTest($source, $destination, $updatables, $deletables) {
$view = new TestDoubleFileView($updatables, $deletables);
$info = new FileInfo('', null, null, array(), null);
@ -115,7 +115,7 @@ class ObjectTree extends \Test\TestCase {
/** @var $objectTree \OC\Connector\Sabre\ObjectTree */
$mountManager = \OC\Files\Filesystem::getMountManager();
$objectTree->init($rootDir, $view, $mountManager);
$objectTree->move($source, $dest);
$objectTree->move($source, $destination);
}
/**

Loading…
Cancel
Save