2018-04-15 21:46:49 +09:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Tests\Unit\MetadataResolver;
|
|
|
|
|
|
|
|
|
|
use App\MetadataResolver\NijieResolver;
|
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
|
|
class NijieResolverTest extends TestCase
|
|
|
|
|
{
|
2019-02-17 03:19:27 +09:00
|
|
|
|
use CreateMockedResolver;
|
|
|
|
|
|
2020-05-23 22:17:07 +09:00
|
|
|
|
public function setUp(): void
|
2019-02-17 03:19:27 +09:00
|
|
|
|
{
|
|
|
|
|
parent::setUp();
|
2019-02-18 17:33:52 +09:00
|
|
|
|
|
|
|
|
|
if (!$this->shouldUseMock()) {
|
|
|
|
|
sleep(1);
|
|
|
|
|
}
|
2019-02-17 03:19:27 +09:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-15 21:46:49 +09:00
|
|
|
|
public function testStandardPicture()
|
|
|
|
|
{
|
2020-08-22 13:58:03 +09:00
|
|
|
|
$responseText = $this->fetchSnapshot(__DIR__ . '/../../fixture/Nijie/testStandardPictureResponse.html');
|
2018-04-15 21:46:49 +09:00
|
|
|
|
|
2019-02-17 03:19:27 +09:00
|
|
|
|
$this->createResolver(NijieResolver::class, $responseText);
|
|
|
|
|
|
|
|
|
|
$metadata = $this->resolver->resolve('https://nijie.info/view.php?id=66384');
|
2019-08-21 03:40:47 +09:00
|
|
|
|
$this->assertSame('チンポップくんの日常ep.1「チンポップくんと釣り」', $metadata->title);
|
|
|
|
|
$this->assertSame('投稿者: ニジエ運営' . PHP_EOL . 'メールマガジン漫画のバックナンバー第一話です!' . PHP_EOL . '最新話はメールマガジンより配信中です。', $metadata->description);
|
|
|
|
|
$this->assertSame('https://pic.nijie.net/04/nijie_picture/38_20131130155623.png', $metadata->image);
|
|
|
|
|
$this->assertSame(['ニジエたん', '釣り', 'チンポップ君の日常', '公式漫画'], $metadata->tags);
|
2019-02-17 03:19:27 +09:00
|
|
|
|
if ($this->shouldUseMock()) {
|
2019-07-02 12:44:25 +09:00
|
|
|
|
$this->assertSame('https://nijie.info/view.php?id=66384', (string) $this->handler->getLastRequest()->getUri());
|
2019-02-17 03:19:27 +09:00
|
|
|
|
}
|
2018-04-15 21:46:49 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testMultiplePicture()
|
|
|
|
|
{
|
2020-08-22 13:58:03 +09:00
|
|
|
|
$responseText = $this->fetchSnapshot(__DIR__ . '/../../fixture/Nijie/testMultiplePictureResponse.html');
|
2019-02-17 03:19:27 +09:00
|
|
|
|
|
|
|
|
|
$this->createResolver(NijieResolver::class, $responseText);
|
2018-04-15 21:46:49 +09:00
|
|
|
|
|
2019-02-17 03:19:27 +09:00
|
|
|
|
$metadata = $this->resolver->resolve('https://nijie.info/view.php?id=202707');
|
2019-08-21 03:40:47 +09:00
|
|
|
|
$this->assertSame('ニジエ壁紙', $metadata->title);
|
|
|
|
|
$this->assertSame('投稿者: ニジエ運営' . PHP_EOL . 'ニジエのPCとiphone用(4.7inch推奨)の壁紙です。' . PHP_EOL . '保存してご自由にお使いくださいませ。', $metadata->description);
|
|
|
|
|
$this->assertSame('https://pic.nijie.net/03/nijie_picture/38_20170209185801_0.png', $metadata->image);
|
|
|
|
|
$this->assertSame(['ニジエたん', '壁紙'], $metadata->tags);
|
2019-02-17 03:19:27 +09:00
|
|
|
|
if ($this->shouldUseMock()) {
|
2019-07-02 12:44:25 +09:00
|
|
|
|
$this->assertSame('https://nijie.info/view.php?id=202707', (string) $this->handler->getLastRequest()->getUri());
|
2019-02-17 03:19:27 +09:00
|
|
|
|
}
|
2018-04-15 21:46:49 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testAnimationGif()
|
|
|
|
|
{
|
2020-08-22 13:58:03 +09:00
|
|
|
|
$responseText = $this->fetchSnapshot(__DIR__ . '/../../fixture/Nijie/testAnimationGifResponse.html');
|
2019-02-17 03:19:27 +09:00
|
|
|
|
|
|
|
|
|
$this->createResolver(NijieResolver::class, $responseText);
|
2018-04-15 21:46:49 +09:00
|
|
|
|
|
2019-02-17 03:19:27 +09:00
|
|
|
|
$metadata = $this->resolver->resolve('https://nijie.info/view.php?id=9537');
|
2019-08-21 03:40:47 +09:00
|
|
|
|
$this->assertSame('ニジエがgifに対応したんだってね 奥さん', $metadata->title);
|
|
|
|
|
$this->assertSame('投稿者: 黒末アプコ' . PHP_EOL . 'アニメgifとか専門外なのでよくわかりませんでした', $metadata->description);
|
|
|
|
|
$this->assertStringStartsWith('https://nijie.info/pic/logo/nijie_logo_og.png', $metadata->image);
|
|
|
|
|
$this->assertSame(['おっぱい', '陥没乳首', '眼鏡', 'GIFアニメ', 'ぶるんぶるん', 'アニメgif'], $metadata->tags);
|
2019-02-17 03:19:27 +09:00
|
|
|
|
if ($this->shouldUseMock()) {
|
2019-07-02 12:44:25 +09:00
|
|
|
|
$this->assertSame('https://nijie.info/view.php?id=9537', (string) $this->handler->getLastRequest()->getUri());
|
2019-02-17 03:19:27 +09:00
|
|
|
|
}
|
2018-04-15 21:46:49 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testMp4Movie()
|
|
|
|
|
{
|
2020-08-22 13:58:03 +09:00
|
|
|
|
$responseText = $this->fetchSnapshot(__DIR__ . '/../../fixture/Nijie/testMp4MovieResponse.html');
|
2018-04-15 21:46:49 +09:00
|
|
|
|
|
2019-02-17 03:19:27 +09:00
|
|
|
|
$this->createResolver(NijieResolver::class, $responseText);
|
|
|
|
|
|
|
|
|
|
$metadata = $this->resolver->resolve('https://nijie.info/view.php?id=256283');
|
2019-08-21 03:53:32 +09:00
|
|
|
|
$this->assertSame('てすと', $metadata->title);
|
|
|
|
|
$this->assertSame('投稿者: ニジエ運営' . PHP_EOL . 'H264動画てすと あとで消します' . PHP_EOL . PHP_EOL . '今の所、H264コーデックのみ、出力時に音声なしにしないと投稿できません' . PHP_EOL . '動画は勝手にループします', $metadata->description);
|
2019-08-21 03:40:47 +09:00
|
|
|
|
$this->assertStringStartsWith('https://nijie.info/pic/logo/nijie_logo_og.png', $metadata->image);
|
|
|
|
|
$this->assertSame([], $metadata->tags);
|
2019-02-17 03:19:27 +09:00
|
|
|
|
if ($this->shouldUseMock()) {
|
2019-07-02 12:44:25 +09:00
|
|
|
|
$this->assertSame('https://nijie.info/view.php?id=256283', (string) $this->handler->getLastRequest()->getUri());
|
2019-02-17 03:19:27 +09:00
|
|
|
|
}
|
2018-04-15 21:46:49 +09:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-21 03:40:47 +09:00
|
|
|
|
public function testViewPopup()
|
2018-04-15 21:46:49 +09:00
|
|
|
|
{
|
2020-08-22 13:58:03 +09:00
|
|
|
|
$responseText = $this->fetchSnapshot(__DIR__ . '/../../fixture/Nijie/testStandardPictureResponse.html');
|
2019-02-17 03:19:27 +09:00
|
|
|
|
|
|
|
|
|
$this->createResolver(NijieResolver::class, $responseText);
|
2018-04-15 21:46:49 +09:00
|
|
|
|
|
2019-08-21 03:40:47 +09:00
|
|
|
|
$metadata = $this->resolver->resolve('https://nijie.info/view_popup.php?id=66384');
|
|
|
|
|
$this->assertSame('チンポップくんの日常ep.1「チンポップくんと釣り」', $metadata->title);
|
|
|
|
|
$this->assertSame('投稿者: ニジエ運営' . PHP_EOL . 'メールマガジン漫画のバックナンバー第一話です!' . PHP_EOL . '最新話はメールマガジンより配信中です。', $metadata->description);
|
|
|
|
|
$this->assertSame('https://pic.nijie.net/04/nijie_picture/38_20131130155623.png', $metadata->image);
|
|
|
|
|
$this->assertSame(['ニジエたん', '釣り', 'チンポップ君の日常', '公式漫画'], $metadata->tags);
|
2019-02-17 03:19:27 +09:00
|
|
|
|
if ($this->shouldUseMock()) {
|
2019-07-02 12:44:25 +09:00
|
|
|
|
$this->assertSame('https://nijie.info/view.php?id=66384', (string) $this->handler->getLastRequest()->getUri());
|
2019-02-17 03:19:27 +09:00
|
|
|
|
}
|
2018-04-15 21:46:49 +09:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-21 03:40:47 +09:00
|
|
|
|
public function testSp()
|
2018-04-15 21:46:49 +09:00
|
|
|
|
{
|
2020-08-22 13:58:03 +09:00
|
|
|
|
$responseText = $this->fetchSnapshot(__DIR__ . '/../../fixture/Nijie/testStandardPictureResponse.html');
|
2018-04-15 21:46:49 +09:00
|
|
|
|
|
2019-02-17 03:19:27 +09:00
|
|
|
|
$this->createResolver(NijieResolver::class, $responseText);
|
|
|
|
|
|
2019-08-21 03:40:47 +09:00
|
|
|
|
$metadata = $this->resolver->resolve('https://sp.nijie.info/view.php?id=66384');
|
|
|
|
|
$this->assertSame('チンポップくんの日常ep.1「チンポップくんと釣り」', $metadata->title);
|
|
|
|
|
$this->assertSame('投稿者: ニジエ運営' . PHP_EOL . 'メールマガジン漫画のバックナンバー第一話です!' . PHP_EOL . '最新話はメールマガジンより配信中です。', $metadata->description);
|
|
|
|
|
$this->assertSame('https://pic.nijie.net/04/nijie_picture/38_20131130155623.png', $metadata->image);
|
|
|
|
|
$this->assertSame(['ニジエたん', '釣り', 'チンポップ君の日常', '公式漫画'], $metadata->tags);
|
2019-02-17 03:19:27 +09:00
|
|
|
|
if ($this->shouldUseMock()) {
|
2019-08-21 03:40:47 +09:00
|
|
|
|
$this->assertSame('https://nijie.info/view.php?id=66384', (string) $this->handler->getLastRequest()->getUri());
|
2019-02-17 03:19:27 +09:00
|
|
|
|
}
|
2018-04-15 21:46:49 +09:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-21 03:40:47 +09:00
|
|
|
|
public function testSpViewPopup()
|
2018-04-15 21:46:49 +09:00
|
|
|
|
{
|
2020-08-22 13:58:03 +09:00
|
|
|
|
$responseText = $this->fetchSnapshot(__DIR__ . '/../../fixture/Nijie/testStandardPictureResponse.html');
|
2019-02-17 03:19:27 +09:00
|
|
|
|
|
|
|
|
|
$this->createResolver(NijieResolver::class, $responseText);
|
2018-04-15 21:46:49 +09:00
|
|
|
|
|
2019-08-21 03:40:47 +09:00
|
|
|
|
$metadata = $this->resolver->resolve('https://sp.nijie.info/view_popup.php?id=66384');
|
|
|
|
|
$this->assertSame('チンポップくんの日常ep.1「チンポップくんと釣り」', $metadata->title);
|
|
|
|
|
$this->assertSame('投稿者: ニジエ運営' . PHP_EOL . 'メールマガジン漫画のバックナンバー第一話です!' . PHP_EOL . '最新話はメールマガジンより配信中です。', $metadata->description);
|
|
|
|
|
$this->assertSame('https://pic.nijie.net/04/nijie_picture/38_20131130155623.png', $metadata->image);
|
|
|
|
|
$this->assertSame(['ニジエたん', '釣り', 'チンポップ君の日常', '公式漫画'], $metadata->tags);
|
2019-02-17 03:19:27 +09:00
|
|
|
|
if ($this->shouldUseMock()) {
|
2019-08-21 03:40:47 +09:00
|
|
|
|
$this->assertSame('https://nijie.info/view.php?id=66384', (string) $this->handler->getLastRequest()->getUri());
|
2019-02-17 03:19:27 +09:00
|
|
|
|
}
|
2018-04-15 21:46:49 +09:00
|
|
|
|
}
|
2019-10-03 23:34:57 +09:00
|
|
|
|
|
|
|
|
|
public function testHasHtmlInAuthorProfile()
|
|
|
|
|
{
|
2020-08-22 13:58:03 +09:00
|
|
|
|
$responseText = $this->fetchSnapshot(__DIR__ . '/../../fixture/Nijie/testHasHtmlInAuthorProfileResponse.html');
|
2019-10-03 23:34:57 +09:00
|
|
|
|
|
|
|
|
|
$this->createResolver(NijieResolver::class, $responseText);
|
|
|
|
|
|
|
|
|
|
$metadata = $this->resolver->resolve('https://nijie.info/view.php?id=285698');
|
|
|
|
|
$this->assertSame('JK文化祭コスプレ喫茶', $metadata->title);
|
|
|
|
|
$this->assertSame('投稿者: ままままま' . PHP_EOL .
|
|
|
|
|
'https://www.pixiv.net/fanbox/creator/32045169' . PHP_EOL .
|
|
|
|
|
'ピクシブのファンボックスでこっちに上げてた一次創作のノリでえっちなやつ描いてます' . PHP_EOL .
|
|
|
|
|
'二次創作のえっちなやつは相変わらずこっち' . PHP_EOL . '健全目なのはついったー', $metadata->description);
|
|
|
|
|
$this->assertSame('https://pic.nijie.net/02/nijie_picture/540086_20181028112046_0.png', $metadata->image);
|
|
|
|
|
$this->assertSame(['バニーガール'], $metadata->tags);
|
|
|
|
|
if ($this->shouldUseMock()) {
|
|
|
|
|
$this->assertSame('https://nijie.info/view.php?id=285698', (string) $this->handler->getLastRequest()->getUri());
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-15 21:46:49 +09:00
|
|
|
|
}
|