|
|
|
|
@ -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();
|
|
|
|
|
|
|
|
|
|
|