コンテンツ情報取得の実装をapi.phpから剥がした

This commit is contained in:
shibafu
2018-04-15 02:05:41 +09:00
parent 0f39b502e8
commit 7ca0acacb4
9 changed files with 190 additions and 66 deletions

View File

@@ -0,0 +1,28 @@
<?php
namespace Tests\Unit\MetadataResolver;
use App\MetadataResolver\OGPResolver;
use GuzzleHttp\Exception\ClientException;
use Tests\TestCase;
class OGPResolverTest extends TestCase
{
public function testMissingUrl()
{
$resolver = new OGPResolver();
$this->expectException(ClientException::class);
$resolver->resolve('http://example.com/404');
}
public function testResolve()
{
$resolver = new OGPResolver();
$metadata = $resolver->resolve('http://ogp.me');
$this->assertEquals('Open Graph protocol', $metadata->title);
$this->assertEquals('The Open Graph protocol enables any web page to become a rich object in a social graph.', $metadata->description);
$this->assertEquals('http://ogp.me/logo.png', $metadata->image);
}
}