diff --git a/tests/Unit/MetadataResolver/DeviantArtResolverTest.php b/tests/Unit/MetadataResolver/DeviantArtResolverTest.php index c87eeeb..88bae98 100644 --- a/tests/Unit/MetadataResolver/DeviantArtResolverTest.php +++ b/tests/Unit/MetadataResolver/DeviantArtResolverTest.php @@ -27,12 +27,27 @@ class DeviantArtResolverTest extends TestCase $metadata = $this->resolver->resolve('https://www.deviantart.com/bonchilo/art/Sally-Nox-743562408'); $this->assertSame('Sally Nox', $metadata->title); $this->assertSame('By Bonchilo', $metadata->description); - $this->assertSame('https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/f6b84a8f-053e-4ab6-bd6c-71276a4a9282/dcap4fc-6fd6359c-770b-4515-9e29-e99311d58d57.png/v1/fit/w_700,h_700,q_70,strp/sally__nox_by_bonchilo_dcap4fc-pre.jpg?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7ImhlaWdodCI6Ijw9MTE0MCIsInBhdGgiOiJcL2ZcL2Y2Yjg0YThmLTA1M2UtNGFiNi1iZDZjLTcxMjc2YTRhOTI4MlwvZGNhcDRmYy02ZmQ2MzU5Yy03NzBiLTQ1MTUtOWUyOS1lOTkzMTFkNThkNTcucG5nIiwid2lkdGgiOiI8PTEyODAifV1dLCJhdWQiOlsidXJuOnNlcnZpY2U6aW1hZ2Uub3BlcmF0aW9ucyJdfQ.zbw4e5eH0NafyMmhM15DKN1NjawSZBUwr2RWQWB7O3o', $metadata->image); + $this->assertStringStartsWith('https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/f6b84a8f-053e-4ab6-bd6c-71276a4a9282/dcap4fc-6fd6359c-770b-4515-9e29-e99311d58d57.png/v1/fit/w_1024,h_1024,strp/image.jpg?token=', $metadata->image); if ($this->shouldUseMock()) { $this->assertSame('https://backend.deviantart.com/oembed?url=https://www.deviantart.com/bonchilo/art/Sally-Nox-743562408', (string) $this->handler->getLastRequest()->getUri()); } } + public function testWixmpNoImageOptions() + { + $responseText = file_get_contents(__DIR__ . '/../../fixture/DeviantArt/wixmpNoImageOptions.json'); + + $this->createResolver(DeviantArtResolver::class, $responseText); + + $metadata = $this->resolver->resolve('https://www.deviantart.com/messenger-lame/art/rem-639676105'); + $this->assertSame('rem', $metadata->title); + $this->assertSame('By messenger-lame', $metadata->description); + $this->assertStringStartsWith('https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/9afa7937-381f-47f0-a8bc-40b9db1faad1/dakuh8p-aea3fc1c-c06e-466b-88ba-d27be8e164e9.png/v1/fit/w_1024,h_1024,strp/image.jpg?token=', $metadata->image); + if ($this->shouldUseMock()) { + $this->assertSame('https://backend.deviantart.com/oembed?url=https://www.deviantart.com/messenger-lame/art/rem-639676105', (string) $this->handler->getLastRequest()->getUri()); + } + } + public function testMature() { $responseText = file_get_contents(__DIR__ . '/../../fixture/DeviantArt/mature.json'); diff --git a/tests/fixture/DeviantArt/wixmpNoImageOptions.json b/tests/fixture/DeviantArt/wixmpNoImageOptions.json new file mode 100644 index 0000000..66a07b2 --- /dev/null +++ b/tests/fixture/DeviantArt/wixmpNoImageOptions.json @@ -0,0 +1 @@ +{"version":"1.0","type":"photo","title":"rem","category":"Manga & Anime > Digital Media > Drawings","url":"https:\/\/images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com\/f\/9afa7937-381f-47f0-a8bc-40b9db1faad1\/dakuh8p-aea3fc1c-c06e-466b-88ba-d27be8e164e9.png?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7InBhdGgiOiJcL2ZcLzlhZmE3OTM3LTM4MWYtNDdmMC1hOGJjLTQwYjlkYjFmYWFkMVwvZGFrdWg4cC1hZWEzZmMxYy1jMDZlLTQ2NmItODhiYS1kMjdiZThlMTY0ZTkucG5nIn1dXSwiYXVkIjpbInVybjpzZXJ2aWNlOmZpbGUuZG93bmxvYWQiXX0.QX4iUJ00rh1B0PXwyBedqQVbEHR6C72Yp0a9DpM5UIg","author_name":"messenger-lame","author_url":"https:\/\/www.deviantart.com\/messenger-lame","provider_name":"DeviantArt","provider_url":"https:\/\/www.deviantart.com","safety":"nonadult","pubdate":"2016-10-12T05:03:58-07:00","community":{"statistics":{"_attributes":{"views":1612,"favorites":313,"comments":9,"downloads":71}}},"tags":"rem, re_zero_kara_hajimeru_isekai_seikatsu","copyright":{"_attributes":{"url":"https:\/\/www.deviantart.com\/messenger-lame","year":"2016","entity":"messenger-lame"}},"width":"750","height":"1000","imagetype":"png","thumbnail_url":"https:\/\/images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com\/f\/9afa7937-381f-47f0-a8bc-40b9db1faad1\/dakuh8p-aea3fc1c-c06e-466b-88ba-d27be8e164e9.png\/v1\/fit\/w_300,h_900,strp\/rem_by_messenger_lame_dakuh8p-300w.png?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7ImhlaWdodCI6Ijw9MTAwMCIsInBhdGgiOiJcL2ZcLzlhZmE3OTM3LTM4MWYtNDdmMC1hOGJjLTQwYjlkYjFmYWFkMVwvZGFrdWg4cC1hZWEzZmMxYy1jMDZlLTQ2NmItODhiYS1kMjdiZThlMTY0ZTkucG5nIiwid2lkdGgiOiI8PTc1MCJ9XV0sImF1ZCI6WyJ1cm46c2VydmljZTppbWFnZS5vcGVyYXRpb25zIl19._gC85PXUst0iqKJCZZSUVonW0YRr5GHj2Qen_Q_95Og","thumbnail_width":300,"thumbnail_height":400,"thumbnail_url_150":"https:\/\/images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com\/f\/9afa7937-381f-47f0-a8bc-40b9db1faad1\/dakuh8p-aea3fc1c-c06e-466b-88ba-d27be8e164e9.png\/v1\/fit\/w_150,h_150,strp\/rem_by_messenger_lame_dakuh8p-150.png?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7ImhlaWdodCI6Ijw9MTAwMCIsInBhdGgiOiJcL2ZcLzlhZmE3OTM3LTM4MWYtNDdmMC1hOGJjLTQwYjlkYjFmYWFkMVwvZGFrdWg4cC1hZWEzZmMxYy1jMDZlLTQ2NmItODhiYS1kMjdiZThlMTY0ZTkucG5nIiwid2lkdGgiOiI8PTc1MCJ9XV0sImF1ZCI6WyJ1cm46c2VydmljZTppbWFnZS5vcGVyYXRpb25zIl19._gC85PXUst0iqKJCZZSUVonW0YRr5GHj2Qen_Q_95Og","thumbnail_url_200h":"https:\/\/images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com\/f\/9afa7937-381f-47f0-a8bc-40b9db1faad1\/dakuh8p-aea3fc1c-c06e-466b-88ba-d27be8e164e9.png\/v1\/fill\/w_150,h_200,strp\/rem_by_messenger_lame_dakuh8p-200h.png?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7ImhlaWdodCI6Ijw9MTAwMCIsInBhdGgiOiJcL2ZcLzlhZmE3OTM3LTM4MWYtNDdmMC1hOGJjLTQwYjlkYjFmYWFkMVwvZGFrdWg4cC1hZWEzZmMxYy1jMDZlLTQ2NmItODhiYS1kMjdiZThlMTY0ZTkucG5nIiwid2lkdGgiOiI8PTc1MCJ9XV0sImF1ZCI6WyJ1cm46c2VydmljZTppbWFnZS5vcGVyYXRpb25zIl19._gC85PXUst0iqKJCZZSUVonW0YRr5GHj2Qen_Q_95Og","thumbnail_width_200h":150,"thumbnail_height_200h":200} \ No newline at end of file