'array']); DB::shouldReceive('connection')->never(); } public function test_controller_reads_the_new_plain_data_cache_instead_of_the_legacy_metric(): void { $current = ['stats' => ['opportunities' => 1, 'provinces' => 2, 'sectors' => 1], 'sectors' => [], 'featuredOpportunities' => []]; Cache::put('portal_home_sector_organization_v1_pt', ['stats' => ['opportunities' => 99, 'provinces' => 1]]); Cache::put('portal_home_territorial_v2_pt', unserialize(serialize($current), ['allowed_classes' => false])); $response = app(HomeController::class)->show(Request::create('/api/v1/home?locale=pt')); $this->assertSame($current, $response->getData(true)['data']); } public function test_existing_model_events_invalidate_both_locales_of_the_new_cache(): void { foreach ([Opportunity::class, Sector::class] as $model) { foreach (['saved', 'deleted'] as $event) { Cache::put('portal_home_territorial_v2_pt', ['stats' => []]); Cache::put('portal_home_territorial_v2_en', ['stats' => []]); Event::dispatch('eloquent.'.$event.': '.$model, [new $model]); $this->assertNull(Cache::get('portal_home_territorial_v2_pt')); $this->assertNull(Cache::get('portal_home_territorial_v2_en')); } } } }