mirror of
https://github.com/nextcloud/server.git
synced 2026-06-04 14:24:59 -04:00
test: Cleanup tests/lib/Files/*
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
53b116b8a5
commit
5283e9a5e2
17 changed files with 99 additions and 89 deletions
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Test\Files\Node;
|
||||
|
||||
use OC\Files\Node\Root;
|
||||
|
||||
/**
|
||||
* Class FileTest
|
||||
*
|
||||
|
|
@ -14,7 +16,7 @@ namespace Test\Files\Node;
|
|||
*
|
||||
* @package Test\Files\Node
|
||||
*/
|
||||
class FileTest extends NodeTest {
|
||||
class FileTest extends NodeTestCase {
|
||||
protected function createTestNode($root, $view, $path, array $data = [], $internalPath = '', $storage = null) {
|
||||
if ($data || $internalPath || $storage) {
|
||||
return new \OC\Files\Node\File($root, $view, $path, $this->getFileInfo($data, $internalPath, $storage));
|
||||
|
|
@ -37,7 +39,7 @@ class FileTest extends NodeTest {
|
|||
|
||||
public function testGetContent(): void {
|
||||
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
|
||||
$root = $this->getMockBuilder('\OC\Files\Node\Root')
|
||||
$root = $this->getMockBuilder(Root::class)
|
||||
->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
|
||||
->getMock();
|
||||
|
||||
|
|
@ -67,7 +69,7 @@ class FileTest extends NodeTest {
|
|||
$this->expectException(\OCP\Files\NotPermittedException::class);
|
||||
|
||||
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
|
||||
$root = $this->getMockBuilder('\OC\Files\Node\Root')
|
||||
$root = $this->getMockBuilder(Root::class)
|
||||
->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
|
||||
->getMock();
|
||||
|
||||
|
|
@ -86,7 +88,7 @@ class FileTest extends NodeTest {
|
|||
|
||||
public function testPutContent(): void {
|
||||
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
|
||||
$root = $this->getMockBuilder('\OC\Files\Node\Root')
|
||||
$root = $this->getMockBuilder(Root::class)
|
||||
->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
|
||||
->getMock();
|
||||
|
||||
|
|
@ -113,7 +115,7 @@ class FileTest extends NodeTest {
|
|||
$this->expectException(\OCP\Files\NotPermittedException::class);
|
||||
|
||||
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
|
||||
$root = $this->getMockBuilder('\OC\Files\Node\Root')
|
||||
$root = $this->getMockBuilder(Root::class)
|
||||
->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
|
||||
->getMock();
|
||||
|
||||
|
|
@ -128,7 +130,7 @@ class FileTest extends NodeTest {
|
|||
|
||||
public function testGetMimeType(): void {
|
||||
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
|
||||
$root = $this->getMockBuilder('\OC\Files\Node\Root')
|
||||
$root = $this->getMockBuilder(Root::class)
|
||||
->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
|
||||
->getMock();
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
*
|
||||
* @package Test\Files\Node
|
||||
*/
|
||||
class FolderTest extends NodeTest {
|
||||
class FolderTest extends NodeTestCase {
|
||||
protected function createTestNode($root, $view, $path, array $data = [], $internalPath = '', $storage = null) {
|
||||
$view->expects($this->any())
|
||||
->method('getRoot')
|
||||
|
|
@ -337,7 +337,7 @@ class FolderTest extends NodeTest {
|
|||
$manager = $this->createMock(Manager::class);
|
||||
$view = $this->getRootViewMock();
|
||||
$root = $this->getMockBuilder(Root::class)
|
||||
->setMethods(['getUser', 'getMountsIn', 'getMount'])
|
||||
->onlyMethods(['getUser', 'getMountsIn', 'getMount'])
|
||||
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
|
||||
->getMock();
|
||||
$root->expects($this->any())
|
||||
|
|
@ -499,7 +499,7 @@ class FolderTest extends NodeTest {
|
|||
$manager = $this->createMock(Manager::class);
|
||||
$view = $this->getRootViewMock();
|
||||
$root = $this->getMockBuilder(Root::class)
|
||||
->setMethods(['getMountsIn', 'getMount'])
|
||||
->onlyMethods(['getMountsIn', 'getMount'])
|
||||
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
|
||||
->getMock();
|
||||
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
|
||||
|
|
@ -548,7 +548,7 @@ class FolderTest extends NodeTest {
|
|||
$manager = $this->createMock(Manager::class);
|
||||
$view = $this->getRootViewMock();
|
||||
$root = $this->getMockBuilder(Root::class)
|
||||
->setMethods(['getMountsIn', 'getMount'])
|
||||
->onlyMethods(['getMountsIn', 'getMount'])
|
||||
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
|
||||
->getMock();
|
||||
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
|
||||
|
|
@ -593,7 +593,7 @@ class FolderTest extends NodeTest {
|
|||
$manager = $this->createMock(Manager::class);
|
||||
$view = $this->getRootViewMock();
|
||||
$root = $this->getMockBuilder(Root::class)
|
||||
->setMethods(['getMountsIn', 'getMount'])
|
||||
->onlyMethods(['getMountsIn', 'getMount'])
|
||||
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
|
||||
->getMock();
|
||||
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
|
||||
|
|
@ -637,7 +637,7 @@ class FolderTest extends NodeTest {
|
|||
$manager = $this->createMock(Manager::class);
|
||||
$view = $this->getRootViewMock();
|
||||
$root = $this->getMockBuilder(Root::class)
|
||||
->setMethods(['getMountsIn', 'getMount'])
|
||||
->onlyMethods(['getMountsIn', 'getMount'])
|
||||
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
|
||||
->getMock();
|
||||
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
|
||||
|
|
@ -681,7 +681,7 @@ class FolderTest extends NodeTest {
|
|||
$this->assertEquals('/bar/foo/asd/foo/qwerty', $result[1]->getPath());
|
||||
}
|
||||
|
||||
public function uniqueNameProvider() {
|
||||
public static function uniqueNameProvider(): array {
|
||||
return [
|
||||
// input, existing, expected
|
||||
['foo', [], 'foo'],
|
||||
|
|
@ -698,7 +698,7 @@ class FolderTest extends NodeTest {
|
|||
$folderPath = '/bar/foo';
|
||||
$view = $this->getRootViewMock();
|
||||
$root = $this->getMockBuilder(Root::class)
|
||||
->setMethods(['getUser', 'getMountsIn', 'getMount'])
|
||||
->onlyMethods(['getUser', 'getMountsIn', 'getMount'])
|
||||
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
|
||||
->getMock();
|
||||
|
||||
|
|
@ -723,7 +723,7 @@ class FolderTest extends NodeTest {
|
|||
$view = $this->getRootViewMock();
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
|
||||
$root = $this->getMockBuilder(Root::class)
|
||||
->setMethods(['getUser', 'getMountsIn', 'getMount'])
|
||||
->onlyMethods(['getUser', 'getMountsIn', 'getMount'])
|
||||
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
|
||||
->getMock();
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\FileInfo $folderInfo */
|
||||
|
|
@ -792,7 +792,7 @@ class FolderTest extends NodeTest {
|
|||
$view = $this->getRootViewMock();
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
|
||||
$root = $this->getMockBuilder(Root::class)
|
||||
->setMethods(['getUser', 'getMountsIn', 'getMount'])
|
||||
->onlyMethods(['getUser', 'getMountsIn', 'getMount'])
|
||||
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
|
||||
->getMock();
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\FileInfo $folderInfo */
|
||||
|
|
@ -859,7 +859,7 @@ class FolderTest extends NodeTest {
|
|||
$view = $this->getRootViewMock();
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
|
||||
$root = $this->getMockBuilder(Root::class)
|
||||
->setMethods(['getUser', 'getMountsIn', 'getMount'])
|
||||
->onlyMethods(['getUser', 'getMountsIn', 'getMount'])
|
||||
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
|
||||
->getMock();
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\FileInfo $folderInfo */
|
||||
|
|
@ -910,7 +910,7 @@ class FolderTest extends NodeTest {
|
|||
$this->assertEquals([$id1], $ids);
|
||||
}
|
||||
|
||||
public function offsetLimitProvider() {
|
||||
public static function offsetLimitProvider(): array {
|
||||
return [
|
||||
[0, 10, ['/bar/foo/foo1', '/bar/foo/foo2', '/bar/foo/foo3', '/bar/foo/foo4', '/bar/foo/sub1/foo5', '/bar/foo/sub1/foo6', '/bar/foo/sub2/foo7', '/bar/foo/sub2/foo8'], []],
|
||||
[0, 5, ['/bar/foo/foo1', '/bar/foo/foo2', '/bar/foo/foo3', '/bar/foo/foo4', '/bar/foo/sub1/foo5'], []],
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class HookConnectorTest extends TestCase {
|
|||
\OC_Util::tearDownFS();
|
||||
}
|
||||
|
||||
public function viewToNodeProvider() {
|
||||
public static function viewToNodeProvider(): array {
|
||||
return [
|
||||
[function () {
|
||||
Filesystem::file_put_contents('test.txt', 'asd');
|
||||
|
|
@ -195,7 +195,7 @@ class HookConnectorTest extends TestCase {
|
|||
$this->assertEquals('/' . $this->userId . '/files/test.txt', $newDispatcherNode->getPath());
|
||||
}
|
||||
|
||||
public function viewToNodeProviderCopyRename() {
|
||||
public static function viewToNodeProviderCopyRename(): array {
|
||||
return [
|
||||
[function () {
|
||||
Filesystem::file_put_contents('source', 'asd');
|
||||
|
|
|
|||
|
|
@ -21,13 +21,14 @@ use OCP\ICacheFactory;
|
|||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use OC\Files\Node\Root;
|
||||
|
||||
/**
|
||||
* Class NodeTest
|
||||
*
|
||||
* @package Test\Files\Node
|
||||
*/
|
||||
abstract class NodeTest extends \Test\TestCase {
|
||||
abstract class NodeTestCase extends \Test\TestCase {
|
||||
/** @var \OC\User\User */
|
||||
protected $user;
|
||||
/** @var \OC\Files\Mount\Manager */
|
||||
|
|
@ -71,7 +72,7 @@ abstract class NodeTest extends \Test\TestCase {
|
|||
->willReturnCallback(function () {
|
||||
return new ArrayCache();
|
||||
});
|
||||
$this->root = $this->getMockBuilder('\OC\Files\Node\Root')
|
||||
$this->root = $this->getMockBuilder(Root::class)
|
||||
->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
|
||||
->getMock();
|
||||
}
|
||||
|
|
@ -592,7 +593,7 @@ abstract class NodeTest extends \Test\TestCase {
|
|||
$this->assertEquals('/bar/asd', $node->getPath());
|
||||
}
|
||||
|
||||
public function moveOrCopyProvider() {
|
||||
public static function moveOrCopyProvider(): array {
|
||||
return [
|
||||
['move', 'rename', 'preRename', 'postRename'],
|
||||
['copy', 'copy', 'preCopy', 'postCopy'],
|
||||
|
|
@ -608,9 +609,9 @@ abstract class NodeTest extends \Test\TestCase {
|
|||
*/
|
||||
public function testMoveCopyHooks($operationMethod, $viewMethod, $preHookName, $postHookName): void {
|
||||
/** @var IRootFolder|\PHPUnit\Framework\MockObject\MockObject $root */
|
||||
$root = $this->getMockBuilder('\OC\Files\Node\Root')
|
||||
$root = $this->getMockBuilder(Root::class)
|
||||
->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
|
||||
->setMethods(['get'])
|
||||
->onlyMethods(['get'])
|
||||
->getMock();
|
||||
|
||||
$this->view->expects($this->any())
|
||||
|
|
@ -11,7 +11,7 @@ use OC\Files\ObjectStore\Azure;
|
|||
/**
|
||||
* @group PRIMARY-azure
|
||||
*/
|
||||
class AzureTest extends ObjectStoreTest {
|
||||
class AzureTest extends ObjectStoreTestCase {
|
||||
protected function getInstance() {
|
||||
$config = \OC::$server->getConfig()->getSystemValue('objectstore');
|
||||
if (!is_array($config) || $config['class'] !== 'OC\\Files\\ObjectStore\\Azure') {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Test\Files\ObjectStore;
|
|||
use OC\Files\ObjectStore\StorageObjectStore;
|
||||
use OC\Files\Storage\Temporary;
|
||||
|
||||
class LocalTest extends ObjectStoreTest {
|
||||
class LocalTest extends ObjectStoreTestCase {
|
||||
/**
|
||||
* @return \OCP\Files\ObjectStore\IObjectStore
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class MapperTest extends \Test\TestCase {
|
|||
$this->mapper = new Mapper($this->user, $this->config);
|
||||
}
|
||||
|
||||
public function dataGetBucket() {
|
||||
public static function dataGetBucket(): array {
|
||||
return [
|
||||
['user', 64, 0, '17'],
|
||||
['USER', 64, 0, '0'],
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ namespace Test\Files\ObjectStore;
|
|||
|
||||
use OC\Files\ObjectStore\StorageObjectStore;
|
||||
use OC\Files\Storage\Temporary;
|
||||
use Test\Files\Storage\StoragesTest;
|
||||
use Test\Files\Storage\StoragesTestCase;
|
||||
|
||||
/**
|
||||
* @group DB
|
||||
*/
|
||||
class ObjectStoreStoragesDifferentBucketTest extends StoragesTest {
|
||||
class ObjectStoreStoragesDifferentBucketTest extends StoragesTestCase {
|
||||
/**
|
||||
* @var \OCP\Files\ObjectStore\IObjectStore
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ namespace Test\Files\ObjectStore;
|
|||
|
||||
use OC\Files\ObjectStore\StorageObjectStore;
|
||||
use OC\Files\Storage\Temporary;
|
||||
use Test\Files\Storage\StoragesTest;
|
||||
use Test\Files\Storage\StoragesTestCase;
|
||||
|
||||
/**
|
||||
* @group DB
|
||||
*/
|
||||
class ObjectStoreStoragesSameBucketTest extends StoragesTest {
|
||||
class ObjectStoreStoragesSameBucketTest extends StoragesTestCase {
|
||||
/**
|
||||
* @var \OCP\Files\ObjectStore\IObjectStore
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -9,10 +9,12 @@ namespace Test\Files\ObjectStore;
|
|||
|
||||
use Test\TestCase;
|
||||
|
||||
abstract class ObjectStoreTest extends TestCase {
|
||||
abstract class ObjectStoreTestCase extends TestCase {
|
||||
/** @var string[] */
|
||||
private $cleanup = [];
|
||||
|
||||
private $instance = nulL;
|
||||
|
||||
/**
|
||||
* @return \OCP\Files\ObjectStore\IObjectStore
|
||||
*/
|
||||
|
|
@ -22,13 +24,20 @@ abstract class ObjectStoreTest extends TestCase {
|
|||
$this->cleanup[] = $urn;
|
||||
}
|
||||
|
||||
public function tearDown(): void {
|
||||
parent::tearDown();
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$instance = $this->getInstance();
|
||||
foreach ($this->cleanup as $urn) {
|
||||
$instance->deleteObject($urn);
|
||||
$this->instance = $this->getInstance();
|
||||
}
|
||||
|
||||
public function tearDown(): void {
|
||||
if ($this->instance) {
|
||||
foreach ($this->cleanup as $urn) {
|
||||
$this->instance->deleteObject($urn);
|
||||
}
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
protected function stringToStream($data) {
|
||||
|
|
@ -44,7 +44,7 @@ class NonSeekableStream extends Wrapper {
|
|||
/**
|
||||
* @group PRIMARY-s3
|
||||
*/
|
||||
class S3Test extends ObjectStoreTest {
|
||||
class S3Test extends ObjectStoreTestCase {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$s3 = $this->getInstance();
|
||||
|
|
@ -126,7 +126,7 @@ class S3Test extends ObjectStoreTest {
|
|||
}
|
||||
|
||||
/** File size to upload in bytes */
|
||||
public function dataFileSizes() {
|
||||
public static function dataFileSizes(): array {
|
||||
return [
|
||||
[1000000], [2000000], [5242879], [5242880], [5242881], [10000000]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use OC\Files\ObjectStore\Swift;
|
|||
/**
|
||||
* @group PRIMARY-swift
|
||||
*/
|
||||
class SwiftTest extends ObjectStoreTest {
|
||||
class SwiftTest extends ObjectStoreTestCase {
|
||||
/**
|
||||
* @return \OCP\Files\ObjectStore\IObjectStore
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ abstract class Storage extends \Test\TestCase {
|
|||
$this->assertEquals([], $content);
|
||||
}
|
||||
|
||||
public function fileNameProvider() {
|
||||
public static function fileNameProvider(): array {
|
||||
return [
|
||||
['file.txt'],
|
||||
[' file.txt'],
|
||||
|
|
@ -119,7 +119,7 @@ abstract class Storage extends \Test\TestCase {
|
|||
];
|
||||
}
|
||||
|
||||
public function directoryProvider() {
|
||||
public static function directoryProvider(): array {
|
||||
return [
|
||||
['folder'],
|
||||
[' folder'],
|
||||
|
|
@ -130,7 +130,7 @@ abstract class Storage extends \Test\TestCase {
|
|||
];
|
||||
}
|
||||
|
||||
public function loremFileProvider() {
|
||||
public static function loremFileProvider(): array {
|
||||
$root = \OC::$SERVERROOT . '/tests/data/';
|
||||
return [
|
||||
// small file
|
||||
|
|
@ -179,7 +179,7 @@ abstract class Storage extends \Test\TestCase {
|
|||
}
|
||||
|
||||
|
||||
public function copyAndMoveProvider() {
|
||||
public static function copyAndMoveProvider(): array {
|
||||
return [
|
||||
['/source.txt', '/target.txt'],
|
||||
['/source.txt', '/target with space.txt'],
|
||||
|
|
@ -414,7 +414,7 @@ abstract class Storage extends \Test\TestCase {
|
|||
$this->assertFalse($this->instance->file_exists('folder'));
|
||||
}
|
||||
|
||||
public function hashProvider() {
|
||||
public static function hashProvider(): array {
|
||||
return [
|
||||
['Foobar', 'md5'],
|
||||
['Foobar', 'sha1'],
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Test\Files\Storage;
|
|||
|
||||
use Test\TestCase;
|
||||
|
||||
abstract class StoragesTest extends TestCase {
|
||||
abstract class StoragesTestCase extends TestCase {
|
||||
/**
|
||||
* @var \OC\Files\Storage\Storage
|
||||
*/
|
||||
|
|
@ -29,25 +29,25 @@ class EncodingTest extends \Test\Files\Storage\Storage {
|
|||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function directoryProvider() {
|
||||
public static function directoryProvider(): array {
|
||||
$a = parent::directoryProvider();
|
||||
$a[] = [self::NFC_NAME];
|
||||
return $a;
|
||||
}
|
||||
|
||||
public function fileNameProvider() {
|
||||
public static function fileNameProvider(): array {
|
||||
$a = parent::fileNameProvider();
|
||||
$a[] = [self::NFD_NAME . '.txt'];
|
||||
return $a;
|
||||
}
|
||||
|
||||
public function copyAndMoveProvider() {
|
||||
public static function copyAndMoveProvider(): array {
|
||||
$a = parent::copyAndMoveProvider();
|
||||
$a[] = [self::NFD_NAME . '.txt', self::NFC_NAME . '-renamed.txt'];
|
||||
return $a;
|
||||
}
|
||||
|
||||
public function accessNameProvider() {
|
||||
public static function accessNameProvider(): array {
|
||||
return [
|
||||
[self::NFD_NAME],
|
||||
[self::NFC_NAME],
|
||||
|
|
@ -110,7 +110,7 @@ class EncodingTest extends \Test\Files\Storage\Storage {
|
|||
$this->assertEquals('nfc', $this->instance->file_get_contents(self::NFC_NAME));
|
||||
}
|
||||
|
||||
public function encodedDirectoriesProvider() {
|
||||
public static function encodedDirectoriesProvider(): array {
|
||||
return [
|
||||
[self::NFD_NAME, self::NFC_NAME],
|
||||
[self::NFD_NAME . '/' . self::NFD_NAME, self::NFC_NAME . '/' . self::NFC_NAME],
|
||||
|
|
@ -150,7 +150,7 @@ class EncodingTest extends \Test\Files\Storage\Storage {
|
|||
$this->assertEquals('barbaric', $this->instance->file_get_contents('//' . self::NFC_NAME));
|
||||
}
|
||||
|
||||
public function sourceAndTargetDirectoryProvider() {
|
||||
public static function sourceAndTargetDirectoryProvider(): array {
|
||||
return [
|
||||
[self::NFC_NAME . '1', self::NFC_NAME . '2'],
|
||||
[self::NFD_NAME . '1', self::NFC_NAME . '2'],
|
||||
|
|
|
|||
|
|
@ -60,9 +60,9 @@ class EncryptionTest extends Storage {
|
|||
parent::setUp();
|
||||
|
||||
$mockModule = $this->buildMockModule();
|
||||
$this->encryptionManager = $this->getMockBuilder('\OC\Encryption\Manager')
|
||||
$this->encryptionManager = $this->getMockBuilder(\OC\Encryption\Manager::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getEncryptionModule', 'isEnabled'])
|
||||
->onlyMethods(['getEncryptionModule', 'isEnabled'])
|
||||
->getMock();
|
||||
$this->encryptionManager->expects($this->any())
|
||||
->method('getEncryptionModule')
|
||||
|
|
@ -76,8 +76,8 @@ class EncryptionTest extends Storage {
|
|||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->util = $this->getMockBuilder('\OC\Encryption\Util')
|
||||
->setMethods(['getUidAndFilename', 'isFile', 'isExcluded', 'stripPartialFileExtension'])
|
||||
$this->util = $this->getMockBuilder(Util::class)
|
||||
->onlyMethods(['getUidAndFilename', 'isFile', 'isExcluded', 'stripPartialFileExtension'])
|
||||
->setConstructorArgs([new View(), new Manager(
|
||||
$this->config,
|
||||
$this->createMock(ICacheFactory::class),
|
||||
|
|
@ -96,9 +96,9 @@ class EncryptionTest extends Storage {
|
|||
return $path;
|
||||
});
|
||||
|
||||
$this->file = $this->getMockBuilder('\OC\Encryption\File')
|
||||
$this->file = $this->getMockBuilder(File::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getAccessList'])
|
||||
->onlyMethods(['getAccessList'])
|
||||
->getMock();
|
||||
$this->file->expects($this->any())->method('getAccessList')->willReturn([]);
|
||||
|
||||
|
|
@ -106,12 +106,11 @@ class EncryptionTest extends Storage {
|
|||
|
||||
$this->sourceStorage = new Temporary([]);
|
||||
|
||||
$this->keyStore = $this->getMockBuilder('\OC\Encryption\Keys\Storage')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$this->keyStore = $this->createMock(\OC\Encryption\Keys\Storage::class);
|
||||
|
||||
$this->mount = $this->getMockBuilder('\OC\Files\Mount\MountPoint')
|
||||
$this->mount = $this->getMockBuilder(MountPoint::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getOption'])
|
||||
->onlyMethods(['getOption'])
|
||||
->getMock();
|
||||
$this->mount->expects($this->any())->method('getOption')->willReturnCallback(function ($option, $default) {
|
||||
if ($option === 'encrypt' && $default === true) {
|
||||
|
|
@ -154,7 +153,7 @@ class EncryptionTest extends Storage {
|
|||
$this->arrayCache
|
||||
]
|
||||
)
|
||||
->setMethods(['getMetaData', 'getCache', 'getEncryptionModule'])
|
||||
->onlyMethods(['getMetaData', 'getCache', 'getEncryptionModule'])
|
||||
->getMock();
|
||||
|
||||
$this->instance->expects($this->any())
|
||||
|
|
@ -175,7 +174,7 @@ class EncryptionTest extends Storage {
|
|||
protected function buildMockModule(): IEncryptionModule&MockObject {
|
||||
$this->encryptionModule = $this->getMockBuilder('\OCP\Encryption\IEncryptionModule')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getId', 'getDisplayName', 'begin', 'end', 'encrypt', 'decrypt', 'update', 'shouldEncrypt', 'getUnencryptedBlockSize', 'isReadable', 'encryptAll', 'prepareDecryptAll', 'isReadyForUser', 'needDetailedAccessList'])
|
||||
->onlyMethods(['getId', 'getDisplayName', 'begin', 'end', 'encrypt', 'decrypt', 'update', 'shouldEncrypt', 'getUnencryptedBlockSize', 'isReadable', 'encryptAll', 'prepareDecryptAll', 'isReadyForUser', 'needDetailedAccessList'])
|
||||
->getMock();
|
||||
|
||||
$this->encryptionModule->expects($this->any())->method('getId')->willReturn('UNIT_TEST_MODULE');
|
||||
|
|
@ -235,7 +234,7 @@ class EncryptionTest extends Storage {
|
|||
$this->arrayCache,
|
||||
]
|
||||
)
|
||||
->setMethods(['getCache', 'verifyUnencryptedSize'])
|
||||
->onlyMethods(['getCache', 'verifyUnencryptedSize'])
|
||||
->getMock();
|
||||
|
||||
if ($unencryptedSizeSet) {
|
||||
|
|
@ -278,7 +277,7 @@ class EncryptionTest extends Storage {
|
|||
}
|
||||
}
|
||||
|
||||
public function dataTestGetMetaData() {
|
||||
public static function dataTestGetMetaData(): array {
|
||||
return [
|
||||
['/test.txt', ['size' => 42, 'encrypted' => 2, 'encryptedVersion' => 2, 'fileid' => 1], true, true, 12, ['size' => 12, 'encrypted' => true, 'encryptedVersion' => 2]],
|
||||
['/test.txt', null, true, true, 12, null],
|
||||
|
|
@ -313,7 +312,7 @@ class EncryptionTest extends Storage {
|
|||
$this->arrayCache,
|
||||
]
|
||||
)
|
||||
->setMethods(['getCache', 'verifyUnencryptedSize'])
|
||||
->onlyMethods(['getCache', 'verifyUnencryptedSize'])
|
||||
->getMock();
|
||||
|
||||
$this->instance->expects($this->any())->method('getCache')->willReturn($cache);
|
||||
|
|
@ -357,7 +356,7 @@ class EncryptionTest extends Storage {
|
|||
$this->arrayCache,
|
||||
]
|
||||
)
|
||||
->setMethods(['fixUnencryptedSize'])
|
||||
->onlyMethods(['fixUnencryptedSize'])
|
||||
->getMock();
|
||||
|
||||
$sourceStorage->expects($this->once())->method('filesize')->willReturn($encryptedSize);
|
||||
|
|
@ -380,7 +379,7 @@ class EncryptionTest extends Storage {
|
|||
);
|
||||
}
|
||||
|
||||
public function dataTestVerifyUnencryptedSize() {
|
||||
public static function dataTestVerifyUnencryptedSize(): array {
|
||||
return [
|
||||
[120, 80, false, 80],
|
||||
[120, 120, false, 80],
|
||||
|
|
@ -435,7 +434,7 @@ class EncryptionTest extends Storage {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function dataTestCopyAndRename() {
|
||||
public static function dataTestCopyAndRename(): array {
|
||||
return [
|
||||
['source', 'target', true, false, false],
|
||||
['source', 'target', true, true, false],
|
||||
|
|
@ -496,7 +495,7 @@ class EncryptionTest extends Storage {
|
|||
$encryptionStorage->rmdir($path);
|
||||
}
|
||||
|
||||
public function dataTestRmdir() {
|
||||
public static function dataTestRmdir(): array {
|
||||
return [
|
||||
['/file.txt', true, true, true],
|
||||
['/file.txt', false, true, true],
|
||||
|
|
@ -531,7 +530,7 @@ class EncryptionTest extends Storage {
|
|||
);
|
||||
}
|
||||
|
||||
public function dataTestCopyKeys() {
|
||||
public static function dataTestCopyKeys(): array {
|
||||
return [
|
||||
[true, false],
|
||||
[false, true],
|
||||
|
|
@ -592,7 +591,7 @@ class EncryptionTest extends Storage {
|
|||
$this->arrayCache,
|
||||
]
|
||||
)
|
||||
->setMethods(['getCache', 'readFirstBlock'])
|
||||
->onlyMethods(['getCache', 'readFirstBlock'])
|
||||
->getMock();
|
||||
|
||||
$instance->method('getCache')->willReturn($cache);
|
||||
|
|
@ -618,7 +617,7 @@ class EncryptionTest extends Storage {
|
|||
$this->invokePrivate($instance, 'getHeader', [$path]);
|
||||
}
|
||||
|
||||
public function dataTestGetHeader() {
|
||||
public static function dataTestGetHeader(): array {
|
||||
return [
|
||||
['/foo/bar.txt', false, '/foo/bar.txt'],
|
||||
['/foo/bar.txt.part', false, '/foo/bar.txt'],
|
||||
|
|
@ -635,7 +634,7 @@ class EncryptionTest extends Storage {
|
|||
* @dataProvider dataTestGetHeaderAddLegacyModule
|
||||
*/
|
||||
public function testGetHeaderAddLegacyModule($header, $isEncrypted, $strippedPathExists, $expected): void {
|
||||
$sourceStorage = $this->getMockBuilder('\OC\Files\Storage\Storage')
|
||||
$sourceStorage = $this->getMockBuilder(\OC\Files\Storage\Storage::class)
|
||||
->disableOriginalConstructor()->getMock();
|
||||
|
||||
$sourceStorage->expects($this->once())
|
||||
|
|
@ -643,7 +642,7 @@ class EncryptionTest extends Storage {
|
|||
->with('test.txt')
|
||||
->willReturn($strippedPathExists);
|
||||
|
||||
$util = $this->getMockBuilder('\OC\Encryption\Util')
|
||||
$util = $this->getMockBuilder(Util::class)
|
||||
->onlyMethods(['stripPartialFileExtension', 'parseRawHeader'])
|
||||
->setConstructorArgs([new View(), new Manager(
|
||||
$this->config,
|
||||
|
|
@ -658,8 +657,7 @@ class EncryptionTest extends Storage {
|
|||
return $path;
|
||||
});
|
||||
|
||||
$cache = $this->getMockBuilder('\OC\Files\Cache\Cache')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$cache = $this->createMock(Cache::class);
|
||||
$cache->expects($this->any())
|
||||
->method('get')
|
||||
->willReturnCallback(function ($path) use ($isEncrypted) {
|
||||
|
|
@ -685,7 +683,7 @@ class EncryptionTest extends Storage {
|
|||
$this->arrayCache,
|
||||
]
|
||||
)
|
||||
->setMethods(['readFirstBlock', 'getCache'])
|
||||
->onlyMethods(['readFirstBlock', 'getCache'])
|
||||
->getMock();
|
||||
|
||||
$instance->method('readFirstBlock')->willReturn('');
|
||||
|
|
@ -701,7 +699,7 @@ class EncryptionTest extends Storage {
|
|||
}
|
||||
}
|
||||
|
||||
public function dataTestGetHeaderAddLegacyModule() {
|
||||
public static function dataTestGetHeaderAddLegacyModule(): array {
|
||||
return [
|
||||
[['cipher' => 'AES-128'], true, true, ['cipher' => 'AES-128', Util::HEADER_ENCRYPTION_MODULE_KEY => 'OC_DEFAULT_MODULE']],
|
||||
[[], true, false, []],
|
||||
|
|
@ -710,7 +708,7 @@ class EncryptionTest extends Storage {
|
|||
];
|
||||
}
|
||||
|
||||
public function dataCopyBetweenStorage() {
|
||||
public static function dataCopyBetweenStorage(): array {
|
||||
return [
|
||||
[true, true, true],
|
||||
[true, false, false],
|
||||
|
|
@ -859,7 +857,7 @@ class EncryptionTest extends Storage {
|
|||
$this->arrayCache
|
||||
]
|
||||
)
|
||||
->setMethods(['updateUnencryptedSize', 'getCache'])
|
||||
->onlyMethods(['updateUnencryptedSize', 'getCache'])
|
||||
->getMock();
|
||||
|
||||
$targetStorage->expects($this->once())->method('copyFromStorage')
|
||||
|
|
@ -901,7 +899,7 @@ class EncryptionTest extends Storage {
|
|||
$this->assertSame($copyResult, $result);
|
||||
}
|
||||
|
||||
public function dataTestCopyBetweenStorageVersions() {
|
||||
public static function dataTestCopyBetweenStorageVersions(): array {
|
||||
return [
|
||||
['/files/foo.txt', '/files_versions/foo.txt.768743', true, true],
|
||||
['/files/foo.txt', '/files_versions/foo.txt.768743', true, false],
|
||||
|
|
@ -926,7 +924,7 @@ class EncryptionTest extends Storage {
|
|||
);
|
||||
}
|
||||
|
||||
public function dataTestIsVersion() {
|
||||
public static function dataTestIsVersion(): array {
|
||||
return [
|
||||
['files_versions/foo', true],
|
||||
['/files_versions/foo', true],
|
||||
|
|
@ -976,7 +974,7 @@ class EncryptionTest extends Storage {
|
|||
$arrayCache
|
||||
]
|
||||
)
|
||||
->setMethods(['getFullPath', 'getEncryptionModule'])
|
||||
->onlyMethods(['getFullPath', 'getEncryptionModule'])
|
||||
->getMock();
|
||||
|
||||
if ($encryptionModule === true) {
|
||||
|
|
@ -1018,7 +1016,7 @@ class EncryptionTest extends Storage {
|
|||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
public function dataTestShouldEncrypt() {
|
||||
public static function dataTestShouldEncrypt(): array {
|
||||
return [
|
||||
[false, false, false, false],
|
||||
[true, false, false, false],
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class QuotaTest extends \Test\Files\Storage\Storage {
|
|||
|
||||
public function testFreeSpaceWithUnknownDiskSpace(): void {
|
||||
$storage = $this->getMockBuilder(Local::class)
|
||||
->setMethods(['free_space'])
|
||||
->onlyMethods(['free_space'])
|
||||
->setConstructorArgs([['datadir' => $this->tmpDir]])
|
||||
->getMock();
|
||||
$storage->expects($this->any())
|
||||
|
|
@ -132,7 +132,7 @@ class QuotaTest extends \Test\Files\Storage\Storage {
|
|||
|
||||
public function testReturnFalseWhenFopenFailed(): void {
|
||||
$failStorage = $this->getMockBuilder(Local::class)
|
||||
->setMethods(['fopen'])
|
||||
->onlyMethods(['fopen'])
|
||||
->setConstructorArgs([['datadir' => $this->tmpDir]])
|
||||
->getMock();
|
||||
$failStorage->expects($this->any())
|
||||
|
|
|
|||
Loading…
Reference in a new issue