From 7eeb0207deb5dfe8bee6c3b8cd88d605d34a3614 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Wed, 16 Jan 2019 21:31:52 +0900 Subject: [PATCH] =?UTF-8?q?DLsiteResolver=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/DLsiteResolverTest.php | 50 +++++++++++++++++++ tests/fixture/DLsite/testProduct.html | 44 ++++++++++++++++ tests/fixture/DLsite/testProductSP.html | 40 +++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 tests/Unit/MetadataResolver/DLsiteResolverTest.php create mode 100644 tests/fixture/DLsite/testProduct.html create mode 100644 tests/fixture/DLsite/testProductSP.html diff --git a/tests/Unit/MetadataResolver/DLsiteResolverTest.php b/tests/Unit/MetadataResolver/DLsiteResolverTest.php new file mode 100644 index 0000000..066bfec --- /dev/null +++ b/tests/Unit/MetadataResolver/DLsiteResolverTest.php @@ -0,0 +1,50 @@ +shouldUseMock()) { + sleep(1); + } + } + + public function testProduct() + { + $responseText = file_get_contents(__DIR__.'/../../fixture/DLsite/testProduct.html'); + + $this->createResolver(DLsiteResolver::class, $responseText); + + $metadata = $this->resolver->resolve('https://www.dlsite.com/maniax/work/=/product_id/RJ171695.html'); + $this->assertEquals('【骨伝導風】道草屋 たびらこ-一緒にはみがき【耳かき&はみがき】 [桃色CODE] | DLsite', $metadata->title); + $this->assertStringStartsWith('少しお母さんっぽい店員さんに、歯磨きからおやすみまでお世話されます。はみがきで興奮しちゃった旦那様のも、しっかりお世話してくれます。歯磨き音は特殊なマイクを使用、骨伝導風ハイレゾバイノーラル音声です。', $metadata->description); + $this->assertEquals('https://img.dlsite.jp/modpub/images2/work/doujin/RJ172000/RJ171695_img_main.jpg', $metadata->image); + if ($this->shouldUseMock()) { + $this->assertSame('https://www.dlsite.com/maniax/work/=/product_id/RJ171695.html', (string) $this->handler->getLastRequest()->getUri()); + } + } + + public function testProductSP() + { + $responseText = file_get_contents(__DIR__.'/../../fixture/DLsite/testProductSP.html'); + + $this->createResolver(DLsiteResolver::class, $responseText); + + $metadata = $this->resolver->resolve('https://www.dlsite.com/home/work/=/product_id/RJ234446.html'); + $this->assertEquals('【大人向け耳かき】道草屋 はこべら5 時計修理のはこべらさん。他【汗の匂い】 [桃色CODE] | DLsite', $metadata->title); + $this->assertStringStartsWith('夏の終わり、二人で遠くの花火を眺めます。耳かきの他、クラシックシェービング、氷を含んだあまがみ、冷紅茶、ジャズ、時計の修理、それから大人向けの汗の匂い。色々な事のある、二泊三日の田舎宿音声です。', $metadata->description); + $this->assertEquals('https://img.dlsite.jp/modpub/images2/work/doujin/RJ235000/RJ234446_img_main.jpg', $metadata->image); + if ($this->shouldUseMock()) { + $this->assertSame('https://www.dlsite.com/home/work/=/product_id/RJ234446.html', (string) $this->handler->getLastRequest()->getUri()); + } + } +} diff --git a/tests/fixture/DLsite/testProduct.html b/tests/fixture/DLsite/testProduct.html new file mode 100644 index 0000000..c1202bd --- /dev/null +++ b/tests/fixture/DLsite/testProduct.html @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + 【骨伝導風】道草屋 たびらこ-一緒にはみがき【耳かき&はみがき】 [桃色CODE] | DLsite 同人 - R18 + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/fixture/DLsite/testProductSP.html b/tests/fixture/DLsite/testProductSP.html new file mode 100644 index 0000000..ff075a0 --- /dev/null +++ b/tests/fixture/DLsite/testProductSP.html @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + 【大人向け耳かき】道草屋 はこべら5 時計修理のはこべらさん。他【汗の匂い】 [桃色CODE] | DLsite 同人 - R18 + + + + + + + + + + + + + + + \ No newline at end of file