From b29bb23b406a7f7957a323f6670dc9bf37f33502 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Fri, 8 Mar 2019 03:58:45 +0900 Subject: [PATCH] =?UTF-8?q?PlurkResolver=E3=81=AE=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MetadataResolver/PlurkResolverTest.php | 35 ++++++++++++++++ tests/fixture/Plurk/test.html | 42 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 tests/Unit/MetadataResolver/PlurkResolverTest.php create mode 100644 tests/fixture/Plurk/test.html 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