File getMock Files tests
This commit is contained in:
parent
a819fd3f1e
commit
7656a8fa12
|
@ -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')));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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]);
|
||||
|
|
Loading…
Reference in New Issue