fix unit tests after rebase

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2017-11-07 13:19:08 +01:00
parent 8113f26eed
commit 3ba8b337a4
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
2 changed files with 67 additions and 48 deletions

View File

@ -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');
}

View File

@ -210,9 +210,11 @@ class User_LDAPTest extends TestCase {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
$access->userManager->expects($this->any())
->method('get')
->willReturn($user);
$backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock());
->willReturn($user);
\OC_User::useBackend($backend);
@ -266,10 +268,11 @@ class User_LDAPTest extends TestCase {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
$backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock());
$access->userManager->expects($this->any())
->method('get')
->willReturn($user);
$backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock());
\OC_User::useBackend($backend);
$result = \OCP\User::checkPassword('roland', 'dt19');
@ -1196,6 +1199,7 @@ class User_LDAPTest extends TestCase {
->with($this->equalTo('loginName2UserName-'.$loginName), $this->equalTo($username));
$backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock());
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getUsername')
->willReturn('alice');
@ -1363,6 +1367,11 @@ class User_LDAPTest extends TestCase {
$access = $this->getAccessMock();
$this->prepareAccessForSetPassword($access);
$access->userManager->expects($this->any())
->method('get')
->willReturn($this->createMock(User::class));
$backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock());
$access->userManager->expects($this->any())
->method('get')