mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-12-14 11:12:37 +01:00
91 lines
18 KiB
PHP
91 lines
18 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Services;
|
|
|
|
use App\Facades\QrCode;
|
|
use App\Services\QrCodeService;
|
|
use Exception;
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use PHPUnit\Framework\Attributes\DataProvider;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use Tests\Classes\LocalFile;
|
|
use Tests\FeatureTestCase;
|
|
use Zxing\ChecksumException;
|
|
use Zxing\FormatException;
|
|
use Zxing\NotFoundException;
|
|
use Zxing\QrReader;
|
|
|
|
/**
|
|
* QrCodeServiceTest test class
|
|
*/
|
|
#[CoversClass(QrCodeService::class)]
|
|
#[CoversClass(QrCode::class)]
|
|
class QrCodeServiceTest extends FeatureTestCase
|
|
{
|
|
private const STRING_TO_ENCODE = 'stringToEncode';
|
|
|
|
private const STRING_ENCODED = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBjbGFzcz0icXItc3ZnIHFyY29kZSIgdmlld0JveD0iMCAwIDI1IDI1IiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCI+DQo8cGF0aCBjbGFzcz0icXItZGF0YSBsaWdodCBxcmNvZGUiIGZpbGw9IiNmZmYiIGQ9Ik0xMiAyIGgxIHYxIGgtMVogTTEzIDIgaDEgdjEgaC0xWiBNMTIgMyBoMSB2MSBoLTFaIE0xMyAzIGgxIHYxIGgtMVogTTExIDQgaDEgdjEgaC0xWiBNMTMgNCBoMSB2MSBoLTFaIE0xMSA1IGgxIHYxIGgtMVogTTEyIDUgaDEgdjEgaC0xWiBNMTQgNSBoMSB2MSBoLTFaIE0xNCA2IGgxIHYxIGgtMVogTTExIDcgaDEgdjEgaC0x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IHYxIGgtMVogTTUgNiBoMSB2MSBoLTFaIE02IDYgaDEgdjEgaC0xWiBNMTggNiBoMSB2MSBoLTFaIE0xOSA2IGgxIHYxIGgtMVogTTIwIDYgaDEgdjEgaC0xWiBNNCAxOCBoMSB2MSBoLTFaIE01IDE4IGgxIHYxIGgtMVogTTYgMTggaDEgdjEgaC0xWiBNNCAxOSBoMSB2MSBoLTFaIE01IDE5IGgxIHYxIGgtMVogTTYgMTkgaDEgdjEgaC0xWiBNNCAyMCBoMSB2MSBoLTFaIE01IDIwIGgxIHYxIGgtMVogTTYgMjAgaDEgdjEgaC0xWiIvPg0KPC9zdmc+DQo=';
|
|
|
|
private const DECODED_IMAGE = 'otpauth://totp/test@test.com?secret=A4GRFHVIRBGY7UIW';
|
|
|
|
public function setUp() : void
|
|
{
|
|
parent::setUp();
|
|
}
|
|
|
|
#[Test]
|
|
public function test_encode_returns_correct_value()
|
|
{
|
|
$this->assertEquals(self::STRING_ENCODED, QrCode::encode(self::STRING_TO_ENCODE));
|
|
}
|
|
|
|
#[Test]
|
|
public function test_decode_valid_image_returns_correct_value()
|
|
{
|
|
$file = LocalFile::fake()->validQrcode();
|
|
|
|
$this->assertEquals(self::DECODED_IMAGE, QrCode::decode($file));
|
|
}
|
|
|
|
#[Test]
|
|
public function test_decode_invalid_image_throws_an_exception()
|
|
{
|
|
$this->expectException(\App\Exceptions\InvalidQrCodeException::class);
|
|
|
|
QrCode::decode(LocalFile::fake()->invalidQrcode());
|
|
}
|
|
|
|
#[Test]
|
|
#[DataProvider('QrReaderExceptionProvider')]
|
|
public function test_decodee_throws_an_exception($exception)
|
|
{
|
|
$this->expectException(\App\Exceptions\InvalidQrCodeException::class);
|
|
|
|
// QrReader is a final class, so we need to mock it here with a new object instance
|
|
// to then bind it to the container
|
|
$fileContent = LocalFile::fake()->validQrcode()->get();
|
|
$qrReader = \Mockery::mock(new QrReader($fileContent, QrReader::SOURCE_TYPE_BLOB))->makePartial();
|
|
$qrReader->shouldReceive('text')->andReturn('');
|
|
$qrReader->shouldReceive('getError')->andReturn($exception);
|
|
|
|
$this->app->bind(QrReader::class, function() use($qrReader) {
|
|
return $qrReader;
|
|
});
|
|
|
|
QrCode::decode(LocalFile::fake()->validQrcode());
|
|
}
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public static function QrReaderExceptionProvider()
|
|
{
|
|
return [
|
|
'NotFoundException' => [new NotFoundException()],
|
|
'FormatException' => [new FormatException()],
|
|
'ChecksumException' => [new ChecksumException()],
|
|
'default' => [new Exception()],
|
|
];
|
|
}
|
|
}
|