Deploy Ladill Events / deploy (push) Successful in 47s
Add badge verification API, preserve meet_return through registration and payment, and link confirmation back to Meet with badge auto-login. Co-authored-by: Cursor <cursoragent@cursor.com>
92 lines
2.8 KiB
PHP
92 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\QrCode;
|
|
use App\Models\QrEventRegistration;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class ServiceMeetVerifyRegistrationTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected User $owner;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
config(['events.service_api_keys.meet' => 'test-meet-key']);
|
|
|
|
$this->owner = User::factory()->create(['public_id' => 'usr_verify_badge']);
|
|
}
|
|
|
|
public function test_service_api_verifies_confirmed_badge(): void
|
|
{
|
|
$event = QrCode::create([
|
|
'user_id' => $this->owner->id,
|
|
'short_code' => 'evt-verify-1',
|
|
'type' => QrCode::TYPE_EVENT,
|
|
'label' => 'Verify badge event',
|
|
'payload' => [
|
|
'content' => [
|
|
'title' => 'Verify badge event',
|
|
'format' => 'virtual',
|
|
'virtual_sessions' => [],
|
|
],
|
|
'style' => [],
|
|
],
|
|
'is_active' => true,
|
|
]);
|
|
|
|
QrEventRegistration::create([
|
|
'qr_code_id' => $event->id,
|
|
'user_id' => $this->owner->id,
|
|
'reference' => 'QRE-TESTVERIFY001',
|
|
'badge_code' => 'BADGE999',
|
|
'tier_name' => 'General',
|
|
'amount_minor' => 0,
|
|
'currency' => 'GHS',
|
|
'attendee_name' => 'Ada Lovelace',
|
|
'attendee_email' => 'ada@example.com',
|
|
'status' => QrEventRegistration::STATUS_CONFIRMED,
|
|
]);
|
|
|
|
$this->withToken('test-meet-key')
|
|
->postJson('/api/service/v1/events/'.$event->id.'/verify-registration', [
|
|
'owner_ref' => $this->owner->public_id,
|
|
'badge_code' => 'badge999',
|
|
])
|
|
->assertOk()
|
|
->assertJsonPath('registration.attendee_name', 'Ada Lovelace')
|
|
->assertJsonPath('registration.badge_code', 'BADGE999');
|
|
}
|
|
|
|
public function test_service_api_returns_not_found_for_unknown_badge(): void
|
|
{
|
|
$event = QrCode::create([
|
|
'user_id' => $this->owner->id,
|
|
'short_code' => 'evt-verify-2',
|
|
'type' => QrCode::TYPE_EVENT,
|
|
'label' => 'Missing badge event',
|
|
'payload' => [
|
|
'content' => [
|
|
'title' => 'Missing badge event',
|
|
'format' => 'virtual',
|
|
],
|
|
'style' => [],
|
|
],
|
|
'is_active' => true,
|
|
]);
|
|
|
|
$this->withToken('test-meet-key')
|
|
->postJson('/api/service/v1/events/'.$event->id.'/verify-registration', [
|
|
'owner_ref' => $this->owner->public_id,
|
|
'badge_code' => 'NOPE123',
|
|
])
|
|
->assertNotFound();
|
|
}
|
|
}
|