diff --git a/tests/Unit/MetadataResolver/PlurkResolverTest.php b/tests/Unit/MetadataResolver/PlurkResolverTest.php new file mode 100644 index 0000000..e2f3abe --- /dev/null +++ b/tests/Unit/MetadataResolver/PlurkResolverTest.php @@ -0,0 +1,35 @@ +shouldUseMock()) { + sleep(1); + } + } + + public function test() + { + $responseText = file_get_contents(__DIR__.'/../../fixture/Plurk/test.html'); + + $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()); + } + } +} diff --git a/tests/fixture/Plurk/test.html b/tests/fixture/Plurk/test.html new file mode 100644 index 0000000..be70c95 --- /dev/null +++ b/tests/fixture/Plurk/test.html @@ -0,0 +1,42 @@ + + + + + 小虫/ムシ@台中種 - [R18]FC2實況中 - Plurk + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + https://images.plurk.com/5cT15Sf9OOFYk9fEQ759bZ.jpg + + + https://images.plurk.com/2HdBlulzzXMZB7vITj4uOG.jpg + [R18]FC2實況中 +
+
+ + \ No newline at end of file