update tests
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Api\V1\BadgeScan;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\Concerns\CreatesApiTestUsers;
|
||||
use Tests\TestCase;
|
||||
|
||||
class BadgeScanControllerTest extends TestCase
|
||||
{
|
||||
use CreatesApiTestUsers;
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_scan_is_public_but_validates_badge_value(): void
|
||||
{
|
||||
$this->postJson('/api/v1/badge_scan/scan', [])
|
||||
->assertStatus(422)
|
||||
->assertJsonPath('status', false);
|
||||
}
|
||||
|
||||
public function test_scan_returns_404_for_unrecognized_badge(): void
|
||||
{
|
||||
$this->postJson('/api/v1/badge_scan/scan', ['badge_scan' => 'UNKNOWN-BADGE-123'])
|
||||
->assertNotFound()
|
||||
->assertJsonPath('status', false);
|
||||
}
|
||||
|
||||
public function test_logs_require_authentication(): void
|
||||
{
|
||||
$this->getJson('/api/v1/badge_scan/logs')
|
||||
->assertStatus(401);
|
||||
}
|
||||
|
||||
public function test_logs_are_forbidden_for_non_staff_roles(): void
|
||||
{
|
||||
$parent = $this->createApiUserWithRole('parent');
|
||||
|
||||
$this->actingAs($parent, 'api')
|
||||
->getJson('/api/v1/badge_scan/logs')
|
||||
->assertStatus(403);
|
||||
}
|
||||
|
||||
public function test_logs_return_data_for_staff(): void
|
||||
{
|
||||
$admin = $this->createApiUserWithRole('administrator');
|
||||
|
||||
$this->actingAs($admin, 'api')
|
||||
->getJson('/api/v1/badge_scan/logs')
|
||||
->assertOk()
|
||||
->assertJsonPath('status', true)
|
||||
->assertJsonStructure(['status', 'data' => ['logs', 'meta']]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user