From 4f1543f7828a5c620666701a99535372238ddd6b Mon Sep 17 00:00:00 2001 From: William Hall Date: Sun, 19 Dec 2021 18:16:38 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20add=20test=20to=20cover=20null?= =?UTF-8?q?=20issuer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Providers/Qr/IQRCodeProviderTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/Providers/Qr/IQRCodeProviderTest.php b/tests/Providers/Qr/IQRCodeProviderTest.php index 86dd431..579cb51 100644 --- a/tests/Providers/Qr/IQRCodeProviderTest.php +++ b/tests/Providers/Qr/IQRCodeProviderTest.php @@ -40,6 +40,25 @@ class IQRCodeProviderTest extends TestCase $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 */