Skip to content

Commit

Permalink
chore: Adapt tests to added constructor parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Dec 19, 2024
1 parent aef2cab commit ecdbc26
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 46 deletions.
30 changes: 17 additions & 13 deletions apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@
use OCA\OAuth2\Exceptions\ClientNotFoundException;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IAppConfig;
use OCP\IL10N;
use OCP\IRequest;
use OCP\ISession;
use OCP\IURLGenerator;
use OCP\Security\ISecureRandom;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;

/**
* @group DB
*/
class LoginRedirectorControllerTest extends TestCase {
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
private $request;
/** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
private $urlGenerator;
/** @var ClientMapper|\PHPUnit\Framework\MockObject\MockObject */
private $clientMapper;
/** @var ISession|\PHPUnit\Framework\MockObject\MockObject */
private $session;
/** @var LoginRedirectorController */
private $loginRedirectorController;
/** @var IL10N */
private $l;
private IRequest&MockObject $request;
private IURLGenerator&MockObject $urlGenerator;
private ClientMapper&MockObject $clientMapper;
private ISession&MockObject $session;
private IL10N&MockObject $l;
private ISecureRandom&MockObject $random;
private IAppConfig&MockObject $appConfig;

private LoginRedirectorController $loginRedirectorController;

protected function setUp(): void {
parent::setUp();
Expand All @@ -42,14 +42,18 @@ protected function setUp(): void {
$this->clientMapper = $this->createMock(ClientMapper::class);
$this->session = $this->createMock(ISession::class);
$this->l = $this->createMock(IL10N::class);
$this->random = $this->createMock(ISecureRandom::class);
$this->appConfig = $this->createMock(IAppConfig::class);

$this->loginRedirectorController = new LoginRedirectorController(
'oauth2',
$this->request,
$this->urlGenerator,
$this->clientMapper,
$this->session,
$this->l
$this->l,
$this->random,
$this->appConfig,
);
}

Expand Down
54 changes: 24 additions & 30 deletions tests/Core/Controller/ClientFlowLoginControllerTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand All @@ -19,6 +22,7 @@
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IAppConfig;
use OCP\IL10N;
use OCP\IRequest;
use OCP\ISession;
Expand All @@ -28,38 +32,26 @@
use OCP\Security\ICrypto;
use OCP\Security\ISecureRandom;
use OCP\Session\Exceptions\SessionNotAvailableException;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;

class ClientFlowLoginControllerTest extends TestCase {
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
private $request;
/** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
private $userSession;
/** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
private $l10n;
/** @var Defaults|\PHPUnit\Framework\MockObject\MockObject */
private $defaults;
/** @var ISession|\PHPUnit\Framework\MockObject\MockObject */
private $session;
/** @var IProvider|\PHPUnit\Framework\MockObject\MockObject */
private $tokenProvider;
/** @var ISecureRandom|\PHPUnit\Framework\MockObject\MockObject */
private $random;
/** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
private $urlGenerator;
/** @var ClientMapper|\PHPUnit\Framework\MockObject\MockObject */
private $clientMapper;
/** @var AccessTokenMapper|\PHPUnit\Framework\MockObject\MockObject */
private $accessTokenMapper;
/** @var ICrypto|\PHPUnit\Framework\MockObject\MockObject */
private $crypto;
/** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
private $eventDispatcher;
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
private $timeFactory;

/** @var ClientFlowLoginController */
private $clientFlowLoginController;
private IRequest&MockObject $request;
private IUserSession&MockObject $userSession;
private IL10N&MockObject $l10n;
private Defaults&MockObject $defaults;
private ISession&MockObject $session;
private IProvider&MockObject $tokenProvider;
private ISecureRandom&MockObject $random;
private IURLGenerator&MockObject $urlGenerator;
private ClientMapper&MockObject $clientMapper;
private AccessTokenMapper&MockObject $accessTokenMapper;
private ICrypto&MockObject $crypto;
private IEventDispatcher&MockObject $eventDispatcher;
private ITimeFactory&MockObject $timeFactory;
private IAppConfig&MockObject $appConfig;

private ClientFlowLoginController $clientFlowLoginController;

protected function setUp(): void {
parent::setUp();
Expand All @@ -83,6 +75,7 @@ protected function setUp(): void {
$this->crypto = $this->createMock(ICrypto::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->appConfig = $this->createMock(IAppConfig::class);

$this->clientFlowLoginController = new ClientFlowLoginController(
'core',
Expand All @@ -98,7 +91,8 @@ protected function setUp(): void {
$this->accessTokenMapper,
$this->crypto,
$this->eventDispatcher,
$this->timeFactory
$this->timeFactory,
$this->appConfig,
);
}

Expand Down
6 changes: 3 additions & 3 deletions tests/lib/Config/UserConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -746,9 +746,9 @@ public function providerSearchValuesByUsers(): array {
public function testSearchValuesByUsers(
string $app,
string $key,
?ValueType $typedAs = null,
?array $userIds = null,
array $result = [],
?ValueType $typedAs,
?array $userIds,
array $result,
): void {
$userConfig = $this->generateUserConfig();
$this->assertEqualsCanonicalizing(
Expand Down

0 comments on commit ecdbc26

Please sign in to comment.