summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2016-07-14 13:49:18 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-07-14 13:49:18 +0200
commita3fa0d00c36d6f85e4af4eadcbeee5cf8be3fad7 (patch)
tree3809edd3b34b08d128769fa8962067ea7e5d5bee /tests
parenta6c23a1f8b2d31764bfa327ab905bab1a380b364 (diff)
downloadnextcloud-server-a3fa0d00c36d6f85e4af4eadcbeee5cf8be3fad7.tar.gz
nextcloud-server-a3fa0d00c36d6f85e4af4eadcbeee5cf8be3fad7.zip
Cleanup ManagerTest
* Fix deprecated getMock call * No longer requires DB
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/App/ManagerTest.php44
1 files changed, 32 insertions, 12 deletions
diff --git a/tests/lib/App/ManagerTest.php b/tests/lib/App/ManagerTest.php
index 26584829b5f..2d4ec4968b0 100644
--- a/tests/lib/App/ManagerTest.php
+++ b/tests/lib/App/ManagerTest.php
@@ -17,7 +17,6 @@ use Test\TestCase;
* Class Manager
*
* @package Test\App
- * @group DB
*/
class ManagerTest extends TestCase {
/**
@@ -85,12 +84,22 @@ class ManagerTest extends TestCase {
protected function setUp() {
parent::setUp();
- $this->userSession = $this->getMock('\OCP\IUserSession');
- $this->groupManager = $this->getMock('\OCP\IGroupManager');
+ $this->userSession = $this->getMockBuilder('\OCP\IUserSession')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->groupManager = $this->getMockBuilder('\OCP\IGroupManager')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->appConfig = $this->getAppConfig();
- $this->cacheFactory = $this->getMock('\OCP\ICacheFactory');
- $this->cache = $this->getMock('\OCP\ICache');
- $this->eventDispatcher = $this->getMock('\Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $this->cacheFactory = $this->getMockBuilder('\OCP\ICacheFactory')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->cache = $this->getMockBuilder('\OCP\ICache')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->eventDispatcher = $this->getMockBuilder('\Symfony\Component\EventDispatcher\EventDispatcherInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->cacheFactory->expects($this->any())
->method('create')
->with('settings')
@@ -228,20 +237,31 @@ class ManagerTest extends TestCase {
$this->assertTrue($this->manager->isInstalled('test'));
}
+ private function newUser($uid) {
+ $config = $this->getMockBuilder('\OCP\IConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $urlgenerator = $this->getMockBuilder('\OCP\IURLGenerator')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ return new User($uid, null, null, $config, $urlgenerator);
+ }
+
public function testIsEnabledForUserEnabled() {
$this->appConfig->setValue('test', 'enabled', 'yes');
- $user = new User('user1', null);
+ $user = $this->newUser('user1');
$this->assertTrue($this->manager->isEnabledForUser('test', $user));
}
public function testIsEnabledForUserDisabled() {
$this->appConfig->setValue('test', 'enabled', 'no');
- $user = new User('user1', null);
+ $user = $this->newUser('user1');
$this->assertFalse($this->manager->isEnabledForUser('test', $user));
}
public function testIsEnabledForUserEnabledForGroup() {
- $user = new User('user1', null);
+ $user = $this->newUser('user1');
$this->groupManager->expects($this->once())
->method('getUserGroupIds')
->with($user)
@@ -252,7 +272,7 @@ class ManagerTest extends TestCase {
}
public function testIsEnabledForUserDisabledForGroup() {
- $user = new User('user1', null);
+ $user = $this->newUser('user1');
$this->groupManager->expects($this->once())
->method('getUserGroupIds')
->with($user)
@@ -268,7 +288,7 @@ class ManagerTest extends TestCase {
}
public function testIsEnabledForUserLoggedIn() {
- $user = new User('user1', null);
+ $user = $this->newUser('user1');
$this->userSession->expects($this->once())
->method('getUser')
@@ -290,7 +310,7 @@ class ManagerTest extends TestCase {
}
public function testGetAppsForUser() {
- $user = new User('user1', null);
+ $user = $this->newUser('user1');
$this->groupManager->expects($this->any())
->method('getUserGroupIds')
->with($user)