From 0f27ba73965a9ef496a4256c4fe403fba984e30c Mon Sep 17 00:00:00 2001 From: arnorietdijk <0964045@hr.nl> Date: Tue, 24 Nov 2020 13:24:20 +0100 Subject: [PATCH] refactor test logic --- .../DownloadedRecoveryCodeHandlerTest.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/Handler/DownloadedRecoveryCodeHandlerTest.php b/tests/Handler/DownloadedRecoveryCodeHandlerTest.php index 68cfb4e..2860cca 100644 --- a/tests/Handler/DownloadedRecoveryCodeHandlerTest.php +++ b/tests/Handler/DownloadedRecoveryCodeHandlerTest.php @@ -22,25 +22,23 @@ class DownloadedRecoveryCodeHandlerTest extends TestCase { public function testSetCodesDownloadedSuccessful(): void { - $doctrine = $this->createMock(ManagerRegistry::class); - $manager = $this->createMock(EntityManager::class); - $repository = $this->createMock(EntityRepository::class); - $tokenStorage = new TokenStorage(); - $user = new User(); - $recoveryCode = new RecoveryCodeEntity(); + $doctrine = $this->createMock(ManagerRegistry::class); + $manager = $this->createMock(EntityManager::class); + $repository = $this->createMock(EntityRepository::class); + $tokenStorage = new TokenStorage(); + $user = new User(); + $recoveryCodes = [ + new RecoveryCodeEntity(), + new RecoveryCodeEntity(), + new RecoveryCodeEntity() + ]; $user->setGoogleAuthenticatorSecret('verysecret!'); $tokenStorage->setToken(new JWTUserToken([], $user)); $repository ->method('findBy') - ->willReturn( - [ - $recoveryCode, - $recoveryCode, - $recoveryCode, - ] - ); + ->willReturn($recoveryCodes); $manager ->expects($this->exactly(1)) @@ -56,6 +54,8 @@ public function testSetCodesDownloadedSuccessful(): void $handler = new DownloadedRecoveryCodeHandler($doctrine, $tokenStorage); $handler(new DownloadedRecoveryCode(true)); - $this->assertSame(true, $recoveryCode->isDownloaded()); + foreach ($recoveryCodes as $code) { + $this->assertSame(true, $code->isDownloaded()); + } } }