saveScreenshot('https://duckduckgo.com'); $this->assertTrue(file_exists(public_path() . '/assets/img/bookmarks/' . $uuid . '.png')); }*/ #[Test] public function archive_link_method_calls_archive_service(): void { $mock = new MockHandler([ new Response(200, ['Content-Location' => '/web/1234/example.org']), ]); $handler = HandlerStack::create($mock); $client = new Client(['handler' => $handler]); $this->app->instance(Client::class, $client); $url = (new BookmarkService)->getArchiveLink('https://example.org'); $this->assertEquals('/web/1234/example.org', $url); } #[Test] public function archive_link_method_throws_an_exception_on_error(): void { $this->expectException(InternetArchiveException::class); $mock = new MockHandler([ new Response(403), ]); $handler = HandlerStack::create($mock); $client = new Client(['handler' => $handler]); $this->app->instance(Client::class, $client); (new BookmarkService)->getArchiveLink('https://example.org'); } #[Test] public function archive_link_method_throws_an_exception_if_no_location_returned(): void { $this->expectException(InternetArchiveException::class); $mock = new MockHandler([ new Response(200), ]); $handler = HandlerStack::create($mock); $client = new Client(['handler' => $handler]); $this->app->instance(Client::class, $client); (new BookmarkService)->getArchiveLink('https://example.org'); } }