bootApp(); // The first /app/* request in a fresh process triggers // session_start() and clobbers the $_SESSION values primed // here. Hit a public route first so the session is active // before any test request fires. $this->request('GET', '/healthz'); $_SESSION['_user'] = (new UserContext(1, 'Admin', 'admin', null, UserContext::SOURCE_LOCAL))->toArray(); $_SESSION['_last_active'] = time(); $_SESSION['_authenticated_at'] = time(); } public function testListPageRendersResults(): void { $this->enqueueApiResponse(200, [ 'page' => 1, 'page_size' => 25, 'total' => 2, 'items' => [ [ 'ip' => '203.0.113.10', 'is_ipv4' => true, 'max_score' => 1.5, 'top_category' => 'brute_force', 'pair_count' => 1, 'last_report_at' => '2026-04-29T10:00:00Z', 'status' => 'scored', 'enrichment' => null, ], [ 'ip' => '2001:db8::1', 'is_ipv4' => false, 'max_score' => 0.8, 'top_category' => 'spam', 'pair_count' => 1, 'last_report_at' => '2026-04-29T09:55:00Z', 'status' => 'scored', 'enrichment' => null, ], ], ]); // listCountries() — issued after searchIps() by the controller. $this->enqueueApiResponse(200, ['items' => []]); $response = $this->request('GET', '/app/ips'); self::assertSame(200, $response->getStatusCode()); $body = (string) $response->getBody(); self::assertStringContainsString('203.0.113.10', $body); self::assertStringContainsString('2001:db8::1', $body); self::assertStringContainsString('brute_force', $body); self::assertStringContainsString('2 total', $body); } public function testListPageRendersEmptyState(): void { $this->enqueueApiResponse(200, [ 'page' => 1, 'page_size' => 25, 'total' => 0, 'items' => [], ]); $this->enqueueApiResponse(200, ['items' => []]); $response = $this->request('GET', '/app/ips'); self::assertSame(200, $response->getStatusCode()); self::assertStringContainsString('No results', (string) $response->getBody()); } public function testListPagePassesFiltersThrough(): void { $this->enqueueApiResponse(200, ['page' => 1, 'page_size' => 25, 'total' => 0, 'items' => []]); $this->enqueueApiResponse(200, ['items' => []]); $response = $this->request('GET', '/app/ips?q=2001&category=spam'); $body = (string) $response->getBody(); self::assertSame(200, $response->getStatusCode()); // The filter form preserves the user's selection. self::assertMatchesRegularExpression('/value="2001"/', $body); self::assertMatchesRegularExpression('/