This commit is contained in:
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user