Skip to content

Commit d56abb2

Browse files
committed
Fix tests, can't use image fixture it seems
1 parent 94b80af commit d56abb2

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"endroid/qr-code": "^2"
2929
},
3030
"require-dev": {
31-
"phpunit/phpunit": "^6"
31+
"phpunit/phpunit": "^5 || ^6"
3232
},
3333
"config": {
3434
"sort-packages": true

tests/GoogleAuthenticatorTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ class GoogleAuthenticatorTest extends \PHPUnit\Framework\TestCase
99
/* @var GoogleAuthenticator $googleAuthenticator */
1010
protected $googleAuthenticator;
1111

12-
protected $qrCodeUrl;
13-
1412
protected function setUp()
1513
{
1614
$this->googleAuthenticator = new GoogleAuthenticator();
17-
$this->qrCodeUrl = trim(file_get_contents(__DIR__ . '/fixtures/qr-code-url.txt'));
1815
}
1916

2017
public function testItCanBeInstantiated()
@@ -100,7 +97,13 @@ public function testGetQRCodeUrl()
10097
$name = 'Test';
10198
$url = $this->googleAuthenticator->getQRCodeUrl($name, $secret);
10299

103-
$this->assertEquals($url, $this->qrCodeUrl);
100+
$prefix = 'data:image/png;base64,';
101+
102+
$this->assertStringStartsWith($prefix, $url);
103+
104+
$base64part = substr($url, strlen($prefix));
105+
106+
$this->assertRegExp("#^[a-zA-Z0-9/+]*={0,2}$#", $base64part);
104107
}
105108

106109
/**

0 commit comments

Comments
 (0)