Change and Re-enable URLImageTest (#2844)

Disabled it earlier because its reliance on an external site not under our control was causing problems. URL in spreadsheet is now changed to point to an image in phpspreadsheet.readthedocs.io, which should be more reliable. Test is re-enabled.
This commit is contained in:
oleibman 2022-05-21 08:07:59 -07:00 committed by GitHub
parent 567b9601b0
commit 7c1c896959
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 7 deletions

View File

@ -11,12 +11,9 @@ class URLImageTest extends TestCase
{ {
public function testURLImageSource(): void public function testURLImageSource(): void
{ {
if (getenv('RUN_URL_IMAGE_TEST') !== '1') { if (getenv('SKIP_URL_IMAGE_TEST') === '1') {
self::markTestSkipped('Skipped due to no longer bein able to access external URL'); self::markTestSkipped('Skipped due to setting of environment variable');
} }
//if (getenv('SKIP_URL_IMAGE_TEST') === '1') {
// self::markTestSkipped('Skipped due to setting of environment variable');
//}
$filename = realpath(__DIR__ . '/../../../data/Reader/XLSX/urlImage.xlsx'); $filename = realpath(__DIR__ . '/../../../data/Reader/XLSX/urlImage.xlsx');
self::assertNotFalse($filename); self::assertNotFalse($filename);
$reader = IOFactory::createReader('Xlsx'); $reader = IOFactory::createReader('Xlsx');
@ -29,7 +26,7 @@ class URLImageTest extends TestCase
self::assertInstanceOf(Drawing::class, $drawing); self::assertInstanceOf(Drawing::class, $drawing);
// Check if the source is a URL or a file path // Check if the source is a URL or a file path
self::assertTrue($drawing->getIsURL()); self::assertTrue($drawing->getIsURL());
self::assertSame('https://www.globalipmanager.com/DataFiles/Pics/20/Berniaga.comahp2.jpg', $drawing->getPath()); self::assertSame('https://phpspreadsheet.readthedocs.io/en/latest/topics/images/01-03-filter-icon-1.png', $drawing->getPath());
$imageContents = file_get_contents($drawing->getPath()); $imageContents = file_get_contents($drawing->getPath());
self::assertNotFalse($imageContents); self::assertNotFalse($imageContents);
$filePath = tempnam(sys_get_temp_dir(), 'Drawing'); $filePath = tempnam(sys_get_temp_dir(), 'Drawing');
@ -39,7 +36,7 @@ class URLImageTest extends TestCase
unlink($filePath); unlink($filePath);
self::assertNotFalse($mimeType); self::assertNotFalse($mimeType);
$extension = File::mime2ext($mimeType); $extension = File::mime2ext($mimeType);
self::assertSame('jpeg', $extension); self::assertSame('png', $extension);
} }
} }
} }

Binary file not shown.