Files
biiproject-kit-v1/tests/Feature/MobileConfigTest.php
T

35 lines
1.0 KiB
PHP

<?php
use Illuminate\Support\Facades\Cache;
test('mobile sync returns expected envelope keys', function () {
$response = $this->getJson('/api/v1/mobile/sync');
$response->assertOk()
->assertJsonStructure(['status', 'version', 'last_updated', 'data']);
expect($response->json('status'))->toBe('success');
expect($response->json('data'))->toBeArray()->not->toBeEmpty();
});
test('mobile sync responds with ETag header', function () {
$response = $this->getJson('/api/v1/mobile/sync');
$response->assertOk();
expect($response->headers->get('ETag'))->not->toBeNull();
});
test('mobile sync returns 304 when If-None-Match matches', function () {
$etag = $this->getJson('/api/v1/mobile/sync')->headers->get('ETag');
$this->withHeaders(['If-None-Match' => $etag])
->getJson('/api/v1/mobile/sync')
->assertStatus(304);
});
test('mobile sync is cached', function () {
$this->getJson('/api/v1/mobile/sync');
expect(Cache::has('mobile_config_all'))->toBeTrue();
});