7872105f2f
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.
40 lines
1.3 KiB
PHP
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();
|
|
});
|