Add support for ISBNDB API queries

This commit is contained in:
DariusIII
2026-04-14 14:51:20 +02:00
parent b7fdf3dafd
commit 43773a0cda
7 changed files with 448 additions and 24 deletions
@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace Tests\Integration;
use App\Services\IsbnDbService;
use Tests\TestCase;
class IsbnDbServiceIntegrationTest extends TestCase
{
public function test_search_book_with_live_isbndb_api(): void
{
$service = new IsbnDbService;
if (! $service->isConfigured()) {
$this->markTestSkipped('ISBNDB_API_KEY is not configured.');
}
$book = $service->searchBook('The Hobbit J. R. R. Tolkien');
$this->assertNotNull($book, 'ISBNdb search should return a known book.');
$this->assertNotSame('', $book['title']);
$this->assertArrayHasKey('author', $book);
$this->assertArrayHasKey('isbn', $book);
}
public function test_find_by_isbn_with_live_isbndb_api(): void
{
$service = new IsbnDbService;
if (! $service->isConfigured()) {
$this->markTestSkipped('ISBNDB_API_KEY is not configured.');
}
$book = $service->findByIsbn('9780140328721');
$this->assertNotNull($book, 'ISBNdb ISBN lookup should return a known book.');
$this->assertNotSame('', $book['title']);
$this->assertSame('9780140328721', $book['isbn']);
}
}