Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2017-11-03 19:40:05 +0300
committerArthur Schiwon <blizzz@arthur-schiwon.de>2017-11-09 13:10:58 +0300
commitfc6b3902af03b770bc1de29cae50fb00022f355d (patch)
treedd345a51a1730c97fc69c168d6d11486ab2e0942 /apps/user_ldap/tests/Group_LDAPTest.php
parent59c05d54472aeed458611341970a72e42e5b9e6a (diff)
adjust tests
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/tests/Group_LDAPTest.php')
-rw-r--r--apps/user_ldap/tests/Group_LDAPTest.php33
1 files changed, 18 insertions, 15 deletions
diff --git a/apps/user_ldap/tests/Group_LDAPTest.php b/apps/user_ldap/tests/Group_LDAPTest.php
index 8eabf2d295a..b3b2d68f94b 100644
--- a/apps/user_ldap/tests/Group_LDAPTest.php
+++ b/apps/user_ldap/tests/Group_LDAPTest.php
@@ -33,8 +33,11 @@
namespace OCA\User_LDAP\Tests;
use OCP\GroupInterface;
+use OCA\User_LDAP\Access;
+use OCA\User_LDAP\Connection;
use OCA\User_LDAP\Group_LDAP as GroupLDAP;
use OCA\User_LDAP\ILDAPWrapper;
+use OCA\User_LDAP\User\Manager;
/**
* Class GroupLDAPTest
@@ -44,6 +47,9 @@ use OCA\User_LDAP\ILDAPWrapper;
* @package OCA\User_LDAP\Tests
*/
class Group_LDAPTest extends \Test\TestCase {
+ /**
+ * @return \PHPUnit_Framework_MockObject_MockObject|Access
+ */
private function getAccessMock() {
static $conMethods;
static $accMethods;
@@ -57,14 +63,8 @@ class Group_LDAPTest extends \Test\TestCase {
->setMethods($conMethods)
->setConstructorArgs([$lw, null, null])
->getMock();
- $um = $this->getMockBuilder('\OCA\User_LDAP\User\Manager')
- ->disableOriginalConstructor()
- ->getMock();
- $helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
- $access = $this->getMockBuilder('\OCA\User_LDAP\Access')
- ->setMethods($accMethods)
- ->setConstructorArgs([$connector, $lw, $um, $helper])
- ->getMock();
+
+ $access = $this->createMock(Access::class);
$access->expects($this->any())
->method('getConnection')
@@ -76,8 +76,13 @@ class Group_LDAPTest extends \Test\TestCase {
private function getPluginManagerMock() {
return $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager')->getMock();
}
-
+
+ /**
+ * @param Access|\PHPUnit_Framework_MockObject_MockObject $access
+ */
private function enableGroups($access) {
+ $access->connection = $this->createMock(Connection::class);
+
$access->connection->expects($this->any())
->method('__get')
->will($this->returnCallback(function($name) {
@@ -498,7 +503,6 @@ class Group_LDAPTest extends \Test\TestCase {
$access->connection->expects($this->any())
->method('getFromCache')
->will($this->returnValue(null));
-
$access->expects($this->any())
->method('readAttribute')
->will($this->returnCallback(function($dn, $attr) {
@@ -509,14 +513,13 @@ class Group_LDAPTest extends \Test\TestCase {
}
return array();
}));
-
$access->expects($this->any())
->method('groupname2dn')
->will($this->returnValue('cn=foobar,dc=foo,dc=bar'));
-
$access->expects($this->exactly(2))
->method('nextcloudUserNames')
->willReturnOnConsecutiveCalls(['lisa', 'bart', 'kira', 'brad'], ['walle', 'dino', 'xenia']);
+ $access->userManager = $this->createMock(Manager::class);
$groupBackend = new GroupLDAP($access, $pluginManager);
$users = $groupBackend->usersInGroup('foobar');
@@ -537,7 +540,6 @@ class Group_LDAPTest extends \Test\TestCase {
$access->connection->expects($this->any())
->method('getFromCache')
->will($this->returnValue(null));
-
$access->expects($this->any())
->method('readAttribute')
->will($this->returnCallback(function($dn, $attr) {
@@ -546,14 +548,13 @@ class Group_LDAPTest extends \Test\TestCase {
}
return array();
}));
-
$access->expects($this->any())
->method('groupname2dn')
->will($this->returnValue('cn=foobar,dc=foo,dc=bar'));
-
$access->expects($this->once())
->method('nextcloudUserNames')
->will($this->returnValue(array('lisa', 'bart', 'kira', 'brad')));
+ $access->userManager = $this->createMock(Manager::class);
$groupBackend = new GroupLDAP($access, $pluginManager);
$users = $groupBackend->usersInGroup('foobar');
@@ -635,6 +636,7 @@ class Group_LDAPTest extends \Test\TestCase {
$access = $this->getAccessMock();
$pluginManager = $this->getPluginManagerMock();
+ $access->connection = $this->createMock(Connection::class);
$access->connection->expects($this->any())
->method('__get')
->will($this->returnCallback(function($name) {
@@ -671,6 +673,7 @@ class Group_LDAPTest extends \Test\TestCase {
$access = $this->getAccessMock();
$pluginManager = $this->getPluginManagerMock();
+ $access->connection = $this->createMock(Connection::class);
$access->connection->expects($this->any())
->method('__get')
->will($this->returnCallback(function($name) {