summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2016-10-28 09:07:40 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-10-28 10:13:35 +0200
commitf722640a32a6c0a7fb0232abf8f57052d43d19c9 (patch)
treeea3d9e1def278a2d6d2c9164701840d87f573eff /tests
parente7ec4601a36c28ad2940c66b4baeadac5cc7863e (diff)
downloadnextcloud-server-f722640a32a6c0a7fb0232abf8f57052d43d19c9.tar.gz
nextcloud-server-f722640a32a6c0a7fb0232abf8f57052d43d19c9.zip
Proper DI of config
* Fixed comments Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/Config/UserMountCacheTest.php3
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncryptionTest.php6
-rw-r--r--tests/lib/Files/Stream/EncryptionTest.php2
-rw-r--r--tests/lib/User/ManagerTest.php51
-rw-r--r--tests/lib/User/SessionTest.php30
5 files changed, 61 insertions, 31 deletions
diff --git a/tests/lib/Files/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php
index 51d488e6dee..376f0a0276c 100644
--- a/tests/lib/Files/Config/UserMountCacheTest.php
+++ b/tests/lib/Files/Config/UserMountCacheTest.php
@@ -13,6 +13,7 @@ use OC\Files\Mount\MountPoint;
use OC\Log;
use OC\User\Manager;
use OCP\Files\Config\ICachedMountInfo;
+use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IUserManager;
use Test\TestCase;
@@ -42,7 +43,7 @@ class UserMountCacheTest extends TestCase {
public function setUp() {
$this->fileIds = [];
$this->connection = \OC::$server->getDatabaseConnection();
- $this->userManager = new Manager(null);
+ $this->userManager = new Manager($this->createMock(IConfig::class));
$userBackend = new Dummy();
$userBackend->createUser('u1', '');
$userBackend->createUser('u2', '');
diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
index 55b38d546de..245f39f5e2e 100644
--- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
@@ -121,7 +121,7 @@ class EncryptionTest extends Storage {
$this->util = $this->getMockBuilder('\OC\Encryption\Util')
->setMethods(['getUidAndFilename', 'isFile', 'isExcluded'])
- ->setConstructorArgs([new View(), new Manager(), $this->groupManager, $this->config, $this->arrayCache])
+ ->setConstructorArgs([new View(), new Manager($this->config), $this->groupManager, $this->config, $this->arrayCache])
->getMock();
$this->util->expects($this->any())
->method('getUidAndFilename')
@@ -547,7 +547,7 @@ class EncryptionTest extends Storage {
->setConstructorArgs(
[
new View(),
- new Manager(),
+ new Manager($this->config),
$this->groupManager,
$this->config,
$this->arrayCache
@@ -612,7 +612,7 @@ class EncryptionTest extends Storage {
->disableOriginalConstructor()->getMock();
$util = $this->getMockBuilder('\OC\Encryption\Util')
- ->setConstructorArgs([new View(), new Manager(), $this->groupManager, $this->config, $this->arrayCache])
+ ->setConstructorArgs([new View(), new Manager($this->config), $this->groupManager, $this->config, $this->arrayCache])
->getMock();
$cache = $this->getMockBuilder('\OC\Files\Cache\Cache')
diff --git a/tests/lib/Files/Stream/EncryptionTest.php b/tests/lib/Files/Stream/EncryptionTest.php
index 6f3c879f9e6..e072dd6718d 100644
--- a/tests/lib/Files/Stream/EncryptionTest.php
+++ b/tests/lib/Files/Stream/EncryptionTest.php
@@ -43,7 +43,7 @@ class EncryptionTest extends \Test\TestCase {
$file->expects($this->any())->method('getAccessList')->willReturn([]);
$util = $this->getMockBuilder('\OC\Encryption\Util')
->setMethods(['getUidAndFilename'])
- ->setConstructorArgs([new View(), new \OC\User\Manager(), $groupManager, $config, $arrayCache])
+ ->setConstructorArgs([new View(), new \OC\User\Manager($config), $groupManager, $config, $arrayCache])
->getMock();
$util->expects($this->any())
->method('getUidAndFilename')
diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php
index 8cad7f4241a..123271bcc8f 100644
--- a/tests/lib/User/ManagerTest.php
+++ b/tests/lib/User/ManagerTest.php
@@ -9,6 +9,7 @@
namespace Test\User;
use OC\User\Database;
+use OCP\IConfig;
use OCP\IUser;
use Test\TestCase;
@@ -20,9 +21,19 @@ use Test\TestCase;
* @package Test\User
*/
class ManagerTest extends TestCase {
+
+ /** @var IConfig */
+ private $config;
+
+ public function setUp() {
+ parent::setUp();
+
+ $this->config = $this->createMock(IConfig::class);
+ }
+
public function testGetBackends() {
$userDummyBackend = $this->createMock(\Test\Util\User\Dummy::class);
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$manager->registerBackend($userDummyBackend);
$this->assertEquals([$userDummyBackend], $manager->getBackends());
$dummyDatabaseBackend = $this->createMock(Database::class);
@@ -41,7 +52,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo'))
->will($this->returnValue(true));
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
$this->assertTrue($manager->userExists('foo'));
@@ -57,14 +68,14 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo'))
->will($this->returnValue(false));
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
$this->assertFalse($manager->userExists('foo'));
}
public function testUserExistsNoBackends() {
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$this->assertFalse($manager->userExists('foo'));
}
@@ -88,7 +99,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo'))
->will($this->returnValue(true));
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend1);
$manager->registerBackend($backend2);
@@ -112,7 +123,7 @@ class ManagerTest extends TestCase {
$backend2->expects($this->never())
->method('userExists');
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend1);
$manager->registerBackend($backend2);
@@ -139,7 +150,7 @@ class ManagerTest extends TestCase {
}
}));
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
$user = $manager->checkPassword('foo', 'bar');
@@ -158,7 +169,7 @@ class ManagerTest extends TestCase {
->method('implementsActions')
->will($this->returnValue(false));
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
$this->assertFalse($manager->checkPassword('foo', 'bar'));
@@ -174,7 +185,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo'))
->will($this->returnValue(true));
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
$this->assertEquals('foo', $manager->get('foo')->getUID());
@@ -190,7 +201,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo'))
->will($this->returnValue(false));
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
$this->assertEquals(null, $manager->get('foo'));
@@ -206,7 +217,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('fo'))
->will($this->returnValue(array('foo', 'afoo')));
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
$result = $manager->search('fo');
@@ -234,7 +245,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('fo'), $this->equalTo(3), $this->equalTo(1))
->will($this->returnValue(array('foo3')));
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend1);
$manager->registerBackend($backend2);
@@ -263,7 +274,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo'))
->will($this->returnValue(false));
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
$user = $manager->createUser('foo', 'bar');
@@ -290,7 +301,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo'))
->will($this->returnValue(true));
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
$manager->createUser('foo', 'bar');
@@ -313,14 +324,14 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo'))
->will($this->returnValue(false));
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
$this->assertFalse($manager->createUser('foo', 'bar'));
}
public function testCreateUserNoBackends() {
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$this->assertFalse($manager->createUser('foo', 'bar'));
}
@@ -361,7 +372,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo'))
->will($this->returnValue(true));
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend1);
$manager->registerBackend($backend2);
@@ -369,7 +380,7 @@ class ManagerTest extends TestCase {
}
public function testCountUsersNoBackend() {
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$result = $manager->countUsers();
$this->assertTrue(is_array($result));
@@ -394,7 +405,7 @@ class ManagerTest extends TestCase {
->method('getBackendName')
->will($this->returnValue('Mock_Test_Util_User_Dummy'));
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
$result = $manager->countUsers();
@@ -435,7 +446,7 @@ class ManagerTest extends TestCase {
->method('getBackendName')
->will($this->returnValue('Mock_Test_Util_User_Dummy'));
- $manager = new \OC\User\Manager();
+ $manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend1);
$manager->registerBackend($backend2);
diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php
index 1b3d5cc4601..268d8e10e5a 100644
--- a/tests/lib/User/SessionTest.php
+++ b/tests/lib/User/SessionTest.php
@@ -190,7 +190,10 @@ class SessionTest extends \Test\TestCase {
unset($managerMethods[$i]);
}
}
- $manager = $this->getMockBuilder(Manager::class)->setMethods($managerMethods)->getMock();
+ $manager = $this->getMockBuilder(Manager::class)
+ ->setMethods($managerMethods)
+ ->setConstructorArgs([$this->config])
+ ->getMock();
$backend = $this->createMock(\Test\Util\User\Dummy::class);
@@ -245,7 +248,10 @@ class SessionTest extends \Test\TestCase {
unset($managerMethods[$i]);
}
}
- $manager = $this->getMockBuilder(Manager::class)->setMethods($managerMethods)->getMock();
+ $manager = $this->getMockBuilder(Manager::class)
+ ->setMethods($managerMethods)
+ ->setConstructorArgs([$this->config])
+ ->getMock();
$backend = $this->createMock(\Test\Util\User\Dummy::class);
@@ -277,7 +283,10 @@ class SessionTest extends \Test\TestCase {
unset($managerMethods[$i]);
}
}
- $manager = $this->getMockBuilder(Manager::class)->setMethods($managerMethods)->getMock();
+ $manager = $this->getMockBuilder(Manager::class)
+ ->setMethods($managerMethods)
+ ->setConstructorArgs([$this->config])
+ ->getMock();
$backend = $this->createMock(\Test\Util\User\Dummy::class);
$userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config);
@@ -527,7 +536,10 @@ class SessionTest extends \Test\TestCase {
unset($managerMethods[$i]);
}
}
- $manager = $this->getMockBuilder(Manager::class)->setMethods($managerMethods)->getMock();
+ $manager = $this->getMockBuilder(Manager::class)
+ ->setMethods($managerMethods)
+ ->setConstructorArgs([$this->config])
+ ->getMock();
$backend = $this->createMock(\Test\Util\User\Dummy::class);
@@ -577,7 +589,10 @@ class SessionTest extends \Test\TestCase {
unset($managerMethods[$i]);
}
}
- $manager = $this->getMockBuilder(Manager::class)->setMethods($managerMethods)->getMock();
+ $manager = $this->getMockBuilder(Manager::class)
+ ->setMethods($managerMethods)
+ ->setConstructorArgs([$this->config])
+ ->getMock();
$backend = $this->createMock(\Test\Util\User\Dummy::class);
@@ -621,7 +636,10 @@ class SessionTest extends \Test\TestCase {
unset($managerMethods[$i]);
}
}
- $manager = $this->getMockBuilder(Manager::class)->setMethods($managerMethods)->getMock();
+ $manager = $this->getMockBuilder(Manager::class)
+ ->setMethods($managerMethods)
+ ->setConstructorArgs([$this->config])
+ ->getMock();
$backend = $this->createMock(\Test\Util\User\Dummy::class);