summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2016-09-07 20:01:13 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-09-07 20:42:37 +0200
commit7656a8fa1210c096e677720f8ba0ab93affdd0e3 (patch)
tree3d2083c3b0e5596cfa5a2d6ae83f2600510b4fd7
parenta819fd3f1eb455871ce424efc8be311582a1d43a (diff)
downloadnextcloud-server-7656a8fa1210c096e677720f8ba0ab93affdd0e3.tar.gz
nextcloud-server-7656a8fa1210c096e677720f8ba0ab93affdd0e3.zip
File getMock Files tests
-rw-r--r--tests/lib/Files/Mount/MountPointTest.php9
-rw-r--r--tests/lib/Files/Mount/ObjectHomeMountProviderTest.php8
-rw-r--r--tests/lib/Files/ObjectStore/MapperTest.php5
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncryptionTest.php19
-rw-r--r--tests/lib/Files/Stream/EncryptionTest.php12
5 files changed, 30 insertions, 23 deletions
diff --git a/tests/lib/Files/Mount/MountPointTest.php b/tests/lib/Files/Mount/MountPointTest.php
index 799f441a1ab..03b106eb598 100644
--- a/tests/lib/Files/Mount/MountPointTest.php
+++ b/tests/lib/Files/Mount/MountPointTest.php
@@ -8,15 +8,18 @@
namespace Test\Files\Mount;
+use OC\Files\Storage\StorageFactory;
+use OCP\Files\Storage;
+
class MountPointTest extends \Test\TestCase {
public function testGetStorage() {
- $storage = $this->getMock('\OCP\Files\Storage');
+ $storage = $this->createMock(Storage::class);
$storage->expects($this->once())
->method('getId')
->will($this->returnValue(123));
- $loader = $this->getMock('\OC\Files\Storage\StorageFactory');
+ $loader = $this->createMock(StorageFactory::class);
$loader->expects($this->once())
->method('wrap')
->will($this->returnValue($storage));
@@ -38,7 +41,7 @@ class MountPointTest extends \Test\TestCase {
}
public function testInvalidStorage() {
- $loader = $this->getMock('\OC\Files\Storage\StorageFactory');
+ $loader = $this->createMock(StorageFactory::class);
$loader->expects($this->once())
->method('wrap')
->will($this->throwException(new \Exception('Test storage init exception')));
diff --git a/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php b/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
index 5d987f0d059..0af90991d60 100644
--- a/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
+++ b/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
@@ -24,9 +24,9 @@ class ObjectHomeMountProviderTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
- $this->config = $this->getMock('OCP\IConfig');
- $this->user = $this->getMock('OCP\IUser');
- $this->loader = $this->getMock('OCP\Files\Storage\IStorageFactory');
+ $this->config = $this->createMock(IConfig::class);
+ $this->user = $this->createMock(IUser::class);
+ $this->loader = $this->createMock(IStorageFactory::class);
$this->provider = new ObjectHomeMountProvider($this->config);
}
@@ -241,4 +241,4 @@ class FakeObjectStore {
public function getArguments() {
return $this->arguments;
}
-} \ No newline at end of file
+}
diff --git a/tests/lib/Files/ObjectStore/MapperTest.php b/tests/lib/Files/ObjectStore/MapperTest.php
index 1ebb67a6905..18bdcdfd005 100644
--- a/tests/lib/Files/ObjectStore/MapperTest.php
+++ b/tests/lib/Files/ObjectStore/MapperTest.php
@@ -22,6 +22,7 @@ namespace Test\Files\ObjectStore;
use OC\Files\ObjectStore\Mapper;
+use OCP\IUser;
class MapperTest extends \Test\TestCase {
@@ -39,7 +40,7 @@ class MapperTest extends \Test\TestCase {
* @param string $expectedBucket
*/
public function testGetBucket($username, $expectedBucket) {
- $user = $this->getMock('OCP\IUser');
+ $user = $this->createMock(IUser::class);
$user->method('getUID')
->willReturn($username);
@@ -47,4 +48,4 @@ class MapperTest extends \Test\TestCase {
$this->assertSame($expectedBucket, $mapper->getBucket());
}
-} \ No newline at end of file
+}
diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
index e9ebf2f3bdf..55b38d546de 100644
--- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
@@ -5,7 +5,10 @@ namespace Test\Files\Storage\Wrapper;
use OC\Encryption\Util;
use OC\Files\Storage\Temporary;
use OC\Files\View;
+use OC\Log;
+use OC\Memcache\ArrayCache;
use OC\User\Manager;
+use OCP\Files\Cache\ICache;
use Test\Files\Storage\Storage;
class EncryptionTest extends Storage {
@@ -108,7 +111,7 @@ class EncryptionTest extends Storage {
->method('getEncryptionModule')
->willReturn($mockModule);
- $this->arrayCache = $this->getMock('OC\Memcache\ArrayCache');
+ $this->arrayCache = $this->createMock(ArrayCache::class);
$this->config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()
->getMock();
@@ -116,10 +119,10 @@ class EncryptionTest extends Storage {
->disableOriginalConstructor()
->getMock();
- $this->util = $this->getMock(
- '\OC\Encryption\Util',
- ['getUidAndFilename', 'isFile', 'isExcluded'],
- [new View(), new Manager(), $this->groupManager, $this->config, $this->arrayCache]);
+ $this->util = $this->getMockBuilder('\OC\Encryption\Util')
+ ->setMethods(['getUidAndFilename', 'isFile', 'isExcluded'])
+ ->setConstructorArgs([new View(), new Manager(), $this->groupManager, $this->config, $this->arrayCache])
+ ->getMock();
$this->util->expects($this->any())
->method('getUidAndFilename')
->willReturnCallback(function ($path) {
@@ -132,7 +135,7 @@ class EncryptionTest extends Storage {
->getMock();
$this->file->expects($this->any())->method('getAccessList')->willReturn([]);
- $this->logger = $this->getMock('\OC\Log');
+ $this->logger = $this->createMock(Log::class);
$this->sourceStorage = new Temporary(array());
@@ -713,7 +716,7 @@ class EncryptionTest extends Storage {
$temp = \OC::$server->getTempManager();
return fopen($temp->getTemporaryFile(), $mode);
});
- $cache = $this->getMock('\OCP\Files\Cache\ICache');
+ $cache = $this->createMock(ICache::class);
$cache->expects($this->once())
->method('get')
->with($sourceInternalPath)
@@ -763,7 +766,7 @@ class EncryptionTest extends Storage {
return fopen($temp->getTemporaryFile(), $mode);
});
if($expectedEncrypted) {
- $cache = $this->getMock('\OCP\Files\Cache\ICache');
+ $cache = $this->createMock(ICache::class);
$cache->expects($this->once())
->method('get')
->with($sourceInternalPath)
diff --git a/tests/lib/Files/Stream/EncryptionTest.php b/tests/lib/Files/Stream/EncryptionTest.php
index 45204e48d09..6f3c879f9e6 100644
--- a/tests/lib/Files/Stream/EncryptionTest.php
+++ b/tests/lib/Files/Stream/EncryptionTest.php
@@ -3,6 +3,7 @@
namespace Test\Files\Stream;
use OC\Files\View;
+use OC\Memcache\ArrayCache;
class EncryptionTest extends \Test\TestCase {
@@ -31,7 +32,7 @@ class EncryptionTest extends \Test\TestCase {
$config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()
->getMock();
- $arrayCache = $this->getMock('OC\Memcache\ArrayCache');
+ $arrayCache = $this->createMock(ArrayCache::class);
$groupManager = $this->getMockBuilder('\OC\Group\Manager')
->disableOriginalConstructor()
->getMock();
@@ -40,11 +41,10 @@ class EncryptionTest extends \Test\TestCase {
->setMethods(['getAccessList'])
->getMock();
$file->expects($this->any())->method('getAccessList')->willReturn([]);
- $util = $this->getMock(
- '\OC\Encryption\Util',
- ['getUidAndFilename'],
- [new View(), new \OC\User\Manager(), $groupManager, $config, $arrayCache]
- );
+ $util = $this->getMockBuilder('\OC\Encryption\Util')
+ ->setMethods(['getUidAndFilename'])
+ ->setConstructorArgs([new View(), new \OC\User\Manager(), $groupManager, $config, $arrayCache])
+ ->getMock();
$util->expects($this->any())
->method('getUidAndFilename')
->willReturn(['user1', $internalPath]);