Skip to content

v3.0.03 #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ vendor
CHANGELOG-draft.md
node_modules
.phpunit.cache
docker-compose.yml
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kiwilan/php-ebook",
"description": "PHP package to read metadata and extract covers from eBooks, comics and audiobooks.",
"version": "3.0.02",
"version": "3.0.03",
"keywords": [
"php",
"ebook",
Expand Down Expand Up @@ -39,7 +39,7 @@
],
"require": {
"php": "^8.1",
"kiwilan/php-archive": "^2.2.0",
"kiwilan/php-archive": "^2.3.01",
"kiwilan/php-xml-reader": "^1.1.0"
},
"require-dev": {
Expand Down
64 changes: 32 additions & 32 deletions tests/BookIdentifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use Kiwilan\Ebook\Models\BookIdentifier;

it('can use BookIdentifier', function (string $value, string $scheme) {
it('can use book identifier', function (string $value, string $scheme) {
$item = new BookIdentifier($value, $scheme);

expect($item->getValue())->toBe($value);
Expand All @@ -17,24 +17,24 @@
}
})->with([
[
'content' => 'a2cf2f25-4de2-4f77-82cc-0198352b0851',
'type' => 'uuid',
'a2cf2f25-4de2-4f77-82cc-0198352b0851',
'uuid',
],
[
'content' => 'a2cf2f25-4de2-4f77-82cc-0198352b0851',
'type' => 'uuid',
'a2cf2f25-4de2-4f77-82cc-0198352b0851',
'uuid',
],
[
'content' => '63CTHAAACAAJ',
'type' => 'google',
'63CTHAAACAAJ',
'google',
],
[
'content' => '2744155349',
'type' => 'isbn10',
'2744155349',
'isbn10',
],
[
'content' => '9782266122122',
'type' => 'isbn13',
'9782266122122',
'isbn13',
],
]);

Expand All @@ -45,51 +45,51 @@
expect($item->getScheme())->toBe($scheme);
})->with([
[
'scheme' => 'isbn13',
'value' => '9788075836663',
'isbn13',
'9788075836663',
],
[
'scheme' => 'qvn2sejbqufrqkfk',
'value' => 'ASvHBAAAQBAJ',
'qvn2sejbqufrqkfk',
'ASvHBAAAQBAJ',
],
[
'scheme' => 'uuid',
'value' => 'urn:uuid:10225bf5-b0ec-43e7-910a-e0e208623cd9',
'uuid',
'urn:uuid:10225bf5-b0ec-43e7-910a-e0e208623cd9',
],
[
'scheme' => 'uuid',
'value' => '10225bf5-b0ec-43e7-910a-e0e208623cd9',
'uuid',
'10225bf5-b0ec-43e7-910a-e0e208623cd9',
],
[
'scheme' => 'custom',
'value' => 'custom:customkey',
'custom',
'custom:customkey',
],
[
'scheme' => 'doi',
'value' => '10.1002/9781118257517',
'doi',
'10.1002/9781118257517',
],
[
'scheme' => 'y3vzdg9ta2v5',
'value' => 'customkey',
'y3vzdg9ta2v5',
'customkey',
],
]);

it('can use without autoDetect', function (?string $scheme, ?string $value) {
it('can use without auto detect', function (?string $scheme, ?string $value) {
$item = new BookIdentifier($value, $scheme, autoDetect: false);

expect($item->getValue())->toBe($value);
expect($item->getScheme())->toBe($scheme);
})->with([
[
'scheme' => 'isbn13',
'value' => '9788075836663',
'isbn13',
'9788075836663',
],
[
'scheme' => null,
'value' => 'ASvHBAAAQBAJ',
null,
'ASvHBAAAQBAJ',
],
[
'scheme' => 'custom',
'value' => null,
'custom',
null,
],
]);
46 changes: 23 additions & 23 deletions tests/EntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Kiwilan\Ebook\Models\BookIdentifier;
use Kiwilan\Ebook\Models\BookMeta;

it('can use EbookEntity', function () {
it('can use ebook entity', function () {
$ebook = Ebook::read(EPUB);
$ebook->setTitle('title');
$ebook->setAuthors([
Expand Down Expand Up @@ -60,7 +60,7 @@
expect($ebook->__toString())->toBeString();
});

it('can use BookContributor', function (string $content, string $role) {
it('can use book contributor', function (string $content, string $role) {
$item = new BookContributor($content, $role);

expect($item->getContents())->toBe($content);
Expand All @@ -72,16 +72,16 @@
expect($item->__toString())->toBe($content);
})->with([
[
'contents' => 'calibre',
'role' => 'bkp',
'calibre',
'bkp',
],
[
'contents' => 'epbu2',
'role' => 'bkp',
'epbu2',
'bkp',
],
]);

it('can use BookAuthor', function (string $name, string $role) {
it('can use book author', function (string $name, string $role) {
$item = new BookAuthor($name, $role);

expect($item->getName())->toBe($name);
Expand All @@ -93,16 +93,16 @@
expect($item->__toString())->toBe($name);
})->with([
[
'contents' => 'Jean M. Auel',
'role' => 'aut',
'Jean M. Auel',
'aut',
],
[
'contents' => 'Terry Pratchett',
'role' => 'aut',
'Terry Pratchett',
'aut',
],
]);

it('can use BookMeta', function (string $name, string $contents) {
it('can use book meta', function (string $name, string $contents) {
$item = new BookMeta($name, $contents);

expect($item->getName())->toBe($name);
Expand All @@ -114,28 +114,28 @@
expect($item->__toString())->toBe("{$name} {$contents}");
})->with([
[
'name' => 'calibre:title_sort',
'contents' => "clan de l'ours des cavernes, Le",
'calibre:title_sort',
"clan de l'ours des cavernes, Le",
],
[
'name' => 'calibre:series',
'contents' => 'Les Enfants de la Terre',
'calibre:series',
'Les Enfants de la Terre',
],
[
'name' => 'calibre:series_index',
'contents' => '1.0',
'calibre:series_index',
'1.0',
],
[
'name' => 'calibre:timestamp',
'contents' => '2023-03-25T10:32:21+00:00',
'calibre:timestamp',
'2023-03-25T10:32:21+00:00',
],
[
'name' => 'calibre:rating',
'contents' => '10.0',
'calibre:rating',
'10.0',
],
]);

it('can parse with BookMeta', function (mixed $data) {
it('can parse with book meta', function (mixed $data) {
$meta = BookMeta::parse($data);

expect($meta)->toBeString();
Expand Down
2 changes: 1 addition & 1 deletion tests/PdfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
expect(file_exists($path))->toBeTrue();
expect($path)->toBeReadableFile();
expect(fileIsValidImg($path))->toBeTrue();
})->skip(PHP_OS_FAMILY === 'Windows' || PHP_VERSION >= '8.3', 'Skip on Windows or PHP >= 8.3');
})->skip(PHP_OS_FAMILY === 'Windows', 'Skip on Windows or PHP >= 8.3');

it('can parse empty pdf', function () {
$ebook = Ebook::read(PDF_EMPTY);
Expand Down
Loading