Skip to content

Commit

Permalink
🚨 add test to cover null issuer
Browse files Browse the repository at this point in the history
  • Loading branch information
willpower232 committed Dec 19, 2021
1 parent 8a5cb24 commit 4f1543f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/Providers/Qr/IQRCodeProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@ public function testTotpUriIsCorrect()
$this->assertEquals('otpauth://totp/Test%26Label?secret=VMR466AB62ZBOKHE&issuer=Test%26Issuer&period=30&algorithm=SHA1&digits=6@200', $data['data']);
}

/**
* @return void
*/
public function testTotpUriIsCorrectNoIssuer()
{
$qr = new TestQrProvider();

/**
* The library specifies the issuer is null by default however in PHP 8.1
* there is a deprecation warning for passing null as a string argument to rawurlencode
*/

$tfa = new TwoFactorAuth(null, 6, 30, 'sha1', $qr);
$data = $this->DecodeDataUri($tfa->getQRCodeImageAsDataUri('Test&Label', 'VMR466AB62ZBOKHE'));
$this->assertEquals('test/test', $data['mimetype']);
$this->assertEquals('base64', $data['encoding']);
$this->assertEquals('otpauth://totp/Test%26Label?secret=VMR466AB62ZBOKHE&issuer=&period=30&algorithm=SHA1&digits=6@200', $data['data']);
}

/**
* @return void
*/
Expand Down

0 comments on commit 4f1543f

Please sign in to comment.