Skip to content

Commit

Permalink
Merge pull request #32051 from owncloud/tech-dept/deprecate-storage-i…
Browse files Browse the repository at this point in the history
…nterface

Remove deprecated interface OCP\Files\Storage in favor of OCP\Files\S…
  • Loading branch information
DeepDiver1975 authored Jul 23, 2018
2 parents d1f5aec + c2d096e commit 7fb3bbb
Show file tree
Hide file tree
Showing 41 changed files with 656 additions and 1,043 deletions.
4 changes: 2 additions & 2 deletions apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public function getDirectDownload() {
if (\OCP\App::isEnabled('encryption')) {
return [];
}
/** @var \OCP\Files\Storage $storage */
/** @var \OCP\Files\Storage\IStorage $storage */
list($storage, $internalPath) = $this->fileView->resolvePath($this->path);
if ($storage === null) {
return [];
Expand Down Expand Up @@ -610,7 +610,7 @@ private static function isChecksumValid(Storage $storage, $path) {
* or whether the file can be assembled/uploaded directly on the
* target storage.
*
* @param \OCP\Files\Storage $storage
* @param \OCP\Files\Storage\IStorage $storage
* @return bool true if the storage needs part file handling
*/
private function needsPartFile($storage) {
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/tests/unit/Connector/Sabre/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function tearDown() {
* @return \PHPUnit_Framework_MockObject_MockObject | Storage
*/
private function getMockStorage() {
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(Storage\IStorage::class);
$storage->expects($this->any())
->method('getId')
->will($this->returnValue('home::someuser'));
Expand Down
27 changes: 17 additions & 10 deletions apps/dav/tests/unit/Connector/Sabre/NodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@

namespace OCA\DAV\Tests\unit\Connector\Sabre;

use OCP\Files\Storage\IStorage;
use OC\Files\View;
use OC\Files\FileInfo;
use OCP\Share\IShare;
use OCP\Share\IManager;
use OCP\Files\Mount\IMountPoint;

/**
* Class NodeTest
*
Expand All @@ -50,7 +57,7 @@ public function davPermissionsProvider() {
* @dataProvider davPermissionsProvider
*/
public function testDavPermissions($permissions, $type, $shared, $mounted, $expected) {
$info = $this->getMockBuilder('\OC\Files\FileInfo')
$info = $this->getMockBuilder(FileInfo::class)
->disableOriginalConstructor()
->setMethods(['getPermissions', 'isShared', 'isMounted', 'getType'])
->getMock();
Expand All @@ -66,7 +73,7 @@ public function testDavPermissions($permissions, $type, $shared, $mounted, $expe
$info->expects($this->any())
->method('getType')
->will($this->returnValue($type));
$view = $this->createMock('\OC\Files\View');
$view = $this->createMock(View::class);

$node = new \OCA\DAV\Connector\Sabre\File($view, $info);
$this->assertEquals($expected, $node->getDavPermissions());
Expand Down Expand Up @@ -116,13 +123,13 @@ public function sharePermissionsProvider() {
* @dataProvider sharePermissionsProvider
*/
public function testSharePermissions($type, $user, $permissions, $expected) {
$storage = $this->createMock('\OCP\Files\Storage');
$storage = $this->createMock(IStorage::class);
$storage->method('getPermissions')->willReturn($permissions);

$mountpoint = $this->createMock('\OCP\Files\Mount\IMountPoint');
$mountpoint = $this->createMock(IMountPoint::class);
$mountpoint->method('getMountPoint')->willReturn('myPath');
$shareManager = $this->getMockBuilder('OCP\Share\IManager')->disableOriginalConstructor()->getMock();
$share = $this->getMockBuilder('OCP\Share\IShare')->disableOriginalConstructor()->getMock();
$shareManager = $this->getMockBuilder(IManager::class)->disableOriginalConstructor()->getMock();
$share = $this->getMockBuilder(IShare::class)->disableOriginalConstructor()->getMock();

if ($user === null) {
$shareManager->expects($this->never())->method('getShareByToken');
Expand All @@ -133,7 +140,7 @@ public function testSharePermissions($type, $user, $permissions, $expected) {
$share->expects($this->once())->method('getPermissions')->willReturn($permissions);
}

$info = $this->getMockBuilder('\OC\Files\FileInfo')
$info = $this->getMockBuilder(FileInfo::class)
->disableOriginalConstructor()
->setMethods(['getStorage', 'getType', 'getMountPoint'])
->getMock();
Expand All @@ -142,7 +149,7 @@ public function testSharePermissions($type, $user, $permissions, $expected) {
$info->method('getType')->willReturn($type);
$info->method('getMountPoint')->willReturn($mountpoint);

$view = $this->createMock('\OC\Files\View');
$view = $this->createMock(View::class);

$node = new \OCA\DAV\Connector\Sabre\File($view, $info);
$this->invokePrivate($node, 'shareManager', [$shareManager]);
Expand All @@ -163,14 +170,14 @@ public function fileIdProvider() {
* @dataProvider fileIdProvider
*/
public function testFileId($instanceid, $numericid, $fullid) {
$info = $this->getMockBuilder('\OC\Files\FileInfo')
$info = $this->getMockBuilder(FileInfo::class)
->disableOriginalConstructor()
->setMethods(['getId'])
->getMock();
$info->expects($this->any())
->method('getId')
->will($this->returnValue($numericid));
$view = $this->createMock('\OC\Files\View');
$view = $this->createMock(View::class);

\OC::$server->getSystemConfig()->setValue('instanceid', $instanceid);

Expand Down
8 changes: 7 additions & 1 deletion apps/federation/tests/DbHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function setUp() {
parent::setUp();

$this->connection = \OC::$server->getDatabaseConnection();
$this->il10n = $this->createMock('OCP\IL10N');
$this->il10n = $this->createMock(IL10N::class);

$this->dbHandler = new DbHandler(
$this->connection,
Expand All @@ -74,6 +74,7 @@ public function tearDown() {
* @param string $url passed to the method
* @param string $expectedUrl the url we expect to be written to the db
* @param string $expectedHash the hash value we expect to be written to the db
* @throws \OC\HintException
*/
public function testAddServer($url, $expectedUrl, $expectedHash) {
$id = $this->dbHandler->addServer($url);
Expand Down Expand Up @@ -141,6 +142,7 @@ public function testGetAll() {
* @param string $serverInTable
* @param string $checkForServer
* @param bool $expected
* @throws \OC\HintException
*/
public function testServerExists($serverInTable, $checkForServer, $expected) {
$this->dbHandler->addServer($serverInTable);
Expand Down Expand Up @@ -272,6 +274,10 @@ public function dataTestNormalizeUrl() {

/**
* @dataProvider providesAuth
* @param $expectedResult
* @param $user
* @param $password
* @throws \OC\HintException
*/
public function testAuth($expectedResult, $user, $password) {
if ($expectedResult) {
Expand Down
6 changes: 3 additions & 3 deletions apps/files_sharing/lib/SharedStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public function unshareStorage() {
* @throws \OCP\Lock\LockedException
*/
public function acquireLock($path, $type, ILockingProvider $provider) {
/** @var \OCP\Files\Storage $targetStorage */
/** @var \OCP\Files\Storage\IStorage $targetStorage */
list($targetStorage, $targetInternalPath) = $this->resolvePath($path);
$targetStorage->acquireLock($targetInternalPath, $type, $provider);
// lock the parent folders of the owner when locking the share as recipient
Expand All @@ -390,7 +390,7 @@ public function acquireLock($path, $type, ILockingProvider $provider) {
* @param \OCP\Lock\ILockingProvider $provider
*/
public function releaseLock($path, $type, ILockingProvider $provider) {
/** @var \OCP\Files\Storage $targetStorage */
/** @var \OCP\Files\Storage\IStorage $targetStorage */
list($targetStorage, $targetInternalPath) = $this->resolvePath($path);
$targetStorage->releaseLock($targetInternalPath, $type, $provider);
// unlock the parent folders of the owner when unlocking the share as recipient
Expand All @@ -406,7 +406,7 @@ public function releaseLock($path, $type, ILockingProvider $provider) {
* @param \OCP\Lock\ILockingProvider $provider
*/
public function changeLock($path, $type, ILockingProvider $provider) {
/** @var \OCP\Files\Storage $targetStorage */
/** @var \OCP\Files\Storage\IStorage $targetStorage */
list($targetStorage, $targetInternalPath) = $this->resolvePath($path);
$targetStorage->changeLock($targetInternalPath, $type, $provider);
}
Expand Down
Loading

0 comments on commit 7fb3bbb

Please sign in to comment.