2019-09-10 00:45:53 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Unit\MetadataResolver;
|
|
|
|
|
|
|
|
use App\MetadataResolver\NicoSeigaResolver;
|
2019-09-16 09:55:29 +09:00
|
|
|
use Tests\MyAsserts;
|
2019-09-10 00:45:53 +09:00
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class NicoSeigaResolverTest extends TestCase
|
|
|
|
{
|
2019-09-16 09:55:29 +09:00
|
|
|
use CreateMockedResolver, MyAsserts;
|
2019-09-10 00:45:53 +09:00
|
|
|
|
2020-05-23 22:17:07 +09:00
|
|
|
public function setUp(): void
|
2019-09-10 00:45:53 +09:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
if (!$this->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);
|
2019-09-16 09:55:29 +09:00
|
|
|
$this->assertArrayContains(['アニメ', 'まちカドまぞく', 'シャミ子', 'シャドウミストレス優子', '吉田優子', '危機管理フォーム'], $metadata->tags);
|
2019-09-10 00:45:53 +09:00
|
|
|
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);
|
2019-09-16 09:55:29 +09:00
|
|
|
$this->assertArrayContains(['結月ゆかり', 'VOICEROID'], $metadata->tags);
|
2019-09-10 00:45:53 +09:00
|
|
|
if ($this->shouldUseMock()) {
|
|
|
|
$this->assertSame('https://seiga.nicovideo.jp/seiga/im9232798', (string) $this->handler->getLastRequest()->getUri());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|