Merge pull request #21018 from owncloud/scrutinizer-patch-1
Scrutinizer Auto-Fixes
This commit is contained in:
commit
0dd111ca2e
|
@ -48,6 +48,12 @@ class SharedMount extends MountPoint implements MoveableMount {
|
||||||
*/
|
*/
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $storage
|
||||||
|
* @param string $mountpoint
|
||||||
|
* @param array|null $arguments
|
||||||
|
* @param \OCP\Files\Storage\IStorageFactory $loader
|
||||||
|
*/
|
||||||
public function __construct($storage, $mountpoint, $arguments = null, $loader = null) {
|
public function __construct($storage, $mountpoint, $arguments = null, $loader = null) {
|
||||||
$this->user = $arguments['user'];
|
$this->user = $arguments['user'];
|
||||||
$this->recipientView = new View('/' . $this->user . '/files');
|
$this->recipientView = new View('/' . $this->user . '/files');
|
||||||
|
@ -59,6 +65,9 @@ class SharedMount extends MountPoint implements MoveableMount {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if the parent folder exists otherwise move the mount point up
|
* check if the parent folder exists otherwise move the mount point up
|
||||||
|
*
|
||||||
|
* @param array $share
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function verifyMountPoint(&$share) {
|
private function verifyMountPoint(&$share) {
|
||||||
|
|
||||||
|
@ -121,6 +130,7 @@ class SharedMount extends MountPoint implements MoveableMount {
|
||||||
*
|
*
|
||||||
* @param string $path the absolute path
|
* @param string $path the absolute path
|
||||||
* @return string e.g. turns '/admin/files/test.txt' into '/test.txt'
|
* @return string e.g. turns '/admin/files/test.txt' into '/test.txt'
|
||||||
|
* @throws \OCA\Files_Sharing\Exceptions\BrokenPath
|
||||||
*/
|
*/
|
||||||
protected function stripUserFilesPath($path) {
|
protected function stripUserFilesPath($path) {
|
||||||
$trimmed = ltrim($path, '/');
|
$trimmed = ltrim($path, '/');
|
||||||
|
@ -183,7 +193,7 @@ class SharedMount extends MountPoint implements MoveableMount {
|
||||||
*/
|
*/
|
||||||
public function removeMount() {
|
public function removeMount() {
|
||||||
$mountManager = \OC\Files\Filesystem::getMountManager();
|
$mountManager = \OC\Files\Filesystem::getMountManager();
|
||||||
/** @var \OC\Files\Storage\Shared */
|
/** @var $storage \OC\Files\Storage\Shared */
|
||||||
$storage = $this->getStorage();
|
$storage = $this->getStorage();
|
||||||
$result = $storage->unshareStorage();
|
$result = $storage->unshareStorage();
|
||||||
$mountManager->removeMount($this->mountPoint);
|
$mountManager->removeMount($this->mountPoint);
|
||||||
|
@ -191,7 +201,12 @@ class SharedMount extends MountPoint implements MoveableMount {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getShare() {
|
public function getShare() {
|
||||||
return $this->getStorage()->getShare();
|
/** @var $storage \OC\Files\Storage\Shared */
|
||||||
|
$storage = $this->getStorage();
|
||||||
|
return $storage->getShare();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,11 @@ class ShareesTest extends TestCase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $uid
|
||||||
|
* @param string $displayName
|
||||||
|
* @return \OCP\IUser|\PHPUnit_Framework_MockObject_MockObject
|
||||||
|
*/
|
||||||
protected function getUserMock($uid, $displayName) {
|
protected function getUserMock($uid, $displayName) {
|
||||||
$user = $this->getMockBuilder('OCP\IUser')
|
$user = $this->getMockBuilder('OCP\IUser')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
|
@ -104,6 +109,10 @@ class ShareesTest extends TestCase {
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $gid
|
||||||
|
* @return \OCP\IGroup|\PHPUnit_Framework_MockObject_MockObject
|
||||||
|
*/
|
||||||
protected function getGroupMock($gid) {
|
protected function getGroupMock($gid) {
|
||||||
$group = $this->getMockBuilder('OCP\IGroup')
|
$group = $this->getMockBuilder('OCP\IGroup')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
|
|
|
@ -220,6 +220,10 @@ class Test_Files_Sharing extends OCA\Files_sharing\Tests\TestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param OC\Files\FileInfo[] $content
|
||||||
|
* @param string[] $expected
|
||||||
|
*/
|
||||||
public function verifyDirContent($content, $expected) {
|
public function verifyDirContent($content, $expected) {
|
||||||
foreach ($content as $c) {
|
foreach ($content as $c) {
|
||||||
if (!in_array($c['name'], $expected)) {
|
if (!in_array($c['name'], $expected)) {
|
||||||
|
|
|
@ -147,7 +147,7 @@ class Trashbin {
|
||||||
*
|
*
|
||||||
* @param string $sourcePath
|
* @param string $sourcePath
|
||||||
* @param string $owner
|
* @param string $owner
|
||||||
* @param $targetPath
|
* @param string $targetPath
|
||||||
* @param $user
|
* @param $user
|
||||||
* @param integer $timestamp
|
* @param integer $timestamp
|
||||||
*/
|
*/
|
||||||
|
@ -410,7 +410,7 @@ class Trashbin {
|
||||||
* @param string $uniqueFilename new file name to restore the file without overwriting existing files
|
* @param string $uniqueFilename new file name to restore the file without overwriting existing files
|
||||||
* @param string $location location if file
|
* @param string $location location if file
|
||||||
* @param int $timestamp deletion time
|
* @param int $timestamp deletion time
|
||||||
* @return bool
|
* @return false|null
|
||||||
*/
|
*/
|
||||||
private static function restoreVersions(\OC\Files\View $view, $file, $filename, $uniqueFilename, $location, $timestamp) {
|
private static function restoreVersions(\OC\Files\View $view, $file, $filename, $uniqueFilename, $location, $timestamp) {
|
||||||
|
|
||||||
|
@ -500,9 +500,10 @@ class Trashbin {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \OC\Files\View $view
|
* @param \OC\Files\View $view
|
||||||
* @param $file
|
* @param string $file
|
||||||
* @param $filename
|
* @param string $filename
|
||||||
* @param $timestamp
|
* @param integer|null $timestamp
|
||||||
|
* @param string $user
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private static function deleteVersions(\OC\Files\View $view, $file, $filename, $timestamp, $user) {
|
private static function deleteVersions(\OC\Files\View $view, $file, $filename, $timestamp, $user) {
|
||||||
|
@ -684,7 +685,7 @@ class Trashbin {
|
||||||
*
|
*
|
||||||
* @param array $files list of files sorted by mtime
|
* @param array $files list of files sorted by mtime
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @return array size of deleted files and number of deleted files
|
* @return integer[] size of deleted files and number of deleted files
|
||||||
*/
|
*/
|
||||||
public static function deleteExpiredFiles($files, $user) {
|
public static function deleteExpiredFiles($files, $user) {
|
||||||
$application = new Application();
|
$application = new Application();
|
||||||
|
|
|
@ -248,8 +248,8 @@ class Test_Trashbin extends \Test\TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* verify that the array contains the expected results
|
* verify that the array contains the expected results
|
||||||
* @param array $result
|
* @param OCP\Files\FileInfo[] $result
|
||||||
* @param array $expected
|
* @param string[] $expected
|
||||||
*/
|
*/
|
||||||
private function verifyArray($result, $expected) {
|
private function verifyArray($result, $expected) {
|
||||||
$this->assertSame(count($expected), count($result));
|
$this->assertSame(count($expected), count($result));
|
||||||
|
@ -268,6 +268,11 @@ class Test_Trashbin extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param OCP\Files\FileInfo[] $files
|
||||||
|
* @param string $trashRoot
|
||||||
|
* @param integer $expireDate
|
||||||
|
*/
|
||||||
private function manipulateDeleteTime($files, $trashRoot, $expireDate) {
|
private function manipulateDeleteTime($files, $trashRoot, $expireDate) {
|
||||||
$counter = 0;
|
$counter = 0;
|
||||||
foreach ($files as &$file) {
|
foreach ($files as &$file) {
|
||||||
|
@ -627,7 +632,6 @@ class Test_Trashbin extends \Test\TestCase {
|
||||||
/**
|
/**
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @param bool $create
|
* @param bool $create
|
||||||
* @param bool $password
|
|
||||||
*/
|
*/
|
||||||
public static function loginHelper($user, $create = false) {
|
public static function loginHelper($user, $create = false) {
|
||||||
if ($create) {
|
if ($create) {
|
||||||
|
@ -650,11 +654,20 @@ class Test_Trashbin extends \Test\TestCase {
|
||||||
|
|
||||||
// just a dummy class to make protected methods available for testing
|
// just a dummy class to make protected methods available for testing
|
||||||
class TrashbinForTesting extends Files_Trashbin\Trashbin {
|
class TrashbinForTesting extends Files_Trashbin\Trashbin {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param OCP\Files\FileInfo[] $files
|
||||||
|
* @param integer $limit
|
||||||
|
*/
|
||||||
public function dummyDeleteExpiredFiles($files, $limit) {
|
public function dummyDeleteExpiredFiles($files, $limit) {
|
||||||
// dummy value for $retention_obligation because it is not needed here
|
// dummy value for $retention_obligation because it is not needed here
|
||||||
return parent::deleteExpiredFiles($files, \Test_Trashbin::TEST_TRASHBIN_USER1, $limit, 0);
|
return parent::deleteExpiredFiles($files, \Test_Trashbin::TEST_TRASHBIN_USER1, $limit, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param OCP\Files\FileInfo[] $files
|
||||||
|
* @param integer $availableSpace
|
||||||
|
*/
|
||||||
public function dummyDeleteFiles($files, $availableSpace) {
|
public function dummyDeleteFiles($files, $availableSpace) {
|
||||||
return parent::deleteFiles($files, \Test_Trashbin::TEST_TRASHBIN_USER1, $availableSpace);
|
return parent::deleteFiles($files, \Test_Trashbin::TEST_TRASHBIN_USER1, $availableSpace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -649,7 +649,7 @@ class Storage {
|
||||||
/**
|
/**
|
||||||
* Expire versions which exceed the quota
|
* Expire versions which exceed the quota
|
||||||
*
|
*
|
||||||
* @param $filename
|
* @param string $filename
|
||||||
* @param int|null $versionsSize
|
* @param int|null $versionsSize
|
||||||
* @param int $offset
|
* @param int $offset
|
||||||
* @return bool|int|null
|
* @return bool|int|null
|
||||||
|
|
|
@ -30,13 +30,13 @@ use OCP\IUserSession;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
|
|
||||||
class GroupsTest extends \Test\TestCase {
|
class GroupsTest extends \Test\TestCase {
|
||||||
/** @var IGroupManager */
|
/** @var IGroupManager|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
protected $groupManager;
|
protected $groupManager;
|
||||||
/** @var IUserSession */
|
/** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
protected $userSession;
|
protected $userSession;
|
||||||
/** @var IRequest */
|
/** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
protected $request;
|
protected $request;
|
||||||
/** @var \OC\SubAdmin */
|
/** @var \OC\SubAdmin|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
protected $subAdminManager;
|
protected $subAdminManager;
|
||||||
/** @var \OCA\Provisioning_API\Groups */
|
/** @var \OCA\Provisioning_API\Groups */
|
||||||
protected $api;
|
protected $api;
|
||||||
|
@ -58,6 +58,10 @@ class GroupsTest extends \Test\TestCase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $gid
|
||||||
|
* @return \OCP\IGroup|\PHPUnit_Framework_MockObject_MockObject
|
||||||
|
*/
|
||||||
private function createGroup($gid) {
|
private function createGroup($gid) {
|
||||||
$group = $this->getMock('OCP\IGroup');
|
$group = $this->getMock('OCP\IGroup');
|
||||||
$group
|
$group
|
||||||
|
@ -66,6 +70,10 @@ class GroupsTest extends \Test\TestCase {
|
||||||
return $group;
|
return $group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $uid
|
||||||
|
* @return \OCP\IUser|\PHPUnit_Framework_MockObject_MockObject
|
||||||
|
*/
|
||||||
private function createUser($uid) {
|
private function createUser($uid) {
|
||||||
$user = $this->getMock('OCP\IUser');
|
$user = $this->getMock('OCP\IUser');
|
||||||
$user
|
$user
|
||||||
|
|
Loading…
Reference in New Issue