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;
|
|
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
|
{
|
|
|
|
|
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()
|
|
|
|
|
{
|
2019-02-17 03:19:27 +09:00
|
|
|
|
$responseText = file_get_contents(__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');
|
2018-04-15 21:46:49 +09:00
|
|
|
|
$this->assertEquals('チンポップくんの日常ep.1「チンポップくんと釣り」 | ニジエ運営', $metadata->title);
|
|
|
|
|
$this->assertEquals("メールマガジン漫画のバックナンバー第一話です!\r\n最新話はメールマガジンより配信中です。", $metadata->description);
|
|
|
|
|
$this->assertRegExp('/pic\d+\.nijie\.info/', $metadata->image);
|
|
|
|
|
$this->assertNotRegExp('~/diff/main/~', $metadata->image);
|
2019-02-17 03:19:27 +09:00
|
|
|
|
if ($this->shouldUseMock()) {
|
|
|
|
|
$this->assertSame('https://nijie.info/view.php?id=66384', (string)$this->handler->getLastRequest()->getUri());
|
|
|
|
|
}
|
2018-04-15 21:46:49 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testMultiplePicture()
|
|
|
|
|
{
|
2019-02-17 03:19:27 +09:00
|
|
|
|
$responseText = file_get_contents(__DIR__ . '/../../fixture/Nijie/testMultiplePictureResponse.html');
|
|
|
|
|
|
|
|
|
|
$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');
|
2018-04-15 21:46:49 +09:00
|
|
|
|
$this->assertEquals('ニジエ壁紙 | ニジエ運営', $metadata->title);
|
|
|
|
|
$this->assertEquals("ニジエのPCとiphone用(4.7inch推奨)の壁紙です。\r\n保存してご自由にお使いくださいませ。", $metadata->description);
|
|
|
|
|
$this->assertRegExp('/pic\d+\.nijie\.info/', $metadata->image);
|
|
|
|
|
$this->assertNotRegExp('~/diff/main/~', $metadata->image);
|
2019-02-17 03:19:27 +09:00
|
|
|
|
if ($this->shouldUseMock()) {
|
|
|
|
|
$this->assertSame('https://nijie.info/view.php?id=202707', (string)$this->handler->getLastRequest()->getUri());
|
|
|
|
|
}
|
2018-04-15 21:46:49 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testAnimationGif()
|
|
|
|
|
{
|
2019-02-17 03:19:27 +09:00
|
|
|
|
$responseText = file_get_contents(__DIR__ . '/../../fixture/Nijie/testAnimationGifResponse.html');
|
|
|
|
|
|
|
|
|
|
$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-01-17 23:24:33 +09:00
|
|
|
|
$this->assertEquals('ニジエがgifに対応したんだってね 奥さん | 黒末アプコ', $metadata->title);
|
2019-01-19 03:02:37 +09:00
|
|
|
|
$this->assertEquals('アニメgifとか専門外なのでよくわかりませんでした', $metadata->description);
|
2018-04-15 22:27:38 +09:00
|
|
|
|
$this->assertRegExp('~/nijie\.info/pic/logo~', $metadata->image);
|
2019-02-17 03:19:27 +09:00
|
|
|
|
if ($this->shouldUseMock()) {
|
|
|
|
|
$this->assertSame('https://nijie.info/view.php?id=9537', (string)$this->handler->getLastRequest()->getUri());
|
|
|
|
|
}
|
2018-04-15 21:46:49 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testMp4Movie()
|
|
|
|
|
{
|
2019-02-17 03:19:27 +09:00
|
|
|
|
$responseText = file_get_contents(__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');
|
2018-04-15 21:46:49 +09:00
|
|
|
|
$this->assertEquals('てすと | ニジエ運営', $metadata->title);
|
|
|
|
|
$this->assertEquals("H264動画てすと あとで消します\r\n\r\n今の所、H264コーデックのみ、出力時に音声なしにしないと投稿できません\r\n動画は勝手にループします", $metadata->description);
|
2018-04-15 22:27:38 +09:00
|
|
|
|
$this->assertRegExp('~/nijie\.info/pic/logo~', $metadata->image);
|
2019-02-17 03:19:27 +09:00
|
|
|
|
if ($this->shouldUseMock()) {
|
|
|
|
|
$this->assertSame('https://nijie.info/view.php?id=256283', (string)$this->handler->getLastRequest()->getUri());
|
|
|
|
|
}
|
2018-04-15 21:46:49 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testStandardPictureSp()
|
|
|
|
|
{
|
2019-02-17 03:19:27 +09:00
|
|
|
|
$responseText = file_get_contents(__DIR__ . '/../../fixture/Nijie/testStandardPictureResponse.html');
|
|
|
|
|
|
|
|
|
|
$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://sp.nijie.info/view.php?id=66384');
|
2018-04-15 21:46:49 +09:00
|
|
|
|
$this->assertEquals('チンポップくんの日常ep.1「チンポップくんと釣り」 | ニジエ運営', $metadata->title);
|
|
|
|
|
$this->assertEquals("メールマガジン漫画のバックナンバー第一話です!\r\n最新話はメールマガジンより配信中です。", $metadata->description);
|
|
|
|
|
$this->assertRegExp('/pic\d+\.nijie\.info/', $metadata->image);
|
|
|
|
|
$this->assertNotRegExp('~/diff/main/~', $metadata->image);
|
2019-02-17 03:19:27 +09:00
|
|
|
|
if ($this->shouldUseMock()) {
|
|
|
|
|
$this->assertSame('https://nijie.info/view.php?id=66384', (string)$this->handler->getLastRequest()->getUri());
|
|
|
|
|
}
|
2018-04-15 21:46:49 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testMultiplePictureSp()
|
|
|
|
|
{
|
2019-02-17 03:19:27 +09:00
|
|
|
|
$responseText = file_get_contents(__DIR__ . '/../../fixture/Nijie/testMultiplePictureResponse.html');
|
|
|
|
|
|
|
|
|
|
$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://sp.nijie.info/view.php?id=202707');
|
2018-04-15 21:46:49 +09:00
|
|
|
|
$this->assertEquals('ニジエ壁紙 | ニジエ運営', $metadata->title);
|
|
|
|
|
$this->assertEquals("ニジエのPCとiphone用(4.7inch推奨)の壁紙です。\r\n保存してご自由にお使いくださいませ。", $metadata->description);
|
|
|
|
|
$this->assertRegExp('/pic\d+\.nijie\.info/', $metadata->image);
|
|
|
|
|
$this->assertNotRegExp('~/diff/main/~', $metadata->image);
|
2019-02-17 03:19:27 +09:00
|
|
|
|
if ($this->shouldUseMock()) {
|
|
|
|
|
$this->assertSame('https://nijie.info/view.php?id=202707', (string)$this->handler->getLastRequest()->getUri());
|
|
|
|
|
}
|
2018-04-15 21:46:49 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testAnimationGifSp()
|
|
|
|
|
{
|
2019-02-17 03:19:27 +09:00
|
|
|
|
$responseText = file_get_contents(__DIR__ . '/../../fixture/Nijie/testAnimationGifResponse.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=9537');
|
2019-01-17 23:24:33 +09:00
|
|
|
|
$this->assertEquals('ニジエがgifに対応したんだってね 奥さん | 黒末アプコ', $metadata->title);
|
2019-01-19 03:02:37 +09:00
|
|
|
|
$this->assertEquals('アニメgifとか専門外なのでよくわかりませんでした', $metadata->description);
|
2018-04-15 22:27:38 +09:00
|
|
|
|
$this->assertRegExp('~/nijie\.info/pic/logo~', $metadata->image);
|
2019-02-17 03:19:27 +09:00
|
|
|
|
if ($this->shouldUseMock()) {
|
|
|
|
|
$this->assertSame('https://nijie.info/view.php?id=9537', (string)$this->handler->getLastRequest()->getUri());
|
|
|
|
|
}
|
2018-04-15 21:46:49 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testMp4MovieSp()
|
|
|
|
|
{
|
2019-02-17 03:19:27 +09:00
|
|
|
|
$responseText = file_get_contents(__DIR__ . '/../../fixture/Nijie/testMp4MovieResponse.html');
|
|
|
|
|
|
|
|
|
|
$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://sp.nijie.info/view.php?id=256283');
|
2018-04-15 21:46:49 +09:00
|
|
|
|
$this->assertEquals('てすと | ニジエ運営', $metadata->title);
|
|
|
|
|
$this->assertEquals("H264動画てすと あとで消します\r\n\r\n今の所、H264コーデックのみ、出力時に音声なしにしないと投稿できません\r\n動画は勝手にループします", $metadata->description);
|
2018-04-15 22:27:38 +09:00
|
|
|
|
$this->assertRegExp('~/nijie\.info/pic/logo~', $metadata->image);
|
2019-02-17 03:19:27 +09:00
|
|
|
|
if ($this->shouldUseMock()) {
|
|
|
|
|
$this->assertSame('https://nijie.info/view.php?id=256283', (string)$this->handler->getLastRequest()->getUri());
|
|
|
|
|
}
|
2018-04-15 21:46:49 +09:00
|
|
|
|
}
|
|
|
|
|
}
|