Skip to content

Commit

Permalink
Fix tests, can't use image fixture it seems
Browse files Browse the repository at this point in the history
  • Loading branch information
francislavoie committed Sep 20, 2019
1 parent 94b80af commit d56abb2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"endroid/qr-code": "^2"
},
"require-dev": {
"phpunit/phpunit": "^6"
"phpunit/phpunit": "^5 || ^6"
},
"config": {
"sort-packages": true
Expand Down
11 changes: 7 additions & 4 deletions tests/GoogleAuthenticatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ class GoogleAuthenticatorTest extends \PHPUnit\Framework\TestCase
/* @var GoogleAuthenticator $googleAuthenticator */
protected $googleAuthenticator;

protected $qrCodeUrl;

protected function setUp()
{
$this->googleAuthenticator = new GoogleAuthenticator();
$this->qrCodeUrl = trim(file_get_contents(__DIR__ . '/fixtures/qr-code-url.txt'));
}

public function testItCanBeInstantiated()
Expand Down Expand Up @@ -100,7 +97,13 @@ public function testGetQRCodeUrl()
$name = 'Test';
$url = $this->googleAuthenticator->getQRCodeUrl($name, $secret);

$this->assertEquals($url, $this->qrCodeUrl);
$prefix = 'data:image/png;base64,';

$this->assertStringStartsWith($prefix, $url);

$base64part = substr($url, strlen($prefix));

$this->assertRegExp("#^[a-zA-Z0-9/+]*={0,2}$#", $base64part);
}

/**
Expand Down
Loading

0 comments on commit d56abb2

Please sign in to comment.