createResolver(OGPResolver::class, '', [], 404);
$this->expectException(\RuntimeException::class);
$this->resolver->resolve('http://example.com/404');
}
public function testResolve()
{
$response = <<< 'HTML'
The Open Graph protocol
HTML;
$this->createResolver(OGPResolver::class, $response);
$resolver = $this->createResolver(OGPResolver::class, $response);
$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);
}
public function testResolveTitleOnly()
{
$response = <<< 'HTML'
Example Domain
HTML;
$this->createResolver(OGPResolver::class, $response);
$metadata = $this->resolver->resolve('http://example.com');
$this->assertEquals('Example Domain', $metadata->title);
$this->assertEmpty($metadata->description);
$this->assertEmpty($metadata->image);
}
public function testResolveTitleAndDescription()
{
$resolver = $this->app->make(OGPResolver::class);
$html = <<Welcome to my homepage
EOF;
$metadata = $resolver->parse($html);
$this->assertEquals('Welcome to my homepage', $metadata->title);
$this->assertEquals('This is my super hyper ultra homepage!!', $metadata->description);
$this->assertEmpty($metadata->image);
}
}