Fix bugs related to unit tests

Fix unit test errors
Fix admin unit test failure
Fix group to id translation

Signed-off-by: Jonathan Treffler <mail@jonathan-treffler.de>
Signed-off-by: Giuliano Mele <giuliano.mele@verdigado.com>
This commit is contained in:
Giuliano Mele 2021-07-22 14:57:34 +02:00 committed by Jonathan Treffler
parent c5ff4555a3
commit 0b62b91a89
3 changed files with 10 additions and 4 deletions

View file

@ -3,6 +3,7 @@
namespace OCA\User_SAML;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\DBAL\FetchMode;
use OCA\User_SAML\Exceptions\AddUserToGroupException;
use OCP\Group\Backend\ABackend;
use OCP\Group\Backend\IAddToGroupBackend;
@ -114,7 +115,7 @@ class GroupBackend extends ABackend implements IAddToGroupBackend {
->from(self::TABLE_GROUPS)
->where($qb->expr()->eq('saml_gid', $qb->createNamedParameter($samlGid)))
->execute();
$result = $cursor->fetch();
$result = $cursor->fetch(FetchMode::NUMERIC);
$cursor->closeCursor();
if ($result !== false) {

View file

@ -147,6 +147,11 @@ class AdminTest extends \Test\TestCase {
'type' => 'line',
'required' => true,
],
'group_mapping_prefix' => [
'text' => $this->l10n->t('Group Mapping Prefix'),
'type' => 'line',
'required' => true,
],
];
$nameIdFormats = [

View file

@ -28,7 +28,7 @@ use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IGroup;
use OCP\IGroupManager;
use OCA\User_SAML\GroupManager;
use OCP\ILogger;
use OCP\ISession;
use OCP\IURLGenerator;
@ -51,7 +51,7 @@ class UserBackendTest extends TestCase {
private $db;
/** @var IUserManager|MockObject */
private $userManager;
/** @var IGroupManager|MockObject */
/** @var GroupManager|\PHPUnit_Framework_MockObject_MockObject */
private $groupManager;
/** @var UserBackend|MockObject */
private $userBackend;
@ -70,7 +70,7 @@ class UserBackendTest extends TestCase {
$this->session = $this->createMock(ISession::class);
$this->db = $this->createMock(IDBConnection::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->groupManager = $this->createMock(GroupManager::class);
$this->SAMLSettings = $this->getMockBuilder(SAMLSettings::class)->disableOriginalConstructor()->getMock();
$this->logger = $this->createMock(ILogger::class);
$this->userData = $this->createMock(UserData::class);