36 lines
948 B
PHP
36 lines
948 B
PHP
<?php
|
|
|
|
namespace Tests\Feature\Api\Event;
|
|
|
|
use App\Models\Event;
|
|
use App\Services\EventJoinTokenService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class EventQrCodeTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_guest_can_fetch_event_qr_code(): void
|
|
{
|
|
$event = Event::factory()->create([
|
|
'status' => 'published',
|
|
]);
|
|
|
|
$token = app(EventJoinTokenService::class)->createToken($event);
|
|
|
|
$response = $this->getJson("/api/v1/events/{$token->token}/qr?size=240");
|
|
|
|
$response->assertOk()
|
|
->assertJsonStructure([
|
|
'url',
|
|
'qr_code_data_url',
|
|
])
|
|
->assertJsonPath('url', url('/e/'.$token->token));
|
|
|
|
$dataUrl = $response->json('qr_code_data_url');
|
|
$this->assertIsString($dataUrl);
|
|
$this->assertStringStartsWith('data:image/png;base64,', $dataUrl);
|
|
}
|
|
}
|