summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2019-09-05 12:55:24 +0200
committerChristoph Wurst <christoph@winzerhof-wurst.at>2019-12-13 13:06:12 +0100
commit3eee359d7ffd6219f6a2ab8cca18a13118552842 (patch)
tree94aa2317588ce3864a3d3715330c757f61d25713 /tests
parent642606754b133a36d7715b45b243155cbb006f95 (diff)
downloadnextcloud-server-3eee359d7ffd6219f6a2ab8cca18a13118552842.tar.gz
nextcloud-server-3eee359d7ffd6219f6a2ab8cca18a13118552842.zip
Allow to force enable apps via CLI
Co-authored-by: Christoph Wurst <christoph@winzerhof-wurst.at> Signed-off-by: Joas Schilling <coding@schilljs.com> Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/App/AppManagerTest.php57
-rw-r--r--tests/lib/AppTest.php1
2 files changed, 34 insertions, 24 deletions
diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php
index 11450667fcc..0e895b5f999 100644
--- a/tests/lib/App/AppManagerTest.php
+++ b/tests/lib/App/AppManagerTest.php
@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
/**
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
@@ -11,20 +11,17 @@ namespace Test\App;
use OC\App\AppManager;
use OC\AppConfig;
-use OC\Group\Group;
-use OC\User\User;
use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
-use OCP\IAppConfig;
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\ILogger;
-use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserSession;
+use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Test\TestCase;
@@ -35,7 +32,7 @@ use Test\TestCase;
*/
class AppManagerTest extends TestCase {
/**
- * @return AppConfig|\PHPUnit_Framework_MockObject_MockObject
+ * @return AppConfig|MockObject
*/
protected function getAppConfig() {
$appConfig = array();
@@ -73,25 +70,28 @@ class AppManagerTest extends TestCase {
return $config;
}
- /** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var IUserSession|MockObject */
protected $userSession;
- /** @var IGroupManager|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var IConfig|MockObject */
+ private $config;
+
+ /** @var IGroupManager|MockObject */
protected $groupManager;
- /** @var AppConfig|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var AppConfig|MockObject */
protected $appConfig;
- /** @var ICache|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ICache|MockObject */
protected $cache;
- /** @var ICacheFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ICacheFactory|MockObject */
protected $cacheFactory;
- /** @var EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var EventDispatcherInterface|MockObject */
protected $eventDispatcher;
- /** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ILogger|MockObject */
protected $logger;
/** @var IAppManager */
@@ -102,6 +102,7 @@ class AppManagerTest extends TestCase {
$this->userSession = $this->createMock(IUserSession::class);
$this->groupManager = $this->createMock(IGroupManager::class);
+ $this->config = $this->createMock(IConfig::class);
$this->appConfig = $this->getAppConfig();
$this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->cache = $this->createMock(ICache::class);
@@ -111,7 +112,15 @@ class AppManagerTest extends TestCase {
->method('createDistributed')
->with('settings')
->willReturn($this->cache);
- $this->manager = new AppManager($this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger);
+ $this->manager = new AppManager(
+ $this->userSession,
+ $this->config,
+ $this->appConfig,
+ $this->groupManager,
+ $this->cacheFactory,
+ $this->eventDispatcher,
+ $this->logger
+ );
}
protected function expectClearCache() {
@@ -161,10 +170,10 @@ class AppManagerTest extends TestCase {
$groups = [$group1, $group2];
$this->expectClearCache();
- /** @var AppManager|\PHPUnit_Framework_MockObject_MockObject $manager */
+ /** @var AppManager|MockObject $manager */
$manager = $this->getMockBuilder(AppManager::class)
->setConstructorArgs([
- $this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger
+ $this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger
])
->setMethods([
'getAppPath',
@@ -208,10 +217,10 @@ class AppManagerTest extends TestCase {
$groups = [$group1, $group2];
$this->expectClearCache();
- /** @var AppManager|\PHPUnit_Framework_MockObject_MockObject $manager */
+ /** @var AppManager|MockObject $manager */
$manager = $this->getMockBuilder(AppManager::class)
->setConstructorArgs([
- $this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger
+ $this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger
])
->setMethods([
'getAppPath',
@@ -262,10 +271,10 @@ class AppManagerTest extends TestCase {
$groups = [$group1, $group2];
- /** @var AppManager|\PHPUnit_Framework_MockObject_MockObject $manager */
+ /** @var AppManager|MockObject $manager */
$manager = $this->getMockBuilder(AppManager::class)
->setConstructorArgs([
- $this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger
+ $this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger
])
->setMethods([
'getAppPath',
@@ -426,9 +435,9 @@ class AppManagerTest extends TestCase {
}
public function testGetAppsNeedingUpgrade() {
- /** @var AppManager|\PHPUnit_Framework_MockObject_MockObject $manager */
+ /** @var AppManager|MockObject $manager */
$manager = $this->getMockBuilder(AppManager::class)
- ->setConstructorArgs([$this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger])
+ ->setConstructorArgs([$this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger])
->setMethods(['getAppInfo'])
->getMock();
@@ -476,9 +485,9 @@ class AppManagerTest extends TestCase {
}
public function testGetIncompatibleApps() {
- /** @var AppManager|\PHPUnit_Framework_MockObject_MockObject $manager */
+ /** @var AppManager|MockObject $manager */
$manager = $this->getMockBuilder(AppManager::class)
- ->setConstructorArgs([$this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger])
+ ->setConstructorArgs([$this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger])
->setMethods(['getAppInfo'])
->getMock();
diff --git a/tests/lib/AppTest.php b/tests/lib/AppTest.php
index 4aac0d68318..4ef370cd349 100644
--- a/tests/lib/AppTest.php
+++ b/tests/lib/AppTest.php
@@ -549,6 +549,7 @@ class AppTest extends \Test\TestCase {
$this->overwriteService('AppConfig', $appConfig);
$this->overwriteService('AppManager', new \OC\App\AppManager(
\OC::$server->getUserSession(),
+ \OC::$server->getConfig(),
$appConfig,
\OC::$server->getGroupManager(),
\OC::$server->getMemCacheFactory(),