Files
famous-ly4-ev/app-modules/catalog/tests/Feature/CatalogReadApiTest.php
T
Nyan Lin Paing 7872105f2f Add Departure Time Slot and Catalog read API (T2.4, T2.5)
Adds the shared DepartureTimeSlot catalog entity with its Filament
resource, and public GET /api/v1/companies + /api/v1/destinations
endpoints (auth:sanctum + throttled) for the mini app/mobile/agent
clients to consume.
2026-08-06 21:18:52 +07:00

40 lines
1.3 KiB
PHP

<?php
use App\Models\User;
use Modules\Catalog\Models\Destination;
use Modules\Catalog\Models\EvCompany;
beforeEach(function () {
$this->token = User::factory()->create()->createToken('test-token')->plainTextToken;
});
test('lists active ev companies', function () {
$active = EvCompany::factory()->create(['is_active' => true]);
EvCompany::factory()->create(['is_active' => false]);
$this->withHeader('Authorization', "Bearer {$this->token}")
->getJson('/api/v1/companies')
->assertSuccessful()
->assertJsonCount(1, 'data')
->assertJsonFragment(['id' => $active->id]);
});
test('lists active destinations', function () {
$active = Destination::factory()->create(['is_active' => true]);
Destination::factory()->create(['is_active' => false]);
$this->withHeader('Authorization', "Bearer {$this->token}")
->getJson('/api/v1/destinations')
->assertSuccessful()
->assertJsonCount(1, 'data')
->assertJsonFragment(['id' => $active->id]);
});
test('companies endpoint rejects unauthenticated requests', function () {
$this->getJson('/api/v1/companies')->assertUnauthorized();
});
test('destinations endpoint rejects unauthenticated requests', function () {
$this->getJson('/api/v1/destinations')->assertUnauthorized();
});