Skip to content

Commit f78b176

Browse files
committed
safer tests for no ppm loader
1 parent 52ed5c0 commit f78b176

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tests/ConfigTest.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ public function testPpmLoadBuffer()
4343
0 0 0
4444
";
4545

46-
// the PPM loader is built in and should be available in most
47-
// libvips binaries
48-
$image = Vips\Image::ppmload_buffer($ppm);
49-
$this->assertTrue($image->width == 1);
46+
if (Vips\Utils::typeFromName("VipsForeignLoadPpm") != 0) {
47+
// the PPM loader is built in and should be available in most
48+
// libvips binaries
49+
$image = Vips\Image::ppmload_buffer($ppm);
50+
$this->assertTrue($image->width == 1);
51+
}
5052
}
5153

5254
public function testBlockUntrusted()
@@ -57,7 +59,8 @@ public function testBlockUntrusted()
5759
0 0 0
5860
";
5961

60-
if (Vips\FFI::atLeast(8, 13)) {
62+
if (Vips\FFI::atLeast(8, 13) &&
63+
Vips\Utils::typeFromName("VipsForeignLoadPpm") != 0) {
6164
Vips\Config::setBlockUntrusted(true);
6265

6366
// should fail
@@ -75,7 +78,8 @@ public function testBlock()
7578
0 0 0
7679
";
7780

78-
if (Vips\FFI::atLeast(8, 13)) {
81+
if (Vips\FFI::atLeast(8, 13) &&
82+
Vips\Utils::typeFromName("VipsForeignLoadPpm") != 0) {
7983
Vips\Config::setBlockUntrusted(true);
8084
Vips\Config::setBlock("VipsForeignLoadPpm", false);
8185

0 commit comments

Comments
 (0)