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:
parent
567b9601b0
commit
7c1c896959
|
|
@ -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.
Loading…
Reference in New Issue