create(['portal' => $portal]); $category->translations()->create([ 'locale' => 'de', 'name' => $name, 'slug' => $slug, 'description' => 'Testbeschreibung für '.$name.'.', ]); return $category; } test('businessportal24 category page renders the editorial shell with real data', function () { /** @var TestCase $this */ $category = makeCategory(Portal::Both, 'Energie & Klima', 'energie-klima'); $company = Company::factory()->businessportal24()->create([ 'name' => 'Nordwind Energie AG', ]); foreach (range(0, 3) as $i) { PressRelease::factory() ->published() ->forPortal(Portal::Businessportal24) ->for($category) ->for($company) ->create([ 'title' => "Energie Branchenmeldung {$i}", 'slug' => "energie-branchenmeldung-{$i}", 'hits' => 100 * ($i + 1), 'published_at' => now()->subDays($i + 1), ]); } $this->get('https://businessportal24.test/de/category/energie-klima') ->assertSuccessful() ->assertSeeText('Energie & Klima') ->assertSeeText('Aktuelle Meldungen') ->assertSeeText('Energie Branchenmeldung 0') ->assertSeeText('Nordwind Energie AG') ->assertSeeText('Meistgelesen'); }); test('category page returns 404 for unknown and inactive categories', function () { /** @var TestCase $this */ $this->get('https://businessportal24.test/de/category/gibt-es-nicht')->assertNotFound(); $inactive = Category::factory()->create(['portal' => Portal::Both, 'is_active' => false]); $inactive->translations()->create(['locale' => 'de', 'name' => 'Versteckt', 'slug' => 'versteckt']); $this->get('https://businessportal24.test/de/category/versteckt')->assertNotFound(); }); test('category page does not expose categories from another portal', function () { /** @var TestCase $this */ $category = makeCategory(Portal::Presseecho, 'Nur Presseecho', 'nur-presseecho'); PressRelease::factory() ->published() ->forPortal(Portal::Presseecho) ->for($category) ->for(Company::factory()->presseecho()) ->create(['slug' => 'pe-branchenmeldung', 'published_at' => now()->subDay()]); $this->get('https://businessportal24.test/de/category/nur-presseecho')->assertNotFound(); $this->get('https://presseecho.test/de/category/nur-presseecho') ->assertSuccessful() ->assertSeeText('Nur Presseecho'); });