Skip to content

Commit 7c1c896

Browse files
authored
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.
1 parent 567b960 commit 7c1c896

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

tests/PhpSpreadsheetTests/Reader/Xlsx/URLImageTest.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@ class URLImageTest extends TestCase
1111
{
1212
public function testURLImageSource(): void
1313
{
14-
if (getenv('RUN_URL_IMAGE_TEST') !== '1') {
15-
self::markTestSkipped('Skipped due to no longer bein able to access external URL');
14+
if (getenv('SKIP_URL_IMAGE_TEST') === '1') {
15+
self::markTestSkipped('Skipped due to setting of environment variable');
1616
}
17-
//if (getenv('SKIP_URL_IMAGE_TEST') === '1') {
18-
// self::markTestSkipped('Skipped due to setting of environment variable');
19-
//}
2017
$filename = realpath(__DIR__ . '/../../../data/Reader/XLSX/urlImage.xlsx');
2118
self::assertNotFalse($filename);
2219
$reader = IOFactory::createReader('Xlsx');
@@ -29,7 +26,7 @@ public function testURLImageSource(): void
2926
self::assertInstanceOf(Drawing::class, $drawing);
3027
// Check if the source is a URL or a file path
3128
self::assertTrue($drawing->getIsURL());
32-
self::assertSame('https://www.globalipmanager.com/DataFiles/Pics/20/Berniaga.comahp2.jpg', $drawing->getPath());
29+
self::assertSame('https://phpspreadsheet.readthedocs.io/en/latest/topics/images/01-03-filter-icon-1.png', $drawing->getPath());
3330
$imageContents = file_get_contents($drawing->getPath());
3431
self::assertNotFalse($imageContents);
3532
$filePath = tempnam(sys_get_temp_dir(), 'Drawing');
@@ -39,7 +36,7 @@ public function testURLImageSource(): void
3936
unlink($filePath);
4037
self::assertNotFalse($mimeType);
4138
$extension = File::mime2ext($mimeType);
42-
self::assertSame('jpeg', $extension);
39+
self::assertSame('png', $extension);
4340
}
4441
}
4542
}

tests/data/Reader/XLSX/urlImage.xlsx

17 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)