diff --git a/tests/Unit/MetadataResolver/NicoSeigaResolverTest.php b/tests/Unit/MetadataResolver/NicoSeigaResolverTest.php new file mode 100644 index 0000000..0c1c0bd --- /dev/null +++ b/tests/Unit/MetadataResolver/NicoSeigaResolverTest.php @@ -0,0 +1,52 @@ +shouldUseMock()) { + sleep(1); + } + } + + public function testSeiga() + { + $responseText = file_get_contents(__DIR__ . '/../../fixture/NicoSeiga/seiga.html'); + + $this->createResolver(NicoSeigaResolver::class, $responseText); + + $metadata = $this->resolver->resolve('https://seiga.nicovideo.jp/seiga/im9623750'); + $this->assertSame('シャミ子 / まとけち さんのイラスト', $metadata->title); + $this->assertSame('シャミ子が悪いんだよ・・・', $metadata->description); + $this->assertSame('https://lohas.nicoseiga.jp/thumb/9623750l?', $metadata->image); + $this->assertSame(['アニメ', 'まちカドまぞく', 'シャミ子', 'シャドウミストレス優子', '吉田優子', '危機管理フォーム', 'シャミ子が悪いんだよ', '赤面', 'シャミ子は悪くないよ'], $metadata->tags); + if ($this->shouldUseMock()) { + $this->assertSame('https://seiga.nicovideo.jp/seiga/im9623750', (string) $this->handler->getLastRequest()->getUri()); + } + } + + public function testShunga() + { + $responseText = file_get_contents(__DIR__ . '/../../fixture/NicoSeiga/shunga.html'); + + $this->createResolver(NicoSeigaResolver::class, $responseText); + + $metadata = $this->resolver->resolve('https://seiga.nicovideo.jp/seiga/im9232798'); + $this->assertSame('ベッドのゆかりさん / せゆーら/Se-U-Ra さんのイラスト', $metadata->title); + $this->assertSame('待つ側の方がつよいってスマブラが伝えてきたので', $metadata->description); + $this->assertSame('https://lohas.nicoseiga.jp/thumb/9232798l?', $metadata->image); + $this->assertSame(['結月ゆかり', 'VOICEROID', '裸パーカー', '謎の光'], $metadata->tags); + if ($this->shouldUseMock()) { + $this->assertSame('https://seiga.nicovideo.jp/seiga/im9232798', (string) $this->handler->getLastRequest()->getUri()); + } + } +} diff --git a/tests/fixture/NicoSeiga/seiga.html b/tests/fixture/NicoSeiga/seiga.html new file mode 100644 index 0000000..fd601c5 --- /dev/null +++ b/tests/fixture/NicoSeiga/seiga.html @@ -0,0 +1,88 @@ + + + + + +
+ + + + + + + + + + + + + + + ++ + + | +
+ シャミ子投稿者:まとけち さん
+ シャミ子が悪いんだよ・・・
+
+ 2019年09月07日 18:17:19 投稿
+ 登録タグ
+
+ |
+