3 namespace Friendica\Test\src\Util;
5 use Friendica\Test\DiceHttpMockHandlerTrait;
6 use Friendica\Test\MockedTest;
7 use Friendica\Util\Images;
8 use GuzzleHttp\Handler\MockHandler;
9 use GuzzleHttp\Psr7\Response;
11 class ImagesTest extends MockedTest
13 use DiceHttpMockHandlerTrait;
15 protected function setUp(): void
19 $this->setupHttpMockHandler();
22 public function dataImages()
26 'url' => 'https://pbs.twimg.com/profile_images/2365515285/9re7kx4xmc0eu9ppmado.png',
29 'Content-Type' => 'image/png',
30 'Cache-Control' => 'max-age=604800,must-revalidate',
31 'Last-Modified' => 'Thu,04Nov201001:42:54GMT',
32 'Content-Length' => '24875',
33 'Access-Control-Allow-Origin' => '*',
34 'Access-Control-Expose-Headers' => 'Content-Length',
35 'Date' => 'Mon,23Aug202112:39:00GMT',
36 'Connection' => 'keep-alive',
38 'data' => file_get_contents(__DIR__ . '/../../datasets/curl/image.content'),
43 '3' => 'width="400" height="400"',
45 'mime' => 'image/png',
59 * Test the Images::getInfoFromURL() method (only remote images, not local/relative!)
61 * @dataProvider dataImages
63 public function testGetInfoFromRemotURL(string $url, array $headers, string $data, array $assertion)
65 $this->httpRequestHandler->setHandler(new MockHandler([
66 new Response(200, $headers, $data),
69 self::assertArraySubset($assertion, Images::getInfoFromURL($url));