Skip to content
Prev Previous commit
Next Next commit
Fix more tests in the Core subdir
Signed-off-by: Vincent Petry <[email protected]>
  • Loading branch information
PVince81 authored and backportbot[bot] committed Mar 24, 2021
commit 97c11ff48b1ec6849164b48dcfc5cf8b3b6034e6
9 changes: 8 additions & 1 deletion tests/Core/Command/Preview/RepairTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use OCP\Files\Node;
use OCP\IConfig;
use OCP\ILogger;
use OCP\Lock\ILockingProvider;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -43,7 +44,13 @@ protected function setUp(): void {
->getMock();
$this->iniGetWrapper = $this->getMockBuilder(IniGetWrapper::class)
->getMock();
$this->repair = new Repair($this->config, $this->rootFolder, $this->logger, $this->iniGetWrapper);
$this->repair = new Repair(
$this->config,
$this->rootFolder,
$this->logger,
$this->iniGetWrapper,
$this->createMock(ILockingProvider::class)
);
$this->input = $this->getMockBuilder(InputInterface::class)
->getMock();
$this->input->expects($this->any())
Expand Down
10 changes: 5 additions & 5 deletions tests/Core/Controller/AppPasswordControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
use OCP\Authentication\Exceptions\PasswordUnavailableException;
use OCP\Authentication\LoginCredentials\ICredentials;
use OCP\Authentication\LoginCredentials\IStore;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IRequest;
use OCP\ISession;
use OCP\Security\ISecureRandom;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Test\TestCase;

class AppPasswordControllerTest extends TestCase {
Expand All @@ -59,7 +59,7 @@ class AppPasswordControllerTest extends TestCase {
/** @var IRequest|MockObject */
private $request;

/** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject */
/** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
private $eventDispatcher;

/** @var AppPasswordController */
Expand All @@ -73,7 +73,7 @@ protected function setUp(): void {
$this->tokenProvider = $this->createMock(IProvider::class);
$this->credentialStore = $this->createMock(IStore::class);
$this->request = $this->createMock(IRequest::class);
$this->eventDispatcher = $this->createMock(EventDispatcherInterface::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);

$this->controller = new AppPasswordController(
'core',
Expand Down Expand Up @@ -144,7 +144,7 @@ public function testGetAppPassword() {
);

$this->eventDispatcher->expects($this->once())
->method('dispatch');
->method('dispatchTyped');

$this->controller->getAppPassword();
}
Expand Down Expand Up @@ -185,7 +185,7 @@ public function testGetAppPasswordNoPassword() {
);

$this->eventDispatcher->expects($this->once())
->method('dispatch');
->method('dispatchTyped');

$this->controller->getAppPassword();
}
Expand Down
14 changes: 7 additions & 7 deletions tests/Core/Controller/ClientFlowLoginControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\StandaloneTemplateResponse;
use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IL10N;
use OCP\IRequest;
use OCP\ISession;
Expand All @@ -41,7 +42,6 @@
use OCP\Security\ICrypto;
use OCP\Security\ISecureRandom;
use OCP\Session\Exceptions\SessionNotAvailableException;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Test\TestCase;

class ClientFlowLoginControllerTest extends TestCase {
Expand All @@ -67,7 +67,7 @@ class ClientFlowLoginControllerTest extends TestCase {
private $accessTokenMapper;
/** @var ICrypto|\PHPUnit\Framework\MockObject\MockObject */
private $crypto;
/** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject */
/** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
private $eventDispatcher;


Expand All @@ -94,7 +94,7 @@ protected function setUp(): void {
$this->clientMapper = $this->createMock(ClientMapper::class);
$this->accessTokenMapper = $this->createMock(AccessTokenMapper::class);
$this->crypto = $this->createMock(ICrypto::class);
$this->eventDispatcher = $this->createMock(EventDispatcherInterface::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);

$this->clientFlowLoginController = new ClientFlowLoginController(
'core',
Expand Down Expand Up @@ -392,7 +392,7 @@ public function testGeneratePasswordWithPassword() {
->willReturn('');

$this->eventDispatcher->expects($this->once())
->method('dispatch');
->method('dispatchTyped');

$expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken');
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
Expand Down Expand Up @@ -488,7 +488,7 @@ public function testGeneratePasswordWithPasswordForOauthClient($redirectUri, $re
->willReturn($client);

$this->eventDispatcher->expects($this->once())
->method('dispatch');
->method('dispatchTyped');

$expected = new Http\RedirectResponse($redirectUrl);
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken', 'MyClientIdentifier'));
Expand Down Expand Up @@ -563,7 +563,7 @@ public function testGeneratePasswordWithoutPassword() {
->willReturn('');

$this->eventDispatcher->expects($this->once())
->method('dispatch');
->method('dispatchTyped');

$expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken');
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
Expand Down Expand Up @@ -694,7 +694,7 @@ public function testGeneratePasswordWithHttpsProxy(array $headers, $protocol, $e
->willReturnMap($headers);

$this->eventDispatcher->expects($this->once())
->method('dispatch');
->method('dispatchTyped');

$expected = new Http\RedirectResponse('nc://login/server:' . $expected . '://example.com&user:MyLoginName&password:MyGeneratedToken');
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
Expand Down