diff options
author | Daniel Kesselberg <mail@danielkesselberg.de> | 2019-07-09 12:58:14 +0300 |
---|---|---|
committer | Backportbot <backportbot-noreply@rullzer.com> | 2019-07-10 13:22:36 +0300 |
commit | c876b3c77bde656463dc036650a840440bcf40d3 (patch) | |
tree | 2fecfc7840b2f1bcc5ed9422d7412fd41df21d62 /tests | |
parent | 10052eb7d220b8bfaf309b1b34273068a0333b9f (diff) |
Return first value from $users
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Core/Controller/LostControllerTest.php | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/tests/Core/Controller/LostControllerTest.php b/tests/Core/Controller/LostControllerTest.php index de8e8cfbcef..e9d57f4f925 100644 --- a/tests/Core/Controller/LostControllerTest.php +++ b/tests/Core/Controller/LostControllerTest.php @@ -807,28 +807,38 @@ class LostControllerTest extends \Test\TestCase { $this->assertEquals($expectedResponse, $response); } - public function testTwoUsersWithSameEmailOneDisabled() { + + /** + * @return array + */ + public function dataTwoUserswithSameEmailOneDisabled(): array { + return [ + ['user1' => true, 'user2' => false], + ['user1' => false, 'user2' => true] + ]; + } + + /** + * @dataProvider dataTwoUserswithSameEmailOneDisabled + * @param bool $userEnabled1 + * @param bool $userEnabled2 + */ + public function testTwoUsersWithSameEmailOneDisabled(bool $userEnabled1, bool $userEnabled2): void { $user1 = $this->createMock(IUser::class); - $user1->expects($this->any()) - ->method('getEMailAddress') + $user1->method('getEMailAddress') ->willReturn('test@example.com'); - $user1->expects($this->any()) - ->method('getUID') + $user1->method('getUID') ->willReturn('User1'); - $user1->expects($this->any()) - ->method('isEnabled') - ->willReturn(true); + $user1->method('isEnabled') + ->willReturn($userEnabled1); $user2 = $this->createMock(IUser::class); - $user2->expects($this->any()) - ->method('getEMailAddress') + $user2->method('getEMailAddress') ->willReturn('test@example.com'); - $user2->expects($this->any()) - ->method('getUID') + $user2->method('getUID') ->willReturn('User2'); - $user2->expects($this->any()) - ->method('isEnabled') - ->willReturn(false); + $user2->method('isEnabled') + ->willReturn($userEnabled2); $this->userManager ->method('get') @@ -838,14 +848,7 @@ class LostControllerTest extends \Test\TestCase { ->method('getByEmail') ->willReturn([$user1, $user2]); - // request password reset for test@example.com - $response = $this->lostController->email('test@example.com'); - - $expectedResponse = new JSONResponse([ - 'status' => 'success' - ]); - $expectedResponse->throttle(); - - $this->assertEquals($expectedResponse, $response); + $result = self::invokePrivate($this->lostController, 'findUserByIdOrMail', ['test@example.com']); + $this->assertInstanceOf(IUser::class, $result); } } |