Skip to content

Commit ae4da10

Browse files
committed
🚨 test bacon qr code provider
1 parent 66e1e03 commit ae4da10

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

.github/workflows/test-bacon.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Test Bacon QR Code Provider
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
strategy:
12+
matrix:
13+
php-version: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: ${{ matrix.php-version }}
21+
tools: composer
22+
coverage: xdebug
23+
ini-values: error_reporting=E_ALL
24+
25+
- uses: ramsey/composer-install@v1
26+
27+
- run: composer require bacon/bacon-qr-code
28+
29+
- run: composer lint
30+
- run: composer test testsDependency/BaconQRCodeTest.php

testsDependency/BaconQRCodeTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace TestsDependency;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use RobThree\Auth\Providers\Qr\BaconQrCodeProvider;
7+
use RobThree\Auth\TwoFactorAuth;
8+
use RobThree\Auth\Providers\Qr\HandlesDataUri;
9+
10+
class BaconQRCodeTest extends TestCase
11+
{
12+
use HandlesDataUri;
13+
14+
public function testDependency()
15+
{
16+
$qr = new BaconQrCodeProvider(1, '#000', '#FFF', 'svg');
17+
18+
$tfa = new TwoFactorAuth('Test&Issuer', 6, 30, 'sha1', $qr);
19+
20+
$data = $this->DecodeDataUri($tfa->getQRCodeImageAsDataUri('Test&Label', 'VMR466AB62ZBOKHE'));
21+
$this->assertEquals('image/svg+xml', $data['mimetype']);
22+
}
23+
24+
public function testBadTextColour()
25+
{
26+
$this->expectException(\RuntimeException::class);
27+
28+
new BaconQrCodeProvider(1, 'not-a-colour', '#FFF');
29+
}
30+
31+
public function testBadBackgroundColour()
32+
{
33+
$this->expectException(\RuntimeException::class);
34+
35+
new BaconQrCodeProvider(1, '#000', 'not-a-colour');
36+
}
37+
}

0 commit comments

Comments
 (0)