tissue/tests/Unit/MetadataResolver/KomifloResolverTest.php

53 lines
2.1 KiB
PHP
Raw Normal View History

2019-06-08 02:38:58 +09:00
<?php
namespace Tests\Unit\MetadataResolver;
use App\MetadataResolver\KomifloResolver;
use Tests\TestCase;
class KomifloResolverTest extends TestCase
{
use CreateMockedResolver;
2020-05-23 22:17:07 +09:00
public function setUp(): void
2019-06-08 02:38:58 +09:00
{
parent::setUp();
if (!$this->shouldUseMock()) {
sleep(1);
}
}
public function testComic()
{
2019-07-02 12:44:25 +09:00
$responseText = file_get_contents(__DIR__ . '/../../fixture/Komiflo/comic.json');
2019-06-08 02:38:58 +09:00
$this->createResolver(KomifloResolver::class, $responseText);
$metadata = $this->resolver->resolve('https://komiflo.com/#!/comics/5490');
$this->assertEquals('魔法少女とえっち物語', $metadata->title);
$this->assertEquals('薙派 - メガストアα 19.07', $metadata->description);
$this->assertEquals('https://t.komiflo.com/564_mobile_large_3x/contents/23a4cd530060b8607aa434f4b299b249e71a4d5c.jpg', $metadata->image);
2019-07-02 12:44:25 +09:00
$this->assertEquals(['薙派', 'お姉さん', 'ショタ', 'ファンタジー', '巨乳', '野外・露出', '羞恥'], $metadata->tags);
2019-06-08 02:38:58 +09:00
if ($this->shouldUseMock()) {
$this->assertSame('https://api.komiflo.com/content/id/5490', (string) $this->handler->getLastRequest()->getUri());
}
}
public function testComicWithNoParents()
{
2019-07-02 12:44:25 +09:00
$responseText = file_get_contents(__DIR__ . '/../../fixture/Komiflo/comicWithNoParents.json');
2019-06-08 02:38:58 +09:00
$this->createResolver(KomifloResolver::class, $responseText);
$metadata = $this->resolver->resolve('https://komiflo.com/#!/comics/3414');
$this->assertEquals('生まれなおしプログラム', $metadata->title);
$this->assertEquals('EROKI - ?', $metadata->description);
$this->assertEquals('https://t.komiflo.com/564_mobile_large_3x/contents/71cfb83640aead3cdd35e4329c4e2f427606a11d.jpg', $metadata->image);
2019-07-02 12:44:25 +09:00
$this->assertEquals(['EROKI', 'お姉さん', 'しつけ', 'オリジナル', 'ショートカット', '逆転', '巨乳'], $metadata->tags);
2019-06-08 02:38:58 +09:00
if ($this->shouldUseMock()) {
$this->assertSame('https://api.komiflo.com/content/id/3414', (string) $this->handler->getLastRequest()->getUri());
}
}
}