Skip to content

Commit

Permalink
fix: adjust test for static method invocation
Browse files Browse the repository at this point in the history
Signed-off-by: ernolf <[email protected]>
  • Loading branch information
ernolf committed Aug 8, 2024
1 parent bf4f8e7 commit 800c808
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions tests/Unit/Controller/SettingsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,28 @@ public function testCreateSecret() {
->method('getCloudId')
->willReturn('[email protected]');

$secret = 'newsecret';
$algorithm = ITotp::getAlgorithmById(1);
$digits = 6;
$period = ITotp::DEFAULT_PERIOD;
$this->totp->expects($this->once())
->method('createSecret')
->with($user, null, 1, 6, 30)
->willReturn('newsecret');

// Mock the default algorithm and digits
$this->totp->expects($this->once())
->method('getDefaultAlgorithm')
->willReturn(1);
$this->totp->expects($this->once())
->method('getDefaultDigits')
->willReturn(6);

// Mock method for `getAlgorithmById`
$this->totp->method('getAlgorithmById')->willReturn('SHA1');

$issuer = rawurlencode($this->defaults->getName());
$qrUrl = "otpauth://totp/{$issuer}:user%40instance.com?secret=$secret&issuer=$issuer&algorithm=SHA1&digits=$digits&period=$period&image=";
$qrUrl = "otpauth://totp/{$issuer}:user%40instance.com?secret=newsecret&issuer=$issuer&algorithm=SHA1&digits=6&period=30&image=";

$expected = new JSONResponse([
'state' => ITotp::STATE_CREATED,
'secret' => $secret,
'secret' => 'newsecret',
'qrUrl' => $qrUrl
]);

Expand Down

0 comments on commit 800c808

Please sign in to comment.