|
|
|
@ -32,6 +32,7 @@ |
|
|
|
|
|
|
|
namespace OCA\User_LDAP\Tests; |
|
|
|
|
|
|
|
use OCA\User_LDAP\GroupPluginManager; |
|
|
|
use OCP\GroupInterface; |
|
|
|
use OCA\User_LDAP\Access; |
|
|
|
use OCA\User_LDAP\Connection; |
|
|
|
@ -159,6 +160,7 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
} |
|
|
|
|
|
|
|
public function testCountUsersWithPlugin() { |
|
|
|
/** @var GroupPluginManager|\PHPUnit_Framework_MockObject_MockObject $pluginManager */ |
|
|
|
$pluginManager = $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager') |
|
|
|
->setMethods(['implementsActions','countUsersInGroup']) |
|
|
|
->getMock(); |
|
|
|
@ -173,10 +175,10 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
->with('gid', 'search') |
|
|
|
->willReturn(42); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP( |
|
|
|
$this->getAccessMock(), |
|
|
|
$pluginManager |
|
|
|
); |
|
|
|
$access = $this->getAccessMock(); |
|
|
|
$access->connection = $this->createMock(Connection::class); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP($access, $pluginManager); |
|
|
|
|
|
|
|
$this->assertEquals($ldap->countUsersInGroup('gid', 'search'),42); |
|
|
|
} |
|
|
|
@ -727,6 +729,7 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
} |
|
|
|
|
|
|
|
public function testCreateGroupWithPlugin() { |
|
|
|
/** @var GroupPluginManager|\PHPUnit_Framework_MockObject_MockObject $pluginManager */ |
|
|
|
$pluginManager = $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager') |
|
|
|
->setMethods(['implementsActions','createGroup']) |
|
|
|
->getMock(); |
|
|
|
@ -741,10 +744,10 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
->with('gid') |
|
|
|
->willReturn('result'); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP( |
|
|
|
$this->getAccessMock(), |
|
|
|
$pluginManager |
|
|
|
); |
|
|
|
$access = $this->getAccessMock(); |
|
|
|
$access->connection = $this->createMock(Connection::class); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP($access, $pluginManager); |
|
|
|
|
|
|
|
$this->assertEquals($ldap->createGroup('gid'),true); |
|
|
|
} |
|
|
|
@ -753,6 +756,7 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
* @expectedException \Exception |
|
|
|
*/ |
|
|
|
public function testCreateGroupFailing() { |
|
|
|
/** @var GroupPluginManager|\PHPUnit_Framework_MockObject_MockObject $pluginManager */ |
|
|
|
$pluginManager = $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager') |
|
|
|
->setMethods(['implementsActions', 'createGroup']) |
|
|
|
->getMock(); |
|
|
|
@ -762,15 +766,16 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
->with(GroupInterface::CREATE_GROUP) |
|
|
|
->willReturn(false); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP( |
|
|
|
$this->getAccessMock(), |
|
|
|
$pluginManager |
|
|
|
); |
|
|
|
$access = $this->getAccessMock(); |
|
|
|
$access->connection = $this->createMock(Connection::class); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP($access, $pluginManager); |
|
|
|
|
|
|
|
$ldap->createGroup('gid'); |
|
|
|
} |
|
|
|
|
|
|
|
public function testDeleteGroupWithPlugin() { |
|
|
|
/** @var GroupPluginManager|\PHPUnit_Framework_MockObject_MockObject $pluginManager */ |
|
|
|
$pluginManager = $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager') |
|
|
|
->setMethods(['implementsActions','deleteGroup']) |
|
|
|
->getMock(); |
|
|
|
@ -785,21 +790,19 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
->with('gid') |
|
|
|
->willReturn('result'); |
|
|
|
|
|
|
|
$access = $this->getAccessMock(); |
|
|
|
|
|
|
|
$mapper = $this->getMockBuilder('\OCA\User_LDAP\Mapping\GroupMapping') |
|
|
|
->setMethods(['unmap']) |
|
|
|
->disableOriginalConstructor() |
|
|
|
->getMock(); |
|
|
|
|
|
|
|
$access = $this->getAccessMock(); |
|
|
|
$access->expects($this->any()) |
|
|
|
->method('getGroupMapper') |
|
|
|
->will($this->returnValue($mapper)); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP( |
|
|
|
$access, |
|
|
|
$pluginManager |
|
|
|
); |
|
|
|
$access->connection = $this->createMock(Connection::class); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP($access, $pluginManager); |
|
|
|
|
|
|
|
$this->assertEquals($ldap->deleteGroup('gid'),'result'); |
|
|
|
} |
|
|
|
@ -808,6 +811,7 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
* @expectedException \Exception |
|
|
|
*/ |
|
|
|
public function testDeleteGroupFailing() { |
|
|
|
/** @var GroupPluginManager|\PHPUnit_Framework_MockObject_MockObject $pluginManager */ |
|
|
|
$pluginManager = $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager') |
|
|
|
->setMethods(['implementsActions', 'deleteGroup']) |
|
|
|
->getMock(); |
|
|
|
@ -817,15 +821,16 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
->with(GroupInterface::DELETE_GROUP) |
|
|
|
->willReturn(false); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP( |
|
|
|
$this->getAccessMock(), |
|
|
|
$pluginManager |
|
|
|
); |
|
|
|
$access = $this->getAccessMock(); |
|
|
|
$access->connection = $this->createMock(Connection::class); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP($access, $pluginManager); |
|
|
|
|
|
|
|
$ldap->deleteGroup('gid'); |
|
|
|
} |
|
|
|
|
|
|
|
public function testAddToGroupWithPlugin() { |
|
|
|
/** @var GroupPluginManager|\PHPUnit_Framework_MockObject_MockObject $pluginManager */ |
|
|
|
$pluginManager = $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager') |
|
|
|
->setMethods(['implementsActions','addToGroup']) |
|
|
|
->getMock(); |
|
|
|
@ -840,10 +845,10 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
->with('uid', 'gid') |
|
|
|
->willReturn('result'); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP( |
|
|
|
$this->getAccessMock(), |
|
|
|
$pluginManager |
|
|
|
); |
|
|
|
$access = $this->getAccessMock(); |
|
|
|
$access->connection = $this->createMock(Connection::class); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP($access, $pluginManager); |
|
|
|
|
|
|
|
$this->assertEquals($ldap->addToGroup('uid', 'gid'),'result'); |
|
|
|
} |
|
|
|
@ -852,6 +857,7 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
* @expectedException \Exception |
|
|
|
*/ |
|
|
|
public function testAddToGroupFailing() { |
|
|
|
/** @var GroupPluginManager|\PHPUnit_Framework_MockObject_MockObject $pluginManager */ |
|
|
|
$pluginManager = $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager') |
|
|
|
->setMethods(['implementsActions', 'addToGroup']) |
|
|
|
->getMock(); |
|
|
|
@ -861,15 +867,16 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
->with(GroupInterface::ADD_TO_GROUP) |
|
|
|
->willReturn(false); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP( |
|
|
|
$this->getAccessMock(), |
|
|
|
$pluginManager |
|
|
|
); |
|
|
|
$access = $this->getAccessMock(); |
|
|
|
$access->connection = $this->createMock(Connection::class); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP($access, $pluginManager); |
|
|
|
|
|
|
|
$ldap->addToGroup('uid', 'gid'); |
|
|
|
} |
|
|
|
|
|
|
|
public function testRemoveFromGroupWithPlugin() { |
|
|
|
/** @var GroupPluginManager|\PHPUnit_Framework_MockObject_MockObject $pluginManager */ |
|
|
|
$pluginManager = $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager') |
|
|
|
->setMethods(['implementsActions','removeFromGroup']) |
|
|
|
->getMock(); |
|
|
|
@ -884,10 +891,10 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
->with('uid', 'gid') |
|
|
|
->willReturn('result'); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP( |
|
|
|
$this->getAccessMock(), |
|
|
|
$pluginManager |
|
|
|
); |
|
|
|
$access = $this->getAccessMock(); |
|
|
|
$access->connection = $this->createMock(Connection::class); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP($access, $pluginManager); |
|
|
|
|
|
|
|
$this->assertEquals($ldap->removeFromGroup('uid', 'gid'),'result'); |
|
|
|
} |
|
|
|
@ -896,6 +903,7 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
* @expectedException \Exception |
|
|
|
*/ |
|
|
|
public function testRemoveFromGroupFailing() { |
|
|
|
/** @var GroupPluginManager|\PHPUnit_Framework_MockObject_MockObject $pluginManager */ |
|
|
|
$pluginManager = $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager') |
|
|
|
->setMethods(['implementsActions', 'removeFromGroup']) |
|
|
|
->getMock(); |
|
|
|
@ -905,15 +913,16 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
->with(GroupInterface::REMOVE_FROM_GROUP) |
|
|
|
->willReturn(false); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP( |
|
|
|
$this->getAccessMock(), |
|
|
|
$pluginManager |
|
|
|
); |
|
|
|
$access = $this->getAccessMock(); |
|
|
|
$access->connection = $this->createMock(Connection::class); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP($access, $pluginManager); |
|
|
|
|
|
|
|
$ldap->removeFromGroup('uid', 'gid'); |
|
|
|
} |
|
|
|
|
|
|
|
public function testGetGroupDetailsWithPlugin() { |
|
|
|
/** @var GroupPluginManager|\PHPUnit_Framework_MockObject_MockObject $pluginManager */ |
|
|
|
$pluginManager = $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager') |
|
|
|
->setMethods(['implementsActions','getGroupDetails']) |
|
|
|
->getMock(); |
|
|
|
@ -928,10 +937,10 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
->with('gid') |
|
|
|
->willReturn('result'); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP( |
|
|
|
$this->getAccessMock(), |
|
|
|
$pluginManager |
|
|
|
); |
|
|
|
$access = $this->getAccessMock(); |
|
|
|
$access->connection = $this->createMock(Connection::class); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP($access, $pluginManager); |
|
|
|
|
|
|
|
$this->assertEquals($ldap->getGroupDetails('gid'),'result'); |
|
|
|
} |
|
|
|
@ -940,6 +949,7 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
* @expectedException \Exception |
|
|
|
*/ |
|
|
|
public function testGetGroupDetailsFailing() { |
|
|
|
/** @var GroupPluginManager|\PHPUnit_Framework_MockObject_MockObject $pluginManager */ |
|
|
|
$pluginManager = $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager') |
|
|
|
->setMethods(['implementsActions', 'getGroupDetails']) |
|
|
|
->getMock(); |
|
|
|
@ -949,10 +959,10 @@ class Group_LDAPTest extends \Test\TestCase { |
|
|
|
->with(GroupInterface::GROUP_DETAILS) |
|
|
|
->willReturn(false); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP( |
|
|
|
$this->getAccessMock(), |
|
|
|
$pluginManager |
|
|
|
); |
|
|
|
$access = $this->getAccessMock(); |
|
|
|
$access->connection = $this->createMock(Connection::class); |
|
|
|
|
|
|
|
$ldap = new GroupLDAP($access, $pluginManager); |
|
|
|
|
|
|
|
$ldap->getGroupDetails('gid'); |
|
|
|
} |
|
|
|
|