diff options
Diffstat (limited to 'tests_integration')
| -rw-r--r-- | tests_integration/PaginationHandlerTest.php | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/tests_integration/PaginationHandlerTest.php b/tests_integration/PaginationHandlerTest.php index 4674e1e..503178c 100644 --- a/tests_integration/PaginationHandlerTest.php +++ b/tests_integration/PaginationHandlerTest.php @@ -69,7 +69,8 @@ final class PaginationHandlerTest extends ApiTestCase ]); $this->assertEquals(200, $status); - $bookid = 99998; + // Real Calibre 'data' row id from the fixture metadata.db + $bookid = 5; $this->deletePagination($bookid); $payload = '{"page":12,"cfi":"epubcfi(/6/14[]/4:123)"}'; @@ -100,7 +101,8 @@ final class PaginationHandlerTest extends ApiTestCase ]); $this->assertEquals(200, $status); - $bookid = 99997; + // Real Calibre 'data' row id from the fixture metadata.db + $bookid = 6; $this->deletePagination($bookid); // Create initial record @@ -155,7 +157,7 @@ final class PaginationHandlerTest extends ApiTestCase ]); $this->assertEquals(200, $status); - $bookid = 99996; + $bookid = 8; $this->deletePagination($bookid); [$status, $body] = $this->post($this->apiUrl, [ @@ -172,6 +174,33 @@ final class PaginationHandlerTest extends ApiTestCase $this->assertNull($record); } + public function test_storepagination_rejects_nonexistent_book(): void + { + // Login + [$status, $body] = $this->post($this->apiUrl, [ + 'op' => 'perform-login', + 'user' => 'test', + 'password' => 'test', + ]); + $this->assertEquals(200, $status); + + // Valid payload, but no such row in Calibre books/data tables + $bookid = 99990; + $this->deletePagination($bookid); + + [$status, $body] = $this->post($this->apiUrl, [ + 'op' => 'storepagination', + 'id' => $bookid, + 'payload' => '{"page":1}', + ]); + + $this->assertEquals(200, $status); + + // Verify no record was created for a book that does not exist + $record = $this->getPagination($bookid); + $this->assertNull($record); + } + // ── getpagination ──────────────────────────────────────────────────────── public function test_getpagination_returns_stored_data(): void @@ -184,7 +213,8 @@ final class PaginationHandlerTest extends ApiTestCase ]); $this->assertEquals(200, $status); - $bookid = 99995; + // Real Calibre 'data' row id from the fixture metadata.db + $bookid = 9; $this->deletePagination($bookid); $payload = '{"page":42,"cfi":"epubcfi(/6/30[]/4:789)"}'; |
