add notes/remark and refactor round-trip
PHP Tests / php-tests (push) Has been cancelled

This commit is contained in:
Nyan Lin Paing
2026-08-22 21:43:41 +07:00
parent 894352b43f
commit fa908cdcaf
46 changed files with 1679 additions and 182 deletions
@@ -41,42 +41,42 @@ test('saving an ev route invalidates the routes cache tag', function () {
$route = EvRoute::factory()->create(['is_active' => true]);
$this->withHeader('Authorization', "Bearer {$this->token}")
->getJson('/api/v1/routes')
->assertJsonCount(1, 'data');
->postJson('/api/v1/routes/search')
->assertJsonCount(1, 'routes.data');
// Bypass Eloquent so the change wouldn't be visible without invalidation.
EvRoute::query()->where('id', $route->id)->update(['is_active' => false]);
$this->withHeader('Authorization', "Bearer {$this->token}")
->getJson('/api/v1/routes')
->assertJsonCount(1, 'data');
->postJson('/api/v1/routes/search')
->assertJsonCount(1, 'routes.data');
$route->refresh()->save();
$this->withHeader('Authorization', "Bearer {$this->token}")
->getJson('/api/v1/routes')
->assertJsonCount(0, 'data');
->postJson('/api/v1/routes/search')
->assertJsonCount(0, 'routes.data');
});
test('deleting an ev route invalidates the routes cache tag', function () {
$route = EvRoute::factory()->create(['is_active' => true]);
$this->withHeader('Authorization', "Bearer {$this->token}")
->getJson('/api/v1/routes')
->assertJsonCount(1, 'data');
->postJson('/api/v1/routes/search')
->assertJsonCount(1, 'routes.data');
$route->delete();
$this->withHeader('Authorization', "Bearer {$this->token}")
->getJson('/api/v1/routes')
->assertJsonCount(0, 'data');
->postJson('/api/v1/routes/search')
->assertJsonCount(0, 'routes.data');
});
test('flushing the routes cache tag does not affect other cached data', function () {
Cache::put('unrelated-key', 'still here', now()->addMinutes(5));
$route = EvRoute::factory()->create(['is_active' => true]);
$route->update(['is_round_trip' => true]);
$route->update(['is_active' => false]);
expect(Cache::get('unrelated-key'))->toBe('still here');
});