create(); $this->actingAs($user); return $user; } public function test_requires_authentication(): void { $response = $this->getJson('/admin/movies/search?q=test'); // For JSON requests, Laravel returns 401 when unauthenticated $response->assertStatus(401); } public function test_returns_provider_results(): void { $this->authenticate(); // Bind a stub provider $this->app->bind(MovieProvider::class, function () { return new class implements MovieProvider { public function search(string $query, int $page = 1): array { return [ 'results' => collect([ [ 'provider' => 'stub', 'provider_id' => 'tt0001', 'title' => 'Stub Movie', 'year' => '2024', 'poster_url' => null, ], ]), 'total' => 1, 'page' => $page, 'has_more' => false, ]; } public function details(string $id): array { return []; } }; }); $response = $this->getJson('/admin/movies/search?q=stub'); $response->assertOk() ->assertJson([ 'total' => 1, 'page' => 1, 'has_more' => false, ]) ->assertJsonPath('results.0.title', 'Stub Movie'); } }