Browse Source

Merge pull request #37595 from jtrees/add-some-tests-to-lost-controller

Add some tests for input trimming in LostController.php
tags/v27.0.0beta1
Arthur Schiwon 1 year ago
parent
commit
1ac7a3f107
No account linked to committer's email address
1 changed files with 36 additions and 0 deletions
  1. 36
    0
      tests/Core/Controller/LostControllerTest.php

+ 36
- 0
tests/Core/Controller/LostControllerTest.php View File

<?php <?php
/** /**
* @author Lukas Reschke <lukas@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com>
* @author Joshua Trees <me@jtrees.io>
* *
* @copyright Copyright (c) 2015, ownCloud, Inc. * @copyright Copyright (c) 2015, ownCloud, Inc.
* @copyright Copyright (c) 2023, Joshua Trees <me@jtrees.io>
* @license AGPL-3.0 * @license AGPL-3.0
* *
* This code is free software: you can redistribute it and/or modify * This code is free software: you can redistribute it and/or modify
$result = self::invokePrivate($this->lostController, 'findUserByIdOrMail', ['test@example.com']); $result = self::invokePrivate($this->lostController, 'findUserByIdOrMail', ['test@example.com']);
$this->assertInstanceOf(IUser::class, $result); $this->assertInstanceOf(IUser::class, $result);
} }

public function testTrimEmailInput() {
$this->userManager
->expects($this->once())
->method('getByEmail')
->with('test@example.com')
->willReturn([$this->existingUser]);

$this->mailer
->expects($this->once())
->method('send');

$response = $this->lostController->email(' test@example.com ');
$expectedResponse = new JSONResponse(['status' => 'success']);
$expectedResponse->throttle();
$this->assertEquals($expectedResponse, $response);
}

public function testUsernameInput() {
$this->userManager
->expects($this->once())
->method('get')
->with('ExistingUser')
->willReturn($this->existingUser);

$this->mailer
->expects($this->once())
->method('send');

$response = $this->lostController->email(' ExistingUser ');
$expectedResponse = new JSONResponse(['status' => 'success']);
$expectedResponse->throttle();
$this->assertEquals($expectedResponse, $response);
}
} }

Loading…
Cancel
Save