2019-03-08 03:58:45 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Unit\MetadataResolver;
|
|
|
|
|
|
|
|
use App\MetadataResolver\PlurkResolver;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class PlurkResolverTest extends TestCase
|
|
|
|
{
|
|
|
|
use CreateMockedResolver;
|
|
|
|
|
2020-05-23 22:17:07 +09:00
|
|
|
public function setUp(): void
|
2019-03-08 03:58:45 +09:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
if (!$this->shouldUseMock()) {
|
|
|
|
sleep(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function test()
|
|
|
|
{
|
2020-08-22 13:58:03 +09:00
|
|
|
$responseText = $this->fetchSnapshot(__DIR__ . '/../../fixture/Plurk/test.html');
|
2019-03-08 03:58:45 +09:00
|
|
|
|
|
|
|
$this->createResolver(PlurkResolver::class, $responseText);
|
|
|
|
|
|
|
|
$metadata = $this->resolver->resolve('https://www.plurk.com/p/n0awli/');
|
|
|
|
$this->assertEquals('[R18]FC2實況中', $metadata->title);
|
|
|
|
$this->assertEquals('Plurk by 小虫/ムシ@台中種 - 71 response(s)', $metadata->description);
|
|
|
|
$this->assertEquals('https://images.plurk.com/5cT15Sf9OOFYk9fEQ759bZ.jpg', $metadata->image);
|
|
|
|
if ($this->shouldUseMock()) {
|
|
|
|
$this->assertSame('https://www.plurk.com/p/n0awli/', (string) $this->handler->getLastRequest()->getUri());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|