load($filename); $worksheet = $spreadsheet->getActiveSheet(); $collection = $worksheet->getDrawingCollection(); self::assertCount(1, $collection); foreach ($collection as $drawing) { self::assertInstanceOf(Drawing::class, $drawing); // Check if the source is a URL or a file path self::assertTrue($drawing->getIsURL()); self::assertSame('https://www.globalipmanager.com/DataFiles/Pics/20/Berniaga.comahp2.jpg', $drawing->getPath()); $imageContents = file_get_contents($drawing->getPath()); self::assertNotFalse($imageContents); $filePath = tempnam(sys_get_temp_dir(), 'Drawing'); self::assertNotFalse($filePath); self::assertNotFalse(file_put_contents($filePath, $imageContents)); $mimeType = mime_content_type($filePath); unlink($filePath); self::assertNotFalse($mimeType); $extension = File::mime2ext($mimeType); self::assertSame('jpeg', $extension); } } }