2FAuth/tests/Unit/QrcodeTest.php
2020-03-02 17:11:17 +01:00

81 lines
6.8 KiB
PHP

<?php
namespace Tests\Unit;
use Zxing\QrReader;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Tests\TestCase;
class QrcodeTest extends TestCase
{
use WithoutMiddleware;
/**
* test upload icon with no missing image resource via API
*
* @test
*/
public function testQrcodeDecodeWithMissingImage()
{
$response = $this->json('POST', '/api/qrcode/decode', [
'qrcode' => '',
])
->assertStatus(422);
}
/**
* test Qrcode decode with an invalid image resource via API
*
* @test
*/
// public function testQrcodeDecodeWithInvalidImage()
// {
// Storage::fake('qrcodes');
// $file = UploadedFile::fake()->image('qrcode.jpg');
// $this->expectException(\Illuminate\Validation\ValidationException::class);
// $response = $this->json('POST', '/api/qrcode/decode', [
// 'qrcode' => $file,
// ]);
// }
/**
* test delete an uploaded icon via API
*
* @test
*/
public function testDecodeQrcode()
{
//Storage::fake('qrcodes');
$image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALcAAAC5CAYAAABqZK7vAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAFiUAABYlAUlSJPAAAA6iSURBVHhe7dJBkttYDgDRvv+lezZ2hBavzTQBkSoNMyJ3CeCzSv/8+/DwpTw/7oev5flxP3wtz4/74Wt5ftwPX8vz4374Wp4f98PX8vy4H76W58f98LU8P+6HryX/uP/555+PsTKZFdonK5qVonZie/Yuj8hfpeV3WZnMCu2TFc1KUTuxPXuXR+Sv0vK7rExmhfbJimalqJ3Ynr3LI/JXafldViazQvtkRbNS1E5sz97lEfmrtPwuK5NZoX2yolkpaie2Z+/yiPxVZ5ZvUO+qk0KdFOpkZXtWTtjeVzlzN7/szPIN6l11UqiTQp2sbM/KCdv7Kmfu5pedWb5BvatOCnVSqJOV7Vk5YXtf5czd/LIzyzeod9VJoU4KdbKyPSsnbO+rnLmbX3Zm+Qb1r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W6qph01YpmZUWzcpt6o3ZH5CkdvEuhriomXbWiWVnRrNym3qjdEXlKB+9SqKuKSVetaFZWNCu3qTdqd0Se0sG7FOqqYtJVK5qVFc3KbeqN2h2Rp3TwLoW6qph01YpmZUWzcpt6o3ZH7H/Bw8OH8Py4H76W58f98LU8P+6Hr+X5cT98Lc+P++FreX7cD1/L8+N++FqeH/fD1/L8uB++lH///R9pHTTkQqC2qAAAAABJRU5ErkJggg==';
//Storage::put('tests/qrcodeTest.png', base64_decode($image));
//$this->assertFileExists('storage/app/tests/qrcodeTest.png');
$response = $this->withHeaders([
'Content-Type' => 'multipart/form-data',
])
->json('POST', '/api/qrcode/decode', [
'qrcode' => $image
]);
$response->dump();
$response->dumpHeaders();
$response->assertStatus(200);
}
}