diff options
author | Daniel Kesselberg <mail@danielkesselberg.de> | 2019-07-09 11:58:14 +0200 |
---|---|---|
committer | Daniel Kesselberg <mail@danielkesselberg.de> | 2019-07-09 19:29:14 +0200 |
commit | d57540ac8460c746baf65323fa8af6db07a58db7 (patch) | |
tree | c7478a0e5a485c1c254f00f1fa05a2df86fc121b /tests/Core/Controller | |
parent | eb092bbdc74fd10253e7a75850d5725df27daa25 (diff) | |
download | nextcloud-server-d57540ac8460c746baf65323fa8af6db07a58db7.tar.gz nextcloud-server-d57540ac8460c746baf65323fa8af6db07a58db7.zip |
Return first value from $users
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'tests/Core/Controller')
-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 8635616a9d5..8500819a9ca 100644 --- a/tests/Core/Controller/LostControllerTest.php +++ b/tests/Core/Controller/LostControllerTest.php @@ -821,28 +821,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') @@ -852,14 +862,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); } } |