summaryrefslogtreecommitdiffstats
path: root/tests/Core
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2022-03-21 09:49:45 +0100
committerThomas Citharel <tcit@tcit.fr>2022-06-10 16:41:41 +0200
commitabe5ff365437927ee9ee9411d71c2e9aa23c4eb7 (patch)
tree514ae9138bff15b0ae37b934909b36e46e2bf5b6 /tests/Core
parent6283d14fa69562867608d7a3fa7a2e60b27f24ac (diff)
downloadnextcloud-server-abe5ff365437927ee9ee9411d71c2e9aa23c4eb7.tar.gz
nextcloud-server-abe5ff365437927ee9ee9411d71c2e9aa23c4eb7.zip
Make LostController use IInitialState and LoggerInterface
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'tests/Core')
-rw-r--r--tests/Core/Controller/LostControllerTest.php24
1 files changed, 18 insertions, 6 deletions
diff --git a/tests/Core/Controller/LostControllerTest.php b/tests/Core/Controller/LostControllerTest.php
index 9fa8a4b0173..31f2767ea4f 100644
--- a/tests/Core/Controller/LostControllerTest.php
+++ b/tests/Core/Controller/LostControllerTest.php
@@ -28,12 +28,12 @@ use OC\Core\Events\PasswordResetEvent;
use OC\Mail\Message;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\AppFramework\Services\IInitialState;
use OCP\Defaults;
use OCP\Encryption\IEncryptionModule;
use OCP\Encryption\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
-use OCP\IInitialStateService;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IURLGenerator;
@@ -72,12 +72,12 @@ class LostControllerTest extends TestCase {
private $encryptionManager;
/** @var IRequest|MockObject */
private $request;
- /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var LoggerInterface|MockObject */
private $logger;
/** @var Manager|MockObject */
private $twofactorManager;
- /** @var IInitialStateService|MockObject */
- private $initialStateService;
+ /** @var IInitialState|MockObject */
+ private $initialState;
/** @var IVerificationToken|MockObject */
private $verificationToken;
/** @var IEventDispatcher|MockObject */
@@ -126,7 +126,7 @@ class LostControllerTest extends TestCase {
->willReturn(true);
$this->logger = $this->createMock(LoggerInterface::class);
$this->twofactorManager = $this->createMock(Manager::class);
- $this->initialStateService = $this->createMock(IInitialStateService::class);
+ $this->initialState = $this->createMock(IInitialState::class);
$this->verificationToken = $this->createMock(IVerificationToken::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->lostController = new LostController(
@@ -142,7 +142,7 @@ class LostControllerTest extends TestCase {
$this->mailer,
$this->logger,
$this->twofactorManager,
- $this->initialStateService,
+ $this->initialState,
$this->verificationToken,
$this->eventDispatcher
);
@@ -176,6 +176,18 @@ class LostControllerTest extends TestCase {
$this->verificationToken->expects($this->once())
->method('check')
->with('MySecretToken', $this->existingUser, 'lostpassword', 'test@example.com');
+ $this->urlGenerator
+ ->expects($this->once())
+ ->method('linkToRouteAbsolute')
+ ->with('core.lost.setPassword', ['userId' => 'ValidTokenUser', 'token' => 'MySecretToken'])
+ ->willReturn('https://example.tld/index.php/lostpassword/set/sometoken/someuser');
+ $this->initialState
+ ->expects($this->exactly(2))
+ ->method('provideInitialState')
+ ->withConsecutive(
+ ['resetPasswordUser', 'ValidTokenUser'],
+ ['resetPasswordTarget', 'https://example.tld/index.php/lostpassword/set/sometoken/someuser']
+ );
$response = $this->lostController->resetform('MySecretToken', 'ValidTokenUser');
$expectedResponse = new TemplateResponse('core',