Skip to content

Commit 4f1543f

Browse files
committed
🚨 add test to cover null issuer
1 parent 8a5cb24 commit 4f1543f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/Providers/Qr/IQRCodeProviderTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,25 @@ public function testTotpUriIsCorrect()
4040
$this->assertEquals('otpauth://totp/Test%26Label?secret=VMR466AB62ZBOKHE&issuer=Test%26Issuer&period=30&algorithm=SHA1&digits=6@200', $data['data']);
4141
}
4242

43+
/**
44+
* @return void
45+
*/
46+
public function testTotpUriIsCorrectNoIssuer()
47+
{
48+
$qr = new TestQrProvider();
49+
50+
/**
51+
* The library specifies the issuer is null by default however in PHP 8.1
52+
* there is a deprecation warning for passing null as a string argument to rawurlencode
53+
*/
54+
55+
$tfa = new TwoFactorAuth(null, 6, 30, 'sha1', $qr);
56+
$data = $this->DecodeDataUri($tfa->getQRCodeImageAsDataUri('Test&Label', 'VMR466AB62ZBOKHE'));
57+
$this->assertEquals('test/test', $data['mimetype']);
58+
$this->assertEquals('base64', $data['encoding']);
59+
$this->assertEquals('otpauth://totp/Test%26Label?secret=VMR466AB62ZBOKHE&issuer=&period=30&algorithm=SHA1&digits=6@200', $data['data']);
60+
}
61+
4362
/**
4463
* @return void
4564
*/

0 commit comments

Comments
 (0)