From cb452268004ce11a7d4cc818d67341a1a37c5c33 Mon Sep 17 00:00:00 2001 From: William Hall Date: Sun, 19 Dec 2021 19:50:25 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20test=20in=20php=20<=207.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- testsDependency/BaconQRCodeTest.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/testsDependency/BaconQRCodeTest.php b/testsDependency/BaconQRCodeTest.php index 9b426a7..e46f13d 100644 --- a/testsDependency/BaconQRCodeTest.php +++ b/testsDependency/BaconQRCodeTest.php @@ -2,6 +2,7 @@ namespace TestsDependency; +use BaconQrCode\Renderer\Image\ImagickImageBackEnd; use PHPUnit\Framework\TestCase; use RobThree\Auth\Providers\Qr\BaconQrCodeProvider; use RobThree\Auth\TwoFactorAuth; @@ -13,12 +14,19 @@ class BaconQRCodeTest extends TestCase public function testDependency() { - $qr = new BaconQrCodeProvider(1, '#000', '#FFF', 'svg'); + // php < 7.1 will install an older Bacon QR Code + if (! class_exists(ImagickImageBackEnd::class)) { + $this->expectException(\RuntimeException::class); - $tfa = new TwoFactorAuth('Test&Issuer', 6, 30, 'sha1', $qr); + $qr = new BaconQrCodeProvider(1, '#000', '#FFF', 'svg'); + } else { + $qr = new BaconQrCodeProvider(1, '#000', '#FFF', 'svg'); - $data = $this->DecodeDataUri($tfa->getQRCodeImageAsDataUri('Test&Label', 'VMR466AB62ZBOKHE')); - $this->assertEquals('image/svg+xml', $data['mimetype']); + $tfa = new TwoFactorAuth('Test&Issuer', 6, 30, 'sha1', $qr); + + $data = $this->DecodeDataUri($tfa->getQRCodeImageAsDataUri('Test&Label', 'VMR466AB62ZBOKHE')); + $this->assertEquals('image/svg+xml', $data['mimetype']); + } } public function testBadTextColour()