From e80acf79b7aa1db79f7e4560eaffa69155b9de81 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Sat, 8 Jun 2019 02:38:58 +0900 Subject: [PATCH] =?UTF-8?q?KomifloResolver=E3=81=AE=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MetadataResolver/KomifloResolverTest.php | 52 +++ tests/fixture/Komiflo/comic.json | 437 ++++++++++++++++++ tests/fixture/Komiflo/comicWithNoParents.json | 298 ++++++++++++ 3 files changed, 787 insertions(+) create mode 100644 tests/Unit/MetadataResolver/KomifloResolverTest.php create mode 100644 tests/fixture/Komiflo/comic.json create mode 100644 tests/fixture/Komiflo/comicWithNoParents.json diff --git a/tests/Unit/MetadataResolver/KomifloResolverTest.php b/tests/Unit/MetadataResolver/KomifloResolverTest.php new file mode 100644 index 0000000..cdb1578 --- /dev/null +++ b/tests/Unit/MetadataResolver/KomifloResolverTest.php @@ -0,0 +1,52 @@ +shouldUseMock()) { + sleep(1); + } + } + + public function testComic() + { + $responseText = file_get_contents(__DIR__.'/../../fixture/Komiflo/comic.json'); + + $this->createResolver(KomifloResolver::class, $responseText); + + $metadata = $this->resolver->resolve('https://komiflo.com/#!/comics/5490'); + $this->assertEquals('魔法少女とえっち物語', $metadata->title); + $this->assertEquals('薙派 - メガストアα 19.07', $metadata->description); + $this->assertEquals('https://t.komiflo.com/564_mobile_large_3x/contents/23a4cd530060b8607aa434f4b299b249e71a4d5c.jpg', $metadata->image); + $this->assertEquals(['薙派','お姉さん','ショタ','ファンタジー','巨乳','野外・露出','羞恥'], $metadata->tags); + if ($this->shouldUseMock()) { + $this->assertSame('https://api.komiflo.com/content/id/5490', (string) $this->handler->getLastRequest()->getUri()); + } + } + + public function testComicWithNoParents() + { + $responseText = file_get_contents(__DIR__.'/../../fixture/Komiflo/comicWithNoParents.json'); + + $this->createResolver(KomifloResolver::class, $responseText); + + $metadata = $this->resolver->resolve('https://komiflo.com/#!/comics/3414'); + $this->assertEquals('生まれなおしプログラム', $metadata->title); + $this->assertEquals('EROKI - ?', $metadata->description); + $this->assertEquals('https://t.komiflo.com/564_mobile_large_3x/contents/71cfb83640aead3cdd35e4329c4e2f427606a11d.jpg', $metadata->image); + $this->assertEquals(['EROKI','お姉さん','しつけ','オリジナル','ショートカット','逆転','巨乳'], $metadata->tags); + if ($this->shouldUseMock()) { + $this->assertSame('https://api.komiflo.com/content/id/3414', (string) $this->handler->getLastRequest()->getUri()); + } + } +} diff --git a/tests/fixture/Komiflo/comic.json b/tests/fixture/Komiflo/comic.json new file mode 100644 index 0000000..f6d5b2f --- /dev/null +++ b/tests/fixture/Komiflo/comic.json @@ -0,0 +1,437 @@ +{ + "content": { + "attributes": { + "artists": { + "meta": { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "name": "Artists" + }, + "id": 2, + "name_read": "Artists", + "new_content_count": 0, + "pages": null, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:56:11.304746387Z", + "slug": "artists", + "source": "live", + "visibility": 1 + }, + "children": [ + { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "薙派", + "name_en": "chiba", + "published": "", + "searchTerms": "ちば,チバ", + "tankoubonLabel": "", + "visibility": true + }, + "id": 1722, + "name_read": "ちば", + "new_content_count": 0, + "pages": null, + "parent_id": 2, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:56:11.303687274Z", + "slug": "chiba", + "source": "live", + "visibility": 1 + } + ] + }, + "label": { + "meta": { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "Labels", + "name_en": "", + "searchTerms": "", + "visibility": true + }, + "id": 638, + "name_read": "", + "new_content_count": 0, + "pages": null, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:56:11.304743971Z", + "slug": "label", + "source": "live", + "visibility": 1 + }, + "children": [ + { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "First double page", + "name_en": "", + "searchTerms": "", + "visibility": true + }, + "id": 659, + "name_read": "", + "new_content_count": 0, + "pages": null, + "parent_id": 638, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:56:11.30368064Z", + "slug": "label-firstdoublepage", + "source": "live", + "visibility": 1 + } + ] + }, + "tags": { + "meta": { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "name": "Tags" + }, + "id": 1, + "name_read": "Tags", + "new_content_count": 0, + "pages": null, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:56:11.304745145Z", + "slug": "tags", + "source": "live", + "visibility": 1 + }, + "children": [ + { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "お姉さん", + "name_en": "Mature sister", + "published": "", + "searchTerms": "おねえさん,年上,おねーさん,オネエサン", + "tankoubonLabel": "", + "visibility": true + }, + "id": 59, + "name_read": "おねえさん", + "new_content_count": 0, + "pages": null, + "parent_id": 1, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:56:11.303682097Z", + "slug": "oneesan", + "source": "live", + "visibility": 1 + }, + { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "ショタ", + "name_en": "Little boy", + "published": "", + "searchTerms": "しょた,ショタコン,小学生,中学生", + "tankoubonLabel": "", + "visibility": true + }, + "id": 75, + "name_read": "しょた", + "new_content_count": 0, + "pages": null, + "parent_id": 1, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:56:11.303683565Z", + "slug": "shota", + "source": "live", + "visibility": 1 + }, + { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "ファンタジー", + "name_en": "", + "published": "", + "searchTerms": "ふぁんたじー,SF,妖怪", + "tankoubonLabel": "", + "visibility": true + }, + "id": 98, + "name_read": "ふぁんたじー", + "new_content_count": 0, + "pages": null, + "parent_id": 1, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:56:11.30368434Z", + "slug": "fantasy", + "source": "live", + "visibility": 1 + }, + { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "巨乳", + "name_en": "Big breasts", + "published": "", + "searchTerms": "きょにゅう,キョニュウ,爆乳", + "tankoubonLabel": "", + "visibility": true + }, + "id": 37, + "name_read": "きょにゅう", + "new_content_count": 0, + "pages": null, + "parent_id": 1, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:56:11.303686492Z", + "slug": "kyonyu", + "source": "live", + "visibility": 1 + }, + { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "野外・露出", + "name_en": "In public", + "published": "", + "searchTerms": "やがい,ろしゅつ,露出狂,アオカン,青姦", + "tankoubonLabel": "", + "visibility": true + }, + "id": 53, + "name_read": "やがい", + "new_content_count": 0, + "pages": null, + "parent_id": 1, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:56:11.30368814Z", + "slug": "yagai", + "source": "live", + "visibility": 1 + }, + { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "羞恥", + "name_en": "Shy girl", + "published": "", + "searchTerms": "しゅうち,シュウチ,羞恥プレイ", + "tankoubonLabel": "", + "visibility": true + }, + "id": 47, + "name_read": "しゅうち", + "new_content_count": 0, + "pages": null, + "parent_id": 1, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:56:11.303688932Z", + "slug": "shuchi", + "source": "live", + "visibility": 1 + } + ] + }, + "tags-hidden": { + "meta": { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "Hidden tags", + "name_en": "", + "published": "", + "searchTerms": "", + "tankoubonLabel": "", + "visibility": true + }, + "id": 783, + "name_read": "", + "new_content_count": 0, + "pages": null, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:56:11.304741513Z", + "slug": "tags-hidden", + "source": "live", + "visibility": 1 + }, + "children": [ + { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "COMICメガストアαsearch", + "name_en": "", + "published": "", + "searchTerms": "メガストア,めがすとあ", + "tankoubonLabel": "", + "visibility": true + }, + "id": 1009, + "name_read": "", + "new_content_count": 0, + "pages": null, + "parent_id": 783, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:56:11.303678935Z", + "slug": "megastore-search", + "source": "live", + "visibility": 1 + } + ] + } + }, + "body": "", + "cdn_public": "https://cdn.komiflo.com/resized", + "cdn_thumbs": "", + "children": [], + "comments_count": 3, + "data": { + "category": "", + "censorship": "モザイク修正", + "download_type": "", + "isbn": "", + "link_amazon": "", + "link_dlsite": "", + "link_dmm": "", + "link_wani": "", + "msrp": "", + "naughty": "", + "restricted": "", + "size": "", + "title": "魔法少女とえっち物語", + "url": "" + }, + "expiry": "2020-06-20T15:00:00Z", + "id": 5490, + "imgs": null, + "key_data": "", + "key_hash": "", + "liked": false, + "likes_count": 127, + "named_imgs": { + "cover": { + "id": 79325, + "original": 81185, + "width": 4299, + "height": 6071, + "ident": "cover", + "filename": "contents/23a4cd530060b8607aa434f4b299b249e71a4d5c.jpg", + "variants": [ + "148_desktop_small", + "296_desktop_small_2x", + "198_desktop_medium", + "396_desktop_medium_2x", + "247_desktop_large", + "494_desktop_large_2x", + "160_mobile_narrow", + "320_mobile_narrow_2x", + "207_mobile_medium", + "414_mobile_medium_2x", + "188_mobile_large", + "376_mobile_large_2x", + "564_mobile_large_3x", + "346_mobile" + ] + } + }, + "page_count": 0, + "parents": [ + { + "body": "", + "cdn_public": "", + "cdn_thumbs": "", + "data": { + "category": "", + "download_type": "", + "isbn": "", + "link_amazon": "", + "link_dlsite": "", + "link_dmm": "", + "link_wani": "", + "msrp": "780", + "release_date": "", + "size": "", + "title": "メガストアα 19.07", + "url": "" + }, + "expiry": "2020-06-20T15:00:00Z", + "id": 5474, + "likes_count": 0, + "page_count": null, + "premium": false, + "public": false, + "published": "2019-06-20T15:00:00Z", + "reading_lists": null, + "signature": "", + "signature_expires": "2019-06-27T02:56:11Z", + "slug": null, + "source": "cache", + "type": "volume" + } + ], + "premium": false, + "public": true, + "published": "2019-06-20T15:00:00Z", + "reading_lists": [], + "signature": "?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9jZG4ua29taWZsby5jb20vKi9jb250ZW50cy8qIiwiQ29uZGl0aW9uIjp7IklwQWRkcmVzcyI6eyJBV1M6U291cmNlSXAiOiIzOS4xMTEuMjE4LjE2MC8zMiJ9LCJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTU2MTYwNDE3MX19fV19&Signature=ilu4WlHoMMecmk8Ab3UuJ3LBTe~FhQxoGVdPbBF9CTrTB-Teockvf43MgWuAzWgsfFrwmCeV-hedV-iEx07B3S~D7ObXWCFcbPd1rb12D0qY~NF2SfGTv8lIbCDMQkc9wyUtE5K4MlZ35Bm4mZRv9HtEZkX1yjkVuAV7sBScBfJUkfnlg6yYsL2d2g4tDkN8gCOjZChUODetZPm05qwTmItIbq0kQhirgXNV~R1z~kFRwsgoBYClCq3vpQCsCy7tbKGmzHz6ku-PgpopqsOCmAaCl9Jh4D2pw8R64aREw6SX4tSoe7NPKG4KbtLzBsio260luuORDeaFcTjvlQI0~g__&Key-Pair-Id=APKAIILYVN5NFPDL7WIA", + "signature_expires": "2019-06-27T02:56:11Z", + "slug": null, + "source": "live", + "type": "chapter" + }, + "success": true +} diff --git a/tests/fixture/Komiflo/comicWithNoParents.json b/tests/fixture/Komiflo/comicWithNoParents.json new file mode 100644 index 0000000..789b320 --- /dev/null +++ b/tests/fixture/Komiflo/comicWithNoParents.json @@ -0,0 +1,298 @@ +{ + "content": { + "attributes": { + "artists": { + "meta": { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "name": "Artists" + }, + "id": 2, + "name_read": "Artists", + "new_content_count": 0, + "pages": null, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:50:55.176026561Z", + "slug": "artists", + "source": "live", + "visibility": 1 + }, + "children": [ + { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "EROKI", + "name_en": "eroki", + "published": "", + "searchTerms": "えろき,エロキ", + "tankoubonLabel": "", + "visibility": true + }, + "id": 836, + "name_read": "えろき", + "new_content_count": 0, + "pages": null, + "parent_id": 2, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:50:55.174698472Z", + "slug": "eroki", + "source": "live", + "visibility": 1 + } + ] + }, + "tags": { + "meta": { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "name": "Tags" + }, + "id": 1, + "name_read": "Tags", + "new_content_count": 0, + "pages": null, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:50:55.176028723Z", + "slug": "tags", + "source": "live", + "visibility": 1 + }, + "children": [ + { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "お姉さん", + "name_en": "Mature sister", + "published": "", + "searchTerms": "おねえさん,年上,おねーさん,オネエサン", + "tankoubonLabel": "", + "visibility": true + }, + "id": 59, + "name_read": "おねえさん", + "new_content_count": 0, + "pages": null, + "parent_id": 1, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:50:55.174699935Z", + "slug": "oneesan", + "source": "live", + "visibility": 1 + }, + { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "しつけ", + "name_en": "Discipline", + "published": "", + "searchTerms": "しつけ,躾,シツケ", + "tankoubonLabel": "", + "visibility": true + }, + "id": 69, + "name_read": "しつけ", + "new_content_count": 0, + "pages": null, + "parent_id": 1, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:50:55.174701095Z", + "slug": "shitsuke", + "source": "live", + "visibility": 1 + }, + { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "オリジナル", + "name_en": "", + "published": "", + "searchTerms": "おりじなる,オリジナル", + "tankoubonLabel": "", + "visibility": true + }, + "id": 534, + "name_read": "おりじなる", + "new_content_count": 0, + "pages": null, + "parent_id": 1, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:50:55.174702761Z", + "slug": "original", + "source": "live", + "visibility": 1 + }, + { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "ショートカット", + "name_en": "", + "published": "", + "searchTerms": "ショートヘアー,ショート,しょーと,しょーとへあ", + "tankoubonLabel": "", + "visibility": true + }, + "id": 798, + "name_read": "しょーとかっと", + "new_content_count": 0, + "pages": null, + "parent_id": 1, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:50:55.174703509Z", + "slug": "shorthair", + "source": "live", + "visibility": 1 + }, + { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "逆転", + "name_en": "", + "published": "", + "searchTerms": "ぎゃくてん,女性優位,ギャクテン", + "tankoubonLabel": "", + "visibility": true + }, + "id": 74, + "name_read": "ぎゃくてん", + "new_content_count": 0, + "pages": null, + "parent_id": 1, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:50:55.174705548Z", + "slug": "gyakuten", + "source": "live", + "visibility": 1 + }, + { + "cdn_public": "", + "cdn_thumbs": "", + "content_count": 0, + "data": { + "href": "", + "ipRestrict": "", + "name": "巨乳", + "name_en": "Big breasts", + "published": "", + "searchTerms": "きょにゅう,キョニュウ,爆乳", + "tankoubonLabel": "", + "visibility": true + }, + "id": 37, + "name_read": "きょにゅう", + "new_content_count": 0, + "pages": null, + "parent_id": 1, + "published": null, + "signature": "", + "signature_expires": "2019-06-26T14:50:55.174706294Z", + "slug": "kyonyu", + "source": "live", + "visibility": 1 + } + ] + } + }, + "body": "", + "cdn_public": "https://cdn.komiflo.com/resized", + "cdn_thumbs": "", + "children": [], + "comments_count": 26, + "data": { + "category": "", + "censorship": "黒棒による修正", + "download_type": "", + "isbn": "", + "link_amazon": "", + "link_dlsite": "", + "link_dmm": "", + "link_wani": "", + "msrp": "", + "naughty": "", + "restricted": "", + "size": "", + "title": "生まれなおしプログラム", + "url": "" + }, + "expiry": null, + "id": 3414, + "imgs": null, + "key_data": "", + "key_hash": "", + "liked": false, + "likes_count": 627, + "named_imgs": { + "cover": { + "id": 49645, + "original": 50622, + "width": 4299, + "height": 6071, + "ident": "cover", + "filename": "contents/71cfb83640aead3cdd35e4329c4e2f427606a11d.jpg", + "variants": [ + "148_desktop_small", + "296_desktop_small_2x", + "198_desktop_medium", + "396_desktop_medium_2x", + "247_desktop_large", + "494_desktop_large_2x", + "160_mobile_narrow", + "320_mobile_narrow_2x", + "207_mobile_medium", + "414_mobile_medium_2x", + "188_mobile_large", + "376_mobile_large_2x", + "564_mobile_large_3x", + "346_mobile" + ] + } + }, + "page_count": 0, + "parents": [], + "premium": false, + "public": true, + "published": "2018-04-10T15:00:00Z", + "reading_lists": [], + "signature": "?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9jZG4ua29taWZsby5jb20vKi9jb250ZW50cy8qIiwiQ29uZGl0aW9uIjp7IklwQWRkcmVzcyI6eyJBV1M6U291cmNlSXAiOiIzOS4xMTEuMjE4LjE2MC8zMiJ9LCJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTU2MTYwMzg1NX19fV19&Signature=bZFuvU1rgv2iBSSFlxyoexOIjjacWW4Sxe--EEjI2ruQPNnZE8iU542yCsWBSrmHfFOXFcYNKIf3PmTAxwjS-CeoyRc~O0VO6T9bNdlinFICMezNTPlYe0Ri~nUWxQ8Oy364ik5zrd5RwHmEOVMjfuc96N6ivrcL9Q5tfi-2sFs~8S9m-IH76Kf7dLXn8~TRPfGFj8bfyoDcn42YfCvfXzl4D92EnKjQO52x2~KICQR3X7igirQ6X1GmuYEoJd9GAYZlKNKUEQch7T6dpR-uJZEJ5hOJDsWrIJkvoMu9ZTBgdZOZGuNLfWunAJ0NhovNlN6-D8PmlhSd79Mu0P2LUA__&Key-Pair-Id=APKAIILYVN5NFPDL7WIA", + "signature_expires": "2019-06-27T02:50:55Z", + "slug": null, + "source": "live", + "type": "chapter" + }, + "success": true +}