Merge pull request #1314 from nextcloud/nodb_getmock_be_gone
Fix PHPUnit warnings on NODB runs
This commit is contained in:
commit
0a33ebdb13
|
@ -26,6 +26,7 @@ namespace OCA\Encryption\Tests;
|
||||||
|
|
||||||
|
|
||||||
use OCA\Encryption\HookManager;
|
use OCA\Encryption\HookManager;
|
||||||
|
use OCP\IConfig;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
class HookManagerTest extends TestCase {
|
class HookManagerTest extends TestCase {
|
||||||
|
@ -42,7 +43,7 @@ class HookManagerTest extends TestCase {
|
||||||
self::$instance->registerHook([
|
self::$instance->registerHook([
|
||||||
$this->getMockBuilder('OCA\Encryption\Hooks\Contracts\IHook')->disableOriginalConstructor()->getMock(),
|
$this->getMockBuilder('OCA\Encryption\Hooks\Contracts\IHook')->disableOriginalConstructor()->getMock(),
|
||||||
$this->getMockBuilder('OCA\Encryption\Hooks\Contracts\IHook')->disableOriginalConstructor()->getMock(),
|
$this->getMockBuilder('OCA\Encryption\Hooks\Contracts\IHook')->disableOriginalConstructor()->getMock(),
|
||||||
$this->getMock('NotIHook')
|
$this->createMock(IConfig::class)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$hookInstances = self::invokePrivate(self::$instance, 'hookInstances');
|
$hookInstances = self::invokePrivate(self::$instance, 'hookInstances');
|
||||||
|
|
|
@ -170,7 +170,7 @@ class BackupCodeStorageTest extends TestCase {
|
||||||
->will($this->returnValue($codes));
|
->will($this->returnValue($codes));
|
||||||
$this->hasher->expects($this->once())
|
$this->hasher->expects($this->once())
|
||||||
->method('verify')
|
->method('verify')
|
||||||
->with('CHALLENGE', 'HASHEDVALUE')
|
->with('CHALLENGE', 'HASHEDVALUE', $this->anything())
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
$this->mapper->expects($this->once())
|
$this->mapper->expects($this->once())
|
||||||
->method('update')
|
->method('update')
|
||||||
|
@ -195,7 +195,7 @@ class BackupCodeStorageTest extends TestCase {
|
||||||
->with($user)
|
->with($user)
|
||||||
->will($this->returnValue($codes));
|
->will($this->returnValue($codes));
|
||||||
$this->hasher->expects($this->never())
|
$this->hasher->expects($this->never())
|
||||||
->method('verifiy');
|
->method('verify');
|
||||||
$this->mapper->expects($this->never())
|
$this->mapper->expects($this->never())
|
||||||
->method('update');
|
->method('update');
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,15 @@ namespace Test\Settings\Controller;
|
||||||
use OC\AppFramework\Http;
|
use OC\AppFramework\Http;
|
||||||
use OC\Authentication\Exceptions\InvalidTokenException;
|
use OC\Authentication\Exceptions\InvalidTokenException;
|
||||||
use OC\Authentication\Token\DefaultToken;
|
use OC\Authentication\Token\DefaultToken;
|
||||||
|
use OC\Authentication\Token\IProvider;
|
||||||
use OC\Authentication\Token\IToken;
|
use OC\Authentication\Token\IToken;
|
||||||
use OC\Settings\Controller\AuthSettingsController;
|
use OC\Settings\Controller\AuthSettingsController;
|
||||||
use OCP\AppFramework\Http\JSONResponse;
|
use OCP\AppFramework\Http\JSONResponse;
|
||||||
|
use OCP\IRequest;
|
||||||
|
use OCP\ISession;
|
||||||
|
use OCP\IUser;
|
||||||
|
use OCP\IUserManager;
|
||||||
|
use OCP\Security\ISecureRandom;
|
||||||
use OCP\Session\Exceptions\SessionNotAvailableException;
|
use OCP\Session\Exceptions\SessionNotAvailableException;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
|
@ -45,13 +51,13 @@ class AuthSettingsControllerTest extends TestCase {
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->request = $this->getMock('\OCP\IRequest');
|
$this->request = $this->createMock(IRequest::class);
|
||||||
$this->tokenProvider = $this->getMock('\OC\Authentication\Token\IProvider');
|
$this->tokenProvider = $this->createMock(IProvider::class);
|
||||||
$this->userManager = $this->getMock('\OCP\IUserManager');
|
$this->userManager = $this->createMock(IUserManager::class);
|
||||||
$this->session = $this->getMock('\OCP\ISession');
|
$this->session = $this->createMock(ISession::class);
|
||||||
$this->secureRandom = $this->getMock('\OCP\Security\ISecureRandom');
|
$this->secureRandom = $this->createMock(ISecureRandom::class);
|
||||||
$this->uid = 'jane';
|
$this->uid = 'jane';
|
||||||
$this->user = $this->getMock('\OCP\IUser');
|
$this->user = $this->createMock(IUser::class);
|
||||||
|
|
||||||
$this->controller = new AuthSettingsController('core', $this->request, $this->tokenProvider, $this->userManager, $this->session, $this->secureRandom, $this->uid);
|
$this->controller = new AuthSettingsController('core', $this->request, $this->tokenProvider, $this->userManager, $this->session, $this->secureRandom, $this->uid);
|
||||||
}
|
}
|
||||||
|
@ -105,8 +111,8 @@ class AuthSettingsControllerTest extends TestCase {
|
||||||
|
|
||||||
public function testCreate() {
|
public function testCreate() {
|
||||||
$name = 'Nexus 4';
|
$name = 'Nexus 4';
|
||||||
$sessionToken = $this->getMock('\OC\Authentication\Token\IToken');
|
$sessionToken = $this->createMock(IToken::class);
|
||||||
$deviceToken = $this->getMock('\OC\Authentication\Token\IToken');
|
$deviceToken = $this->createMock(IToken::class);
|
||||||
$password = '123456';
|
$password = '123456';
|
||||||
|
|
||||||
$this->session->expects($this->once())
|
$this->session->expects($this->once())
|
||||||
|
@ -175,7 +181,7 @@ class AuthSettingsControllerTest extends TestCase {
|
||||||
|
|
||||||
public function testDestroy() {
|
public function testDestroy() {
|
||||||
$id = 123;
|
$id = 123;
|
||||||
$user = $this->getMock('\OCP\IUser');
|
$user = $this->createMock(IUser::class);
|
||||||
|
|
||||||
$this->userManager->expects($this->once())
|
$this->userManager->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
|
|
@ -49,7 +49,7 @@ abstract class MapperTestUtility extends \Test\TestCase {
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$this->query = $this->getMock('\PDOStatement');
|
$this->query = $this->createMock('\PDOStatement');
|
||||||
$this->queryAt = 0;
|
$this->queryAt = 0;
|
||||||
$this->prepareAt = 0;
|
$this->prepareAt = 0;
|
||||||
$this->iterators = [];
|
$this->iterators = [];
|
||||||
|
|
|
@ -24,6 +24,8 @@ use OC\Core\Command\Integrity\SignApp;
|
||||||
use OC\IntegrityCheck\Checker;
|
use OC\IntegrityCheck\Checker;
|
||||||
use OC\IntegrityCheck\Helpers\FileAccessHelper;
|
use OC\IntegrityCheck\Helpers\FileAccessHelper;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
class SignAppTest extends TestCase {
|
class SignAppTest extends TestCase {
|
||||||
|
@ -38,12 +40,9 @@ class SignAppTest extends TestCase {
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->checker = $this->getMockBuilder('\OC\IntegrityCheck\Checker')
|
$this->checker = $this->createMock(Checker::class);
|
||||||
->disableOriginalConstructor()->getMock();
|
$this->fileAccessHelper = $this->createMock(FileAccessHelper::class);
|
||||||
$this->fileAccessHelper = $this->getMockBuilder('\OC\IntegrityCheck\Helpers\FileAccessHelper')
|
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
||||||
->disableOriginalConstructor()->getMock();
|
|
||||||
$this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
|
|
||||||
->disableOriginalConstructor()->getMock();
|
|
||||||
$this->signApp = new SignApp(
|
$this->signApp = new SignApp(
|
||||||
$this->checker,
|
$this->checker,
|
||||||
$this->fileAccessHelper,
|
$this->fileAccessHelper,
|
||||||
|
@ -52,8 +51,8 @@ class SignAppTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExecuteWithMissingPath() {
|
public function testExecuteWithMissingPath() {
|
||||||
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface');
|
$inputInterface = $this->createMock(InputInterface::class);
|
||||||
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface');
|
$outputInterface = $this->createMock(OutputInterface::class);
|
||||||
|
|
||||||
$inputInterface
|
$inputInterface
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
|
@ -80,8 +79,8 @@ class SignAppTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExecuteWithMissingPrivateKey() {
|
public function testExecuteWithMissingPrivateKey() {
|
||||||
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface');
|
$inputInterface = $this->createMock(InputInterface::class);
|
||||||
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface');
|
$outputInterface = $this->createMock(OutputInterface::class);
|
||||||
|
|
||||||
$inputInterface
|
$inputInterface
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
|
@ -108,8 +107,8 @@ class SignAppTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExecuteWithMissingCertificate() {
|
public function testExecuteWithMissingCertificate() {
|
||||||
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface');
|
$inputInterface = $this->createMock(InputInterface::class);
|
||||||
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface');
|
$outputInterface = $this->createMock(OutputInterface::class);
|
||||||
|
|
||||||
$inputInterface
|
$inputInterface
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
|
@ -136,8 +135,8 @@ class SignAppTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExecuteWithNotExistingPrivateKey() {
|
public function testExecuteWithNotExistingPrivateKey() {
|
||||||
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface');
|
$inputInterface = $this->createMock(InputInterface::class);
|
||||||
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface');
|
$outputInterface = $this->createMock(OutputInterface::class);
|
||||||
|
|
||||||
$inputInterface
|
$inputInterface
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
|
@ -170,8 +169,8 @@ class SignAppTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExecuteWithNotExistingCertificate() {
|
public function testExecuteWithNotExistingCertificate() {
|
||||||
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface');
|
$inputInterface = $this->createMock(InputInterface::class);
|
||||||
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface');
|
$outputInterface = $this->createMock(OutputInterface::class);
|
||||||
|
|
||||||
$inputInterface
|
$inputInterface
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
|
@ -209,8 +208,8 @@ class SignAppTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExecute() {
|
public function testExecute() {
|
||||||
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface');
|
$inputInterface = $this->createMock(InputInterface::class);
|
||||||
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface');
|
$outputInterface = $this->createMock(OutputInterface::class);
|
||||||
|
|
||||||
$inputInterface
|
$inputInterface
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
|
|
|
@ -23,6 +23,8 @@ namespace Test\Command\Integrity;
|
||||||
use OC\Core\Command\Integrity\SignCore;
|
use OC\Core\Command\Integrity\SignCore;
|
||||||
use OC\IntegrityCheck\Checker;
|
use OC\IntegrityCheck\Checker;
|
||||||
use OC\IntegrityCheck\Helpers\FileAccessHelper;
|
use OC\IntegrityCheck\Helpers\FileAccessHelper;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
class SignCoreTest extends TestCase {
|
class SignCoreTest extends TestCase {
|
||||||
|
@ -35,10 +37,8 @@ class SignCoreTest extends TestCase {
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->checker = $this->getMockBuilder('\OC\IntegrityCheck\Checker')
|
$this->checker = $this->createMock(Checker::class);
|
||||||
->disableOriginalConstructor()->getMock();
|
$this->fileAccessHelper = $this->createMock(FileAccessHelper::class);
|
||||||
$this->fileAccessHelper = $this->getMockBuilder('\OC\IntegrityCheck\Helpers\FileAccessHelper')
|
|
||||||
->disableOriginalConstructor()->getMock();
|
|
||||||
$this->signCore = new SignCore(
|
$this->signCore = new SignCore(
|
||||||
$this->checker,
|
$this->checker,
|
||||||
$this->fileAccessHelper
|
$this->fileAccessHelper
|
||||||
|
@ -46,8 +46,8 @@ class SignCoreTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExecuteWithMissingPrivateKey() {
|
public function testExecuteWithMissingPrivateKey() {
|
||||||
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface');
|
$inputInterface = $this->createMock(InputInterface::class);
|
||||||
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface');
|
$outputInterface = $this->createMock(OutputInterface::class);
|
||||||
|
|
||||||
$inputInterface
|
$inputInterface
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
|
@ -69,8 +69,8 @@ class SignCoreTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExecuteWithMissingCertificate() {
|
public function testExecuteWithMissingCertificate() {
|
||||||
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface');
|
$inputInterface = $this->createMock(InputInterface::class);
|
||||||
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface');
|
$outputInterface = $this->createMock(OutputInterface::class);
|
||||||
|
|
||||||
$inputInterface
|
$inputInterface
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
|
@ -92,8 +92,8 @@ class SignCoreTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExecuteWithNotExistingPrivateKey() {
|
public function testExecuteWithNotExistingPrivateKey() {
|
||||||
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface');
|
$inputInterface = $this->createMock(InputInterface::class);
|
||||||
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface');
|
$outputInterface = $this->createMock(OutputInterface::class);
|
||||||
|
|
||||||
$inputInterface
|
$inputInterface
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
|
@ -126,8 +126,8 @@ class SignCoreTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExecuteWithNotExistingCertificate() {
|
public function testExecuteWithNotExistingCertificate() {
|
||||||
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface');
|
$inputInterface = $this->createMock(InputInterface::class);
|
||||||
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface');
|
$outputInterface = $this->createMock(OutputInterface::class);
|
||||||
|
|
||||||
$inputInterface
|
$inputInterface
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
|
@ -165,8 +165,8 @@ class SignCoreTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExecute() {
|
public function testExecute() {
|
||||||
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface');
|
$inputInterface = $this->createMock(InputInterface::class);
|
||||||
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface');
|
$outputInterface = $this->createMock(OutputInterface::class);
|
||||||
|
|
||||||
$inputInterface
|
$inputInterface
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
|
|
|
@ -24,6 +24,9 @@ namespace Test\Encryption;
|
||||||
|
|
||||||
|
|
||||||
use OC\Encryption\EncryptionWrapper;
|
use OC\Encryption\EncryptionWrapper;
|
||||||
|
use OC\Encryption\Manager;
|
||||||
|
use OC\Memcache\ArrayCache;
|
||||||
|
use OCP\ILogger;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
class EncryptionWrapperTest extends TestCase {
|
class EncryptionWrapperTest extends TestCase {
|
||||||
|
@ -43,10 +46,10 @@ class EncryptionWrapperTest extends TestCase {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->arrayCache = $this->getMock('OC\Memcache\ArrayCache');
|
$this->arrayCache = $this->createMock(ArrayCache::class);
|
||||||
$this->manager = $this->getMockBuilder('OC\Encryption\Manager')
|
$this->manager = $this->createMock(Manager::class);
|
||||||
->disableOriginalConstructor()->getMock();
|
$this->logger = $this->createMock(ILogger::class);
|
||||||
$this->logger = $this->getMock('OCP\ILogger');
|
$this->logger = $this->createMock(ILogger::class);
|
||||||
|
|
||||||
$this->instance = new EncryptionWrapper($this->arrayCache, $this->manager, $this->logger);
|
$this->instance = new EncryptionWrapper($this->arrayCache, $this->manager, $this->logger);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,13 @@
|
||||||
namespace Test\Encryption;
|
namespace Test\Encryption;
|
||||||
|
|
||||||
use OC\Encryption\Manager;
|
use OC\Encryption\Manager;
|
||||||
|
use OC\Encryption\Util;
|
||||||
|
use OC\Files\View;
|
||||||
|
use OC\Memcache\ArrayCache;
|
||||||
|
use OCP\Encryption\IEncryptionModule;
|
||||||
|
use OCP\IConfig;
|
||||||
|
use OCP\IL10N;
|
||||||
|
use OCP\ILogger;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
class ManagerTest extends TestCase {
|
class ManagerTest extends TestCase {
|
||||||
|
@ -30,12 +37,12 @@ class ManagerTest extends TestCase {
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->config = $this->getMock('\OCP\IConfig');
|
$this->config = $this->createMock(IConfig::class);
|
||||||
$this->logger = $this->getMock('\OCP\ILogger');
|
$this->logger = $this->createMock(ILogger::class);
|
||||||
$this->l10n = $this->getMock('\OCP\Il10n');
|
$this->l10n = $this->createMock(IL10N::class);
|
||||||
$this->view = $this->getMock('\OC\Files\View');
|
$this->view = $this->createMock(View::class);
|
||||||
$this->util = $this->getMockBuilder('\OC\Encryption\Util')->disableOriginalConstructor()->getMock();
|
$this->util = $this->createMock(Util::class);
|
||||||
$this->arrayCache = $this->getMock('OC\Memcache\ArrayCache');
|
$this->arrayCache = $this->createMock(ArrayCache::class);
|
||||||
$this->manager = new Manager($this->config, $this->logger, $this->l10n, $this->view, $this->util, $this->arrayCache);
|
$this->manager = new Manager($this->config, $this->logger, $this->l10n, $this->view, $this->util, $this->arrayCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +57,7 @@ class ManagerTest extends TestCase {
|
||||||
|
|
||||||
public function testManagerIsDisabledIfDisabledButModules() {
|
public function testManagerIsDisabledIfDisabledButModules() {
|
||||||
$this->config->expects($this->any())->method('getAppValue')->willReturn(false);
|
$this->config->expects($this->any())->method('getAppValue')->willReturn(false);
|
||||||
$em = $this->getMock('\OCP\Encryption\IEncryptionModule');
|
$em = $this->createMock(IEncryptionModule::class);
|
||||||
$em->expects($this->any())->method('getId')->willReturn('id');
|
$em->expects($this->any())->method('getId')->willReturn('id');
|
||||||
$em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
|
$em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
|
||||||
$this->manager->registerEncryptionModule('id', 'TestDummyModule0', function() use ($em) {return $em;});
|
$this->manager->registerEncryptionModule('id', 'TestDummyModule0', function() use ($em) {return $em;});
|
||||||
|
@ -235,7 +242,7 @@ class ManagerTest extends TestCase {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
protected function addNewEncryptionModule(Manager $manager, $id) {
|
protected function addNewEncryptionModule(Manager $manager, $id) {
|
||||||
$encryptionModule = $this->getMock('\OCP\Encryption\IEncryptionModule');
|
$encryptionModule = $this->createMock(IEncryptionModule::class);
|
||||||
$encryptionModule->expects($this->any())
|
$encryptionModule->expects($this->any())
|
||||||
->method('getId')
|
->method('getId')
|
||||||
->willReturn('ID' . $id);
|
->willReturn('ID' . $id);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace Test\Encryption;
|
namespace Test\Encryption;
|
||||||
|
|
||||||
use OC\Encryption\Util;
|
use OC\Encryption\Util;
|
||||||
|
use OCP\Encryption\IEncryptionModule;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
class UtilTest extends TestCase {
|
class UtilTest extends TestCase {
|
||||||
|
@ -77,7 +78,7 @@ class UtilTest extends TestCase {
|
||||||
*/
|
*/
|
||||||
public function testCreateHeader($expected, $header, $moduleId) {
|
public function testCreateHeader($expected, $header, $moduleId) {
|
||||||
|
|
||||||
$em = $this->getMock('\OCP\Encryption\IEncryptionModule');
|
$em = $this->createMock(IEncryptionModule::class);
|
||||||
$em->expects($this->any())->method('getId')->willReturn($moduleId);
|
$em->expects($this->any())->method('getId')->willReturn($moduleId);
|
||||||
|
|
||||||
$result = $this->util->createHeader($header, $em);
|
$result = $this->util->createHeader($header, $em);
|
||||||
|
@ -100,7 +101,7 @@ class UtilTest extends TestCase {
|
||||||
|
|
||||||
$header = array('header1' => 1, 'header2' => 2, 'oc_encryption_module' => 'foo');
|
$header = array('header1' => 1, 'header2' => 2, 'oc_encryption_module' => 'foo');
|
||||||
|
|
||||||
$em = $this->getMock('\OCP\Encryption\IEncryptionModule');
|
$em = $this->createMock(IEncryptionModule::class);
|
||||||
$em->expects($this->any())->method('getId')->willReturn('moduleId');
|
$em->expects($this->any())->method('getId')->willReturn('moduleId');
|
||||||
|
|
||||||
$this->util->createHeader($header, $em);
|
$this->util->createHeader($header, $em);
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
*/
|
*/
|
||||||
namespace Test;
|
namespace Test;
|
||||||
|
|
||||||
|
use OCP\ICache;
|
||||||
|
|
||||||
class FileChunkingTest extends \Test\TestCase {
|
class FileChunkingTest extends \Test\TestCase {
|
||||||
|
|
||||||
public function dataIsComplete() {
|
public function dataIsComplete() {
|
||||||
|
@ -54,7 +56,7 @@ class FileChunkingTest extends \Test\TestCase {
|
||||||
]])
|
]])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$cache = $this->getMock('\OCP\ICache');
|
$cache = $this->createMock(ICache::class);
|
||||||
|
|
||||||
$cache->expects($this->atLeastOnce())
|
$cache->expects($this->atLeastOnce())
|
||||||
->method('hasKey')
|
->method('hasKey')
|
||||||
|
|
|
@ -8,15 +8,18 @@
|
||||||
|
|
||||||
namespace Test\Files\Mount;
|
namespace Test\Files\Mount;
|
||||||
|
|
||||||
|
use OC\Files\Storage\StorageFactory;
|
||||||
|
use OCP\Files\Storage;
|
||||||
|
|
||||||
class MountPointTest extends \Test\TestCase {
|
class MountPointTest extends \Test\TestCase {
|
||||||
|
|
||||||
public function testGetStorage() {
|
public function testGetStorage() {
|
||||||
$storage = $this->getMock('\OCP\Files\Storage');
|
$storage = $this->createMock(Storage::class);
|
||||||
$storage->expects($this->once())
|
$storage->expects($this->once())
|
||||||
->method('getId')
|
->method('getId')
|
||||||
->will($this->returnValue(123));
|
->will($this->returnValue(123));
|
||||||
|
|
||||||
$loader = $this->getMock('\OC\Files\Storage\StorageFactory');
|
$loader = $this->createMock(StorageFactory::class);
|
||||||
$loader->expects($this->once())
|
$loader->expects($this->once())
|
||||||
->method('wrap')
|
->method('wrap')
|
||||||
->will($this->returnValue($storage));
|
->will($this->returnValue($storage));
|
||||||
|
@ -38,7 +41,7 @@ class MountPointTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvalidStorage() {
|
public function testInvalidStorage() {
|
||||||
$loader = $this->getMock('\OC\Files\Storage\StorageFactory');
|
$loader = $this->createMock(StorageFactory::class);
|
||||||
$loader->expects($this->once())
|
$loader->expects($this->once())
|
||||||
->method('wrap')
|
->method('wrap')
|
||||||
->will($this->throwException(new \Exception('Test storage init exception')));
|
->will($this->throwException(new \Exception('Test storage init exception')));
|
||||||
|
|
|
@ -24,9 +24,9 @@ class ObjectHomeMountProviderTest extends \Test\TestCase {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->config = $this->getMock('OCP\IConfig');
|
$this->config = $this->createMock(IConfig::class);
|
||||||
$this->user = $this->getMock('OCP\IUser');
|
$this->user = $this->createMock(IUser::class);
|
||||||
$this->loader = $this->getMock('OCP\Files\Storage\IStorageFactory');
|
$this->loader = $this->createMock(IStorageFactory::class);
|
||||||
|
|
||||||
$this->provider = new ObjectHomeMountProvider($this->config);
|
$this->provider = new ObjectHomeMountProvider($this->config);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ namespace Test\Files\ObjectStore;
|
||||||
|
|
||||||
|
|
||||||
use OC\Files\ObjectStore\Mapper;
|
use OC\Files\ObjectStore\Mapper;
|
||||||
|
use OCP\IUser;
|
||||||
|
|
||||||
class MapperTest extends \Test\TestCase {
|
class MapperTest extends \Test\TestCase {
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ class MapperTest extends \Test\TestCase {
|
||||||
* @param string $expectedBucket
|
* @param string $expectedBucket
|
||||||
*/
|
*/
|
||||||
public function testGetBucket($username, $expectedBucket) {
|
public function testGetBucket($username, $expectedBucket) {
|
||||||
$user = $this->getMock('OCP\IUser');
|
$user = $this->createMock(IUser::class);
|
||||||
$user->method('getUID')
|
$user->method('getUID')
|
||||||
->willReturn($username);
|
->willReturn($username);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,10 @@ namespace Test\Files\Storage\Wrapper;
|
||||||
use OC\Encryption\Util;
|
use OC\Encryption\Util;
|
||||||
use OC\Files\Storage\Temporary;
|
use OC\Files\Storage\Temporary;
|
||||||
use OC\Files\View;
|
use OC\Files\View;
|
||||||
|
use OC\Log;
|
||||||
|
use OC\Memcache\ArrayCache;
|
||||||
use OC\User\Manager;
|
use OC\User\Manager;
|
||||||
|
use OCP\Files\Cache\ICache;
|
||||||
use Test\Files\Storage\Storage;
|
use Test\Files\Storage\Storage;
|
||||||
|
|
||||||
class EncryptionTest extends Storage {
|
class EncryptionTest extends Storage {
|
||||||
|
@ -108,7 +111,7 @@ class EncryptionTest extends Storage {
|
||||||
->method('getEncryptionModule')
|
->method('getEncryptionModule')
|
||||||
->willReturn($mockModule);
|
->willReturn($mockModule);
|
||||||
|
|
||||||
$this->arrayCache = $this->getMock('OC\Memcache\ArrayCache');
|
$this->arrayCache = $this->createMock(ArrayCache::class);
|
||||||
$this->config = $this->getMockBuilder('\OCP\IConfig')
|
$this->config = $this->getMockBuilder('\OCP\IConfig')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
@ -116,10 +119,10 @@ class EncryptionTest extends Storage {
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$this->util = $this->getMock(
|
$this->util = $this->getMockBuilder('\OC\Encryption\Util')
|
||||||
'\OC\Encryption\Util',
|
->setMethods(['getUidAndFilename', 'isFile', 'isExcluded'])
|
||||||
['getUidAndFilename', 'isFile', 'isExcluded'],
|
->setConstructorArgs([new View(), new Manager(), $this->groupManager, $this->config, $this->arrayCache])
|
||||||
[new View(), new Manager(), $this->groupManager, $this->config, $this->arrayCache]);
|
->getMock();
|
||||||
$this->util->expects($this->any())
|
$this->util->expects($this->any())
|
||||||
->method('getUidAndFilename')
|
->method('getUidAndFilename')
|
||||||
->willReturnCallback(function ($path) {
|
->willReturnCallback(function ($path) {
|
||||||
|
@ -132,7 +135,7 @@ class EncryptionTest extends Storage {
|
||||||
->getMock();
|
->getMock();
|
||||||
$this->file->expects($this->any())->method('getAccessList')->willReturn([]);
|
$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());
|
$this->sourceStorage = new Temporary(array());
|
||||||
|
|
||||||
|
@ -713,7 +716,7 @@ class EncryptionTest extends Storage {
|
||||||
$temp = \OC::$server->getTempManager();
|
$temp = \OC::$server->getTempManager();
|
||||||
return fopen($temp->getTemporaryFile(), $mode);
|
return fopen($temp->getTemporaryFile(), $mode);
|
||||||
});
|
});
|
||||||
$cache = $this->getMock('\OCP\Files\Cache\ICache');
|
$cache = $this->createMock(ICache::class);
|
||||||
$cache->expects($this->once())
|
$cache->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
->with($sourceInternalPath)
|
->with($sourceInternalPath)
|
||||||
|
@ -763,7 +766,7 @@ class EncryptionTest extends Storage {
|
||||||
return fopen($temp->getTemporaryFile(), $mode);
|
return fopen($temp->getTemporaryFile(), $mode);
|
||||||
});
|
});
|
||||||
if($expectedEncrypted) {
|
if($expectedEncrypted) {
|
||||||
$cache = $this->getMock('\OCP\Files\Cache\ICache');
|
$cache = $this->createMock(ICache::class);
|
||||||
$cache->expects($this->once())
|
$cache->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
->with($sourceInternalPath)
|
->with($sourceInternalPath)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace Test\Files\Stream;
|
namespace Test\Files\Stream;
|
||||||
|
|
||||||
use OC\Files\View;
|
use OC\Files\View;
|
||||||
|
use OC\Memcache\ArrayCache;
|
||||||
|
|
||||||
class EncryptionTest extends \Test\TestCase {
|
class EncryptionTest extends \Test\TestCase {
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ class EncryptionTest extends \Test\TestCase {
|
||||||
$config = $this->getMockBuilder('\OCP\IConfig')
|
$config = $this->getMockBuilder('\OCP\IConfig')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$arrayCache = $this->getMock('OC\Memcache\ArrayCache');
|
$arrayCache = $this->createMock(ArrayCache::class);
|
||||||
$groupManager = $this->getMockBuilder('\OC\Group\Manager')
|
$groupManager = $this->getMockBuilder('\OC\Group\Manager')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
@ -40,11 +41,10 @@ class EncryptionTest extends \Test\TestCase {
|
||||||
->setMethods(['getAccessList'])
|
->setMethods(['getAccessList'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$file->expects($this->any())->method('getAccessList')->willReturn([]);
|
$file->expects($this->any())->method('getAccessList')->willReturn([]);
|
||||||
$util = $this->getMock(
|
$util = $this->getMockBuilder('\OC\Encryption\Util')
|
||||||
'\OC\Encryption\Util',
|
->setMethods(['getUidAndFilename'])
|
||||||
['getUidAndFilename'],
|
->setConstructorArgs([new View(), new \OC\User\Manager(), $groupManager, $config, $arrayCache])
|
||||||
[new View(), new \OC\User\Manager(), $groupManager, $config, $arrayCache]
|
->getMock();
|
||||||
);
|
|
||||||
$util->expects($this->any())
|
$util->expects($this->any())
|
||||||
->method('getUidAndFilename')
|
->method('getUidAndFilename')
|
||||||
->willReturn(['user1', $internalPath]);
|
->willReturn(['user1', $internalPath]);
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
namespace Test\Group;
|
namespace Test\Group;
|
||||||
|
|
||||||
|
use OCP\IUserSession;
|
||||||
|
|
||||||
class MetaDataTest extends \Test\TestCase {
|
class MetaDataTest extends \Test\TestCase {
|
||||||
/** @var \OC\Group\Manager */
|
/** @var \OC\Group\Manager */
|
||||||
private $groupManager;
|
private $groupManager;
|
||||||
|
@ -37,7 +39,7 @@ class MetaDataTest extends \Test\TestCase {
|
||||||
$this->groupManager = $this->getMockBuilder('\OC\Group\Manager')
|
$this->groupManager = $this->getMockBuilder('\OC\Group\Manager')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$this->userSession = $this->getMock('\OCP\IUserSession');
|
$this->userSession = $this->createMock(IUserSession::class);
|
||||||
$this->groupMetadata = new \OC\Group\MetaData(
|
$this->groupMetadata = new \OC\Group\MetaData(
|
||||||
'foo',
|
'foo',
|
||||||
$this->isAdmin,
|
$this->isAdmin,
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
namespace Test;
|
namespace Test;
|
||||||
|
|
||||||
|
use OCP\Http\Client\IClientService;
|
||||||
|
|
||||||
class HTTPHelperTest extends \Test\TestCase {
|
class HTTPHelperTest extends \Test\TestCase {
|
||||||
|
|
||||||
/** @var \OCP\IConfig*/
|
/** @var \OCP\IConfig*/
|
||||||
|
@ -22,7 +24,7 @@ class HTTPHelperTest extends \Test\TestCase {
|
||||||
|
|
||||||
$this->config = $this->getMockBuilder('\OCP\IConfig')
|
$this->config = $this->getMockBuilder('\OCP\IConfig')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$this->clientService = $this->getMock('\OCP\Http\Client\IClientService');
|
$this->clientService = $this->createMock(IClientService::class);
|
||||||
$this->httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper')
|
$this->httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper')
|
||||||
->setConstructorArgs(array($this->config, $this->clientService))
|
->setConstructorArgs(array($this->config, $this->clientService))
|
||||||
->setMethods(array('getHeaders'))
|
->setMethods(array('getHeaders'))
|
||||||
|
|
|
@ -11,14 +11,16 @@ namespace Test\Http\Client;
|
||||||
use GuzzleHttp\Client as GuzzleClient;
|
use GuzzleHttp\Client as GuzzleClient;
|
||||||
use OC\Http\Client\Client;
|
use OC\Http\Client\Client;
|
||||||
use OC\Http\Client\ClientService;
|
use OC\Http\Client\ClientService;
|
||||||
|
use OCP\ICertificateManager;
|
||||||
|
use OCP\IConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ClientServiceTest
|
* Class ClientServiceTest
|
||||||
*/
|
*/
|
||||||
class ClientServiceTest extends \Test\TestCase {
|
class ClientServiceTest extends \Test\TestCase {
|
||||||
public function testNewClient() {
|
public function testNewClient() {
|
||||||
$config = $this->getMock('\OCP\IConfig');
|
$config = $this->createMock(IConfig::class);
|
||||||
$certificateManager = $this->getMock('\OCP\ICertificateManager');
|
$certificateManager = $this->createMock(ICertificateManager::class);
|
||||||
|
|
||||||
$expected = new Client($config, $certificateManager, new GuzzleClient());
|
$expected = new Client($config, $certificateManager, new GuzzleClient());
|
||||||
$clientService = new ClientService($config, $certificateManager);
|
$clientService = new ClientService($config, $certificateManager);
|
||||||
|
|
|
@ -10,6 +10,7 @@ namespace Test\Http\Client;
|
||||||
|
|
||||||
use GuzzleHttp\Message\Response;
|
use GuzzleHttp\Message\Response;
|
||||||
use OC\Http\Client\Client;
|
use OC\Http\Client\Client;
|
||||||
|
use OCP\ICertificateManager;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,11 +26,11 @@ class ClientTest extends \Test\TestCase {
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->config = $this->getMock('\OCP\IConfig');
|
$this->config = $this->createMock(IConfig::class);
|
||||||
$this->guzzleClient = $this->getMockBuilder('\GuzzleHttp\Client')
|
$this->guzzleClient = $this->getMockBuilder('\GuzzleHttp\Client')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$certificateManager = $this->getMock('\OCP\ICertificateManager');
|
$certificateManager = $this->createMock(ICertificateManager::class);
|
||||||
$this->client = new Client(
|
$this->client = new Client(
|
||||||
$this->config,
|
$this->config,
|
||||||
$certificateManager,
|
$certificateManager,
|
||||||
|
|
|
@ -51,12 +51,12 @@ class CheckerTest extends TestCase {
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->environmentHelper = $this->getMock('\OC\IntegrityCheck\Helpers\EnvironmentHelper');
|
$this->environmentHelper = $this->createMock(EnvironmentHelper::class);
|
||||||
$this->fileAccessHelper = $this->getMock('\OC\IntegrityCheck\Helpers\FileAccessHelper');
|
$this->fileAccessHelper = $this->createMock(FileAccessHelper::class);
|
||||||
$this->appLocator = $this->getMock('\OC\IntegrityCheck\Helpers\AppLocator');
|
$this->appLocator = $this->createMock(AppLocator::class);
|
||||||
$this->config = $this->getMock('\OCP\IConfig');
|
$this->config = $this->createMock(IConfig::class);
|
||||||
$this->cacheFactory = $this->getMock('\OCP\ICacheFactory');
|
$this->cacheFactory = $this->createMock(ICacheFactory::class);
|
||||||
$this->appManager = $this->getMock('\OCP\App\IAppManager');
|
$this->appManager = $this->createMock(IAppManager::class);
|
||||||
|
|
||||||
$this->cacheFactory
|
$this->cacheFactory
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
|
|
|
@ -12,6 +12,8 @@ namespace Test\L10N;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use OC\L10N\Factory;
|
use OC\L10N\Factory;
|
||||||
use OC\L10N\L10N;
|
use OC\L10N\L10N;
|
||||||
|
use OCP\IConfig;
|
||||||
|
use OCP\IRequest;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
|
@ -26,11 +28,11 @@ class L10nTest extends TestCase {
|
||||||
*/
|
*/
|
||||||
protected function getFactory() {
|
protected function getFactory() {
|
||||||
/** @var \OCP\IConfig $config */
|
/** @var \OCP\IConfig $config */
|
||||||
$config = $this->getMock('OCP\IConfig');
|
$config = $this->createMock(IConfig::class);
|
||||||
/** @var \OCP\IRequest $request */
|
/** @var \OCP\IRequest $request */
|
||||||
$request = $this->getMock('OCP\IRequest');
|
$request = $this->createMock(IRequest::class);
|
||||||
/** @var IUserSession $userSession */
|
/** @var IUserSession $userSession */
|
||||||
$userSession = $this->getMock('OCP\IUserSession');
|
$userSession = $this->createMock(IUserSession::class);
|
||||||
return new Factory($config, $request, $userSession, \OC::$SERVERROOT);
|
return new Factory($config, $request, $userSession, \OC::$SERVERROOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
namespace Test;
|
namespace Test;
|
||||||
|
|
||||||
|
use OC\Files\View;
|
||||||
use OC_Helper;
|
use OC_Helper;
|
||||||
|
|
||||||
class LegacyHelperTest extends \Test\TestCase {
|
class LegacyHelperTest extends \Test\TestCase {
|
||||||
|
@ -129,7 +130,7 @@ class LegacyHelperTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testBuildNotExistingFileNameForView() {
|
function testBuildNotExistingFileNameForView() {
|
||||||
$viewMock = $this->getMock('\OC\Files\View', array(), array(), '', false);
|
$viewMock = $this->createMock(View::class);
|
||||||
$this->assertEquals('/filename', OC_Helper::buildNotExistingFileNameForView('/', 'filename', $viewMock));
|
$this->assertEquals('/filename', OC_Helper::buildNotExistingFileNameForView('/', 'filename', $viewMock));
|
||||||
$this->assertEquals('dir/filename.ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename.ext', $viewMock));
|
$this->assertEquals('dir/filename.ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename.ext', $viewMock));
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,9 @@ class BackgroundRepairTest extends TestCase {
|
||||||
$this->logger = $this->getMockBuilder('OCP\ILogger')
|
$this->logger = $this->getMockBuilder('OCP\ILogger')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$this->job = $this->getMock('OC\Migration\BackgroundRepair', ['loadApp']);
|
$this->job = $this->getMockBuilder(BackgroundRepair::class)
|
||||||
|
->setMethods(['loadApp'])
|
||||||
|
->getMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNoArguments() {
|
public function testNoArguments() {
|
||||||
|
@ -105,7 +107,7 @@ class BackgroundRepairTest extends TestCase {
|
||||||
|
|
||||||
public function testWorkingStep() {
|
public function testWorkingStep() {
|
||||||
/** @var EventDispatcher | \PHPUnit_Framework_MockObject_MockObject $dispatcher */
|
/** @var EventDispatcher | \PHPUnit_Framework_MockObject_MockObject $dispatcher */
|
||||||
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcher', []);
|
$dispatcher = $this->createMock(EventDispatcher::class);
|
||||||
$dispatcher->expects($this->once())->method('dispatch')
|
$dispatcher->expects($this->once())->method('dispatch')
|
||||||
->with('\OC\Repair::step', new GenericEvent('\OC\Repair::step', ['A test repair step']));
|
->with('\OC\Repair::step', new GenericEvent('\OC\Repair::step', ['A test repair step']));
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,9 @@
|
||||||
namespace Test;
|
namespace Test;
|
||||||
|
|
||||||
use OC\OCSClient;
|
use OC\OCSClient;
|
||||||
|
use OCP\Http\Client\IClient;
|
||||||
use OCP\Http\Client\IClientService;
|
use OCP\Http\Client\IClientService;
|
||||||
|
use OCP\Http\Client\IResponse;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\ILogger;
|
use OCP\ILogger;
|
||||||
|
|
||||||
|
@ -44,8 +46,8 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
|
|
||||||
$this->config = $this->getMockBuilder('\OCP\IConfig')
|
$this->config = $this->getMockBuilder('\OCP\IConfig')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$this->clientService = $this->getMock('\OCP\Http\Client\IClientService');
|
$this->clientService = $this->createMock(IClientService::class);
|
||||||
$this->logger = $this->getMock('\OCP\ILogger');
|
$this->logger = $this->createMock(ILogger::class);
|
||||||
|
|
||||||
$this->ocsClient = new OCSClient(
|
$this->ocsClient = new OCSClient(
|
||||||
$this->clientService,
|
$this->clientService,
|
||||||
|
@ -102,7 +104,7 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
||||||
->will($this->returnValue('https://api.owncloud.com/v1'));
|
->will($this->returnValue('https://api.owncloud.com/v1'));
|
||||||
|
|
||||||
$client = $this->getMock('\OCP\Http\Client\IClient');
|
$client = $this->createMock(IClient::class);
|
||||||
$client
|
$client
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -145,13 +147,13 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
||||||
->will($this->returnValue('https://api.owncloud.com/v1'));
|
->will($this->returnValue('https://api.owncloud.com/v1'));
|
||||||
|
|
||||||
$response = $this->getMock('\OCP\Http\Client\IResponse');
|
$response = $this->createMock(IResponse::class);
|
||||||
$response
|
$response
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getBody')
|
->method('getBody')
|
||||||
->will($this->returnValue('MyInvalidXml'));
|
->will($this->returnValue('MyInvalidXml'));
|
||||||
|
|
||||||
$client = $this->getMock('\OCP\Http\Client\IClient');
|
$client = $this->createMock(IClient::class);
|
||||||
$client
|
$client
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -194,7 +196,7 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
||||||
->will($this->returnValue('https://api.owncloud.com/v1'));
|
->will($this->returnValue('https://api.owncloud.com/v1'));
|
||||||
|
|
||||||
$response = $this->getMock('\OCP\Http\Client\IResponse');
|
$response = $this->createMock(IResponse::class);
|
||||||
$response
|
$response
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getBody')
|
->method('getBody')
|
||||||
|
@ -235,7 +237,7 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
</ocs>
|
</ocs>
|
||||||
'));
|
'));
|
||||||
|
|
||||||
$client = $this->getMock('\OCP\Http\Client\IClient');
|
$client = $this->createMock(IClient::class);
|
||||||
$client
|
$client
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -285,7 +287,7 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
||||||
->will($this->returnValue('https://api.owncloud.com/v1'));
|
->will($this->returnValue('https://api.owncloud.com/v1'));
|
||||||
|
|
||||||
$client = $this->getMock('\OCP\Http\Client\IClient');
|
$client = $this->createMock(IClient::class);
|
||||||
$client
|
$client
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -336,13 +338,13 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
||||||
->will($this->returnValue('https://api.owncloud.com/v1'));
|
->will($this->returnValue('https://api.owncloud.com/v1'));
|
||||||
|
|
||||||
$response = $this->getMock('\OCP\Http\Client\IResponse');
|
$response = $this->createMock(IResponse::class);
|
||||||
$response
|
$response
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getBody')
|
->method('getBody')
|
||||||
->will($this->returnValue('MyInvalidXml'));
|
->will($this->returnValue('MyInvalidXml'));
|
||||||
|
|
||||||
$client = $this->getMock('\OCP\Http\Client\IClient');
|
$client = $this->createMock(IClient::class);
|
||||||
$client
|
$client
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -393,7 +395,7 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
||||||
->will($this->returnValue('https://api.owncloud.com/v1'));
|
->will($this->returnValue('https://api.owncloud.com/v1'));
|
||||||
|
|
||||||
$response = $this->getMock('\OCP\Http\Client\IResponse');
|
$response = $this->createMock(IResponse::class);
|
||||||
$response
|
$response
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getBody')
|
->method('getBody')
|
||||||
|
@ -478,7 +480,7 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
</data>
|
</data>
|
||||||
</ocs> '));
|
</ocs> '));
|
||||||
|
|
||||||
$client = $this->getMock('\OCP\Http\Client\IClient');
|
$client = $this->createMock(IClient::class);
|
||||||
$client
|
$client
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -568,7 +570,7 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
||||||
->will($this->returnValue('https://api.owncloud.com/v1'));
|
->will($this->returnValue('https://api.owncloud.com/v1'));
|
||||||
|
|
||||||
$client = $this->getMock('\OCP\Http\Client\IClient');
|
$client = $this->createMock(IClient::class);
|
||||||
$client
|
$client
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -611,13 +613,13 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
||||||
->will($this->returnValue('https://api.owncloud.com/v1'));
|
->will($this->returnValue('https://api.owncloud.com/v1'));
|
||||||
|
|
||||||
$response = $this->getMock('\OCP\Http\Client\IResponse');
|
$response = $this->createMock(IResponse::class);
|
||||||
$response
|
$response
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getBody')
|
->method('getBody')
|
||||||
->will($this->returnValue('MyInvalidXml'));
|
->will($this->returnValue('MyInvalidXml'));
|
||||||
|
|
||||||
$client = $this->getMock('\OCP\Http\Client\IClient');
|
$client = $this->createMock(IClient::class);
|
||||||
$client
|
$client
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -660,7 +662,7 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
||||||
->will($this->returnValue('https://api.owncloud.com/v1'));
|
->will($this->returnValue('https://api.owncloud.com/v1'));
|
||||||
|
|
||||||
$response = $this->getMock('\OCP\Http\Client\IResponse');
|
$response = $this->createMock(IResponse::class);
|
||||||
$response
|
$response
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getBody')
|
->method('getBody')
|
||||||
|
@ -745,7 +747,7 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
</ocs>
|
</ocs>
|
||||||
'));
|
'));
|
||||||
|
|
||||||
$client = $this->getMock('\OCP\Http\Client\IClient');
|
$client = $this->createMock(IClient::class);
|
||||||
$client
|
$client
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -796,7 +798,7 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
||||||
->will($this->returnValue('https://api.owncloud.com/v1'));
|
->will($this->returnValue('https://api.owncloud.com/v1'));
|
||||||
|
|
||||||
$response = $this->getMock('\OCP\Http\Client\IResponse');
|
$response = $this->createMock(IResponse::class);
|
||||||
$response
|
$response
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getBody')
|
->method('getBody')
|
||||||
|
@ -881,7 +883,7 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
</ocs>
|
</ocs>
|
||||||
'));
|
'));
|
||||||
|
|
||||||
$client = $this->getMock('\OCP\Http\Client\IClient');
|
$client = $this->createMock(IClient::class);
|
||||||
$client
|
$client
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -932,7 +934,7 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
||||||
->will($this->returnValue('https://api.owncloud.com/v1'));
|
->will($this->returnValue('https://api.owncloud.com/v1'));
|
||||||
|
|
||||||
$response = $this->getMock('\OCP\Http\Client\IResponse');
|
$response = $this->createMock(IResponse::class);
|
||||||
$response
|
$response
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getBody')
|
->method('getBody')
|
||||||
|
@ -946,7 +948,7 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
</ocs>
|
</ocs>
|
||||||
'));
|
'));
|
||||||
|
|
||||||
$client = $this->getMock('\OCP\Http\Client\IClient');
|
$client = $this->createMock(IClient::class);
|
||||||
$client
|
$client
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -988,7 +990,7 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
||||||
->will($this->returnValue('https://api.owncloud.com/v1'));
|
->will($this->returnValue('https://api.owncloud.com/v1'));
|
||||||
|
|
||||||
$client = $this->getMock('\OCP\Http\Client\IClient');
|
$client = $this->createMock(IClient::class);
|
||||||
$client
|
$client
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -1031,13 +1033,13 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
||||||
->will($this->returnValue('https://api.owncloud.com/v1'));
|
->will($this->returnValue('https://api.owncloud.com/v1'));
|
||||||
|
|
||||||
$response = $this->getMock('\OCP\Http\Client\IResponse');
|
$response = $this->createMock(IResponse::class);
|
||||||
$response
|
$response
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getBody')
|
->method('getBody')
|
||||||
->will($this->returnValue('MyInvalidXml'));
|
->will($this->returnValue('MyInvalidXml'));
|
||||||
|
|
||||||
$client = $this->getMock('\OCP\Http\Client\IClient');
|
$client = $this->createMock(IClient::class);
|
||||||
$client
|
$client
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -1080,7 +1082,7 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
->with('appstoreurl', 'https://api.owncloud.com/v1')
|
||||||
->will($this->returnValue('https://api.owncloud.com/v1'));
|
->will($this->returnValue('https://api.owncloud.com/v1'));
|
||||||
|
|
||||||
$response = $this->getMock('\OCP\Http\Client\IResponse');
|
$response = $this->createMock(IResponse::class);
|
||||||
$response
|
$response
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getBody')
|
->method('getBody')
|
||||||
|
@ -1104,7 +1106,7 @@ class OCSClientTest extends \Test\TestCase {
|
||||||
</ocs>
|
</ocs>
|
||||||
'));
|
'));
|
||||||
|
|
||||||
$client = $this->getMock('\OCP\Http\Client\IClient');
|
$client = $this->createMock(IClient::class);
|
||||||
$client
|
$client
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
namespace Test\Repair;
|
namespace Test\Repair;
|
||||||
|
|
||||||
use OC\Repair\SharePropagation;
|
use OC\Repair\SharePropagation;
|
||||||
|
use OCP\IConfig;
|
||||||
use OCP\Migration\IOutput;
|
use OCP\Migration\IOutput;
|
||||||
|
|
||||||
class RepairSharePropagationTest extends \Test\TestCase {
|
class RepairSharePropagationTest extends \Test\TestCase {
|
||||||
|
@ -27,7 +28,7 @@ class RepairSharePropagationTest extends \Test\TestCase {
|
||||||
*/
|
*/
|
||||||
public function testRemovePropagationEntries(array $startKeys, array $expectedRemovedKeys) {
|
public function testRemovePropagationEntries(array $startKeys, array $expectedRemovedKeys) {
|
||||||
/** @var \PHPUnit_Framework_MockObject_MockObject|\OCP\IConfig $config */
|
/** @var \PHPUnit_Framework_MockObject_MockObject|\OCP\IConfig $config */
|
||||||
$config = $this->getMock('\OCP\IConfig');
|
$config = $this->createMock(IConfig::class);
|
||||||
$config->expects($this->once())
|
$config->expects($this->once())
|
||||||
->method('getAppKeys')
|
->method('getAppKeys')
|
||||||
->with('files_sharing')
|
->with('files_sharing')
|
||||||
|
|
|
@ -44,9 +44,9 @@ class ThrottlerTest extends TestCase {
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
$this->dbConnection = $this->getMock('\OCP\IDBConnection');
|
$this->dbConnection = $this->createMock(IDBConnection::class);
|
||||||
$this->logger = $this->getMock('\OCP\ILogger');
|
$this->logger = $this->createMock(ILogger::class);
|
||||||
$this->config = $this->getMock('\OCP\IConfig');
|
$this->config = $this->createMock(IConfig::class);
|
||||||
|
|
||||||
$this->throttler = new Throttler(
|
$this->throttler = new Throttler(
|
||||||
$this->dbConnection,
|
$this->dbConnection,
|
||||||
|
|
|
@ -38,7 +38,7 @@ class CredentialsManagerTest extends \Test\TestCase {
|
||||||
|
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->crypto = $this->getMock('\OCP\Security\ICrypto');
|
$this->crypto = $this->createMock(ICrypto::class);
|
||||||
$this->dbConnection = $this->getMockBuilder('\OC\DB\Connection')
|
$this->dbConnection = $this->getMockBuilder('\OC\DB\Connection')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
|
@ -8,7 +8,11 @@
|
||||||
|
|
||||||
namespace Test;
|
namespace Test;
|
||||||
|
|
||||||
|
use bantu\IniGetWrapper\IniGetWrapper;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
use OCP\IL10N;
|
||||||
|
use OCP\ILogger;
|
||||||
|
use OCP\Security\ISecureRandom;
|
||||||
|
|
||||||
class SetupTest extends \Test\TestCase {
|
class SetupTest extends \Test\TestCase {
|
||||||
|
|
||||||
|
@ -30,15 +34,16 @@ class SetupTest extends \Test\TestCase {
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->config = $this->getMock('\OCP\IConfig');
|
$this->config = $this->createMock(IConfig::class);
|
||||||
$this->iniWrapper = $this->getMock('\bantu\IniGetWrapper\IniGetWrapper');
|
$this->iniWrapper = $this->createMock(IniGetWrapper::class);
|
||||||
$this->l10n = $this->getMock('\OCP\IL10N');
|
$this->l10n = $this->createMock(IL10N::class);
|
||||||
$this->defaults = $this->getMock('\OC_Defaults');
|
$this->defaults = $this->createMock(\OC_Defaults::class);
|
||||||
$this->logger = $this->getMock('\OCP\ILogger');
|
$this->logger = $this->createMock(ILogger::class);
|
||||||
$this->random = $this->getMock('\OCP\Security\ISecureRandom');
|
$this->random = $this->createMock(ISecureRandom::class);
|
||||||
$this->setupClass = $this->getMock('\OC\Setup',
|
$this->setupClass = $this->getMockBuilder('\OC\Setup')
|
||||||
['class_exists', 'is_callable', 'getAvailableDbDriversForPdo'],
|
->setMethods(['class_exists', 'is_callable', 'getAvailableDbDriversForPdo'])
|
||||||
[$this->config, $this->iniWrapper, $this->l10n, $this->defaults, $this->logger, $this->random]);
|
->setConstructorArgs([$this->config, $this->iniWrapper, $this->l10n, $this->defaults, $this->logger, $this->random])
|
||||||
|
->getMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSupportedDatabasesWithOneWorking() {
|
public function testGetSupportedDatabasesWithOneWorking() {
|
||||||
|
|
|
@ -60,7 +60,7 @@ class MailNotificationsTest extends \Test\TestCase {
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$this->user = $this->getMockBuilder('\OCP\IUser')
|
$this->user = $this->getMockBuilder('\OCP\IUser')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$this->urlGenerator = $this->getMock('\OCP\IURLGenerator');
|
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
||||||
|
|
||||||
$this->l10n->expects($this->any())
|
$this->l10n->expects($this->any())
|
||||||
->method('t')
|
->method('t')
|
||||||
|
@ -212,14 +212,17 @@ class MailNotificationsTest extends \Test\TestCase {
|
||||||
$this->setupMailerMock('TestUser shared »welcome.txt« with you', ['recipient@owncloud.com' => 'Recipient'], false);
|
$this->setupMailerMock('TestUser shared »welcome.txt« with you', ['recipient@owncloud.com' => 'Recipient'], false);
|
||||||
|
|
||||||
/** @var MailNotifications | \PHPUnit_Framework_MockObject_MockObject $mailNotifications */
|
/** @var MailNotifications | \PHPUnit_Framework_MockObject_MockObject $mailNotifications */
|
||||||
$mailNotifications = $this->getMock('OC\Share\MailNotifications',['getItemSharedWithUser'], [
|
$mailNotifications = $this->getMockBuilder(MailNotifications::class)
|
||||||
|
->setMethods(['getItemSharedWithUser'])
|
||||||
|
->setConstructorArgs([
|
||||||
$this->user,
|
$this->user,
|
||||||
$this->l10n,
|
$this->l10n,
|
||||||
$this->mailer,
|
$this->mailer,
|
||||||
$this->logger,
|
$this->logger,
|
||||||
$this->defaults,
|
$this->defaults,
|
||||||
$this->urlGenerator
|
$this->urlGenerator
|
||||||
]);
|
])
|
||||||
|
->getMock();
|
||||||
|
|
||||||
$mailNotifications->method('getItemSharedWithUser')
|
$mailNotifications->method('getItemSharedWithUser')
|
||||||
->withAnyParameters()
|
->withAnyParameters()
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
namespace Test\Share20;
|
namespace Test\Share20;
|
||||||
|
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
|
use OCP\IUserManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ShareTest
|
* Class ShareTest
|
||||||
|
@ -35,8 +36,8 @@ class ShareTest extends \Test\TestCase {
|
||||||
protected $share;
|
protected $share;
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
$this->rootFolder = $this->getMock('\OCP\Files\IRootFolder');
|
$this->rootFolder = $this->createMock(IRootFolder::class);
|
||||||
$this->userManager = $this->getMock('OCP\IUserManager');
|
$this->userManager = $this->createMock(IUserManager::class);
|
||||||
$this->share = new \OC\Share20\Share($this->rootFolder, $this->userManager);
|
$this->share = new \OC\Share20\Share($this->rootFolder, $this->userManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
namespace Test;
|
namespace Test;
|
||||||
|
|
||||||
use OC\Log;
|
use OC\Log;
|
||||||
|
use OCP\IConfig;
|
||||||
|
|
||||||
class NullLogger extends Log {
|
class NullLogger extends Log {
|
||||||
public function __construct($logger = null) {
|
public function __construct($logger = null) {
|
||||||
|
@ -50,7 +51,7 @@ class TempManagerTest extends \Test\TestCase {
|
||||||
$logger = new NullLogger();
|
$logger = new NullLogger();
|
||||||
}
|
}
|
||||||
if (!$config) {
|
if (!$config) {
|
||||||
$config = $this->getMock('\OCP\IConfig');
|
$config = $this->createMock(IConfig::class);
|
||||||
$config->method('getSystemValue')
|
$config->method('getSystemValue')
|
||||||
->with('tempdirectory', null)
|
->with('tempdirectory', null)
|
||||||
->willReturn('/tmp');
|
->willReturn('/tmp');
|
||||||
|
@ -140,7 +141,7 @@ class TempManagerTest extends \Test\TestCase {
|
||||||
public function testLogCantCreateFile() {
|
public function testLogCantCreateFile() {
|
||||||
$this->markTestSkipped('TODO: Disable because fails on drone');
|
$this->markTestSkipped('TODO: Disable because fails on drone');
|
||||||
|
|
||||||
$logger = $this->getMock('\Test\NullLogger');
|
$logger = $this->createMock(NullLogger::class);
|
||||||
$manager = $this->getManager($logger);
|
$manager = $this->getManager($logger);
|
||||||
chmod($this->baseDir, 0500);
|
chmod($this->baseDir, 0500);
|
||||||
$logger->expects($this->once())
|
$logger->expects($this->once())
|
||||||
|
@ -152,7 +153,7 @@ class TempManagerTest extends \Test\TestCase {
|
||||||
public function testLogCantCreateFolder() {
|
public function testLogCantCreateFolder() {
|
||||||
$this->markTestSkipped('TODO: Disable because fails on drone');
|
$this->markTestSkipped('TODO: Disable because fails on drone');
|
||||||
|
|
||||||
$logger = $this->getMock('\Test\NullLogger');
|
$logger = $this->createMock(NullLogger::class);
|
||||||
$manager = $this->getManager($logger);
|
$manager = $this->getManager($logger);
|
||||||
chmod($this->baseDir, 0500);
|
chmod($this->baseDir, 0500);
|
||||||
$logger->expects($this->once())
|
$logger->expects($this->once())
|
||||||
|
@ -162,7 +163,7 @@ class TempManagerTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBuildFileNameWithPostfix() {
|
public function testBuildFileNameWithPostfix() {
|
||||||
$logger = $this->getMock('\Test\NullLogger');
|
$logger = $this->createMock(NullLogger::class);
|
||||||
$tmpManager = self::invokePrivate(
|
$tmpManager = self::invokePrivate(
|
||||||
$this->getManager($logger),
|
$this->getManager($logger),
|
||||||
'buildFileNameWithSuffix',
|
'buildFileNameWithSuffix',
|
||||||
|
@ -173,7 +174,7 @@ class TempManagerTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBuildFileNameWithoutPostfix() {
|
public function testBuildFileNameWithoutPostfix() {
|
||||||
$logger = $this->getMock('\Test\NullLogger');
|
$logger = $this->createMock(NullLogger::class);
|
||||||
$tmpManager = self::invokePrivate(
|
$tmpManager = self::invokePrivate(
|
||||||
$this->getManager($logger),
|
$this->getManager($logger),
|
||||||
'buildFileNameWithSuffix',
|
'buildFileNameWithSuffix',
|
||||||
|
@ -184,7 +185,7 @@ class TempManagerTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBuildFileNameWithSuffixPathTraversal() {
|
public function testBuildFileNameWithSuffixPathTraversal() {
|
||||||
$logger = $this->getMock('\Test\NullLogger');
|
$logger = $this->createMock(NullLogger::class);
|
||||||
$tmpManager = self::invokePrivate(
|
$tmpManager = self::invokePrivate(
|
||||||
$this->getManager($logger),
|
$this->getManager($logger),
|
||||||
'buildFileNameWithSuffix',
|
'buildFileNameWithSuffix',
|
||||||
|
@ -198,7 +199,7 @@ class TempManagerTest extends \Test\TestCase {
|
||||||
public function testGetTempBaseDirFromConfig() {
|
public function testGetTempBaseDirFromConfig() {
|
||||||
$dir = $this->getManager()->getTemporaryFolder();
|
$dir = $this->getManager()->getTemporaryFolder();
|
||||||
|
|
||||||
$config = $this->getMock('\OCP\IConfig');
|
$config = $this->createMock(IConfig::class);
|
||||||
$config->expects($this->once())
|
$config->expects($this->once())
|
||||||
->method('getSystemValue')
|
->method('getSystemValue')
|
||||||
->with('tempdirectory', null)
|
->with('tempdirectory', null)
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
namespace Test\Template;
|
namespace Test\Template;
|
||||||
|
|
||||||
use OC\Template\ResourceNotFoundException;
|
use OC\Template\ResourceNotFoundException;
|
||||||
|
use OCP\ILogger;
|
||||||
|
|
||||||
class ResourceLocatorTest extends \Test\TestCase {
|
class ResourceLocatorTest extends \Test\TestCase {
|
||||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||||
|
@ -16,7 +17,7 @@ class ResourceLocatorTest extends \Test\TestCase {
|
||||||
|
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->logger = $this->getMock('OCP\ILogger');
|
$this->logger = $this->createMock(ILogger::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,8 +41,10 @@ class VersionCheckTest extends \Test\TestCase {
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$this->updater = $this->getMock('\OC\Updater\VersionCheck',
|
$this->updater = $this->getMockBuilder(VersionCheck::class)
|
||||||
['getUrlContent'], [$clientService, $this->config]);
|
->setMethods(['getUrlContent'])
|
||||||
|
->setConstructorArgs([$clientService, $this->config])
|
||||||
|
->getMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue