1--TEST-- 2Testing ImagickPixel with unitialized pixel_wand 3--SKIPIF-- 4<?php 5require_once(dirname(__FILE__) . '/skipif.inc'); 6requirePHP("5.6"); 7?> 8--FILE-- 9<?php 10 11interface MockInterface {} 12 13class ImagickPixelMock extends \ImagickPixel implements MockInterface 14{ 15 protected $foo1; 16 protected $foo2; 17 protected $foo3; 18 protected $foo4; 19} 20 21$reflectionClass = new ReflectionClass('ImagickPixelMock'); 22$instance = $reflectionClass->newInstanceWithoutConstructor(); 23$methods = $reflectionClass->getMethods(); 24 25$methodsAndParams = array( 26 'clear' => [], 27 'destroy' => [], 28 'getColor' => [], 29 'getColorAsString' => [], 30 'getColorCount' => [], 31 'getColorQuantum' => [], 32 'getColorValue' => [Imagick::COLOR_BLUE], 33 'getColorValueQuantum' => [Imagick::COLOR_RED], 34 'getHSL' => [], 35 'getIndex' => [], 36 'isPixelSimilar' => ['red', 0.1], 37 'isPixelSimilarQuantum' => ['red', 100], 38 'isSimilar' => ['red', 0.1], 39 'setColor' => ['red'], 40 'setcolorcount' => [4], 41 'setColorValue' => [Imagick::COLOR_BLUE, 0.5], 42 'setColorValueQuantum' => [Imagick::COLOR_BLUE, 1], 43 'setHSL' => [0.5, 0.5, 0.5], 44 'setIndex' => [5], 45 'setcolorfrompixel' => [$instance], 46); 47 48$testedMethods = array(); 49foreach ($methodsAndParams as $methodName => $params) { 50 51 if ($reflectionClass->hasMethod($methodName) == false) { 52 continue; 53 } 54 55 try { 56 call_user_func_array([$instance, $methodName], $params); 57 echo "failed to throw an exception.\n"; 58 } 59 catch (ImagickPixelException $ipe) { 60 if (strpos($ipe->getMessage(), "Can not process empty ImagickPixel object") === false) { 61 echo "Incorrect message: " . $ipe->getMessage() . "\n"; 62 } 63 } 64 65 $testedMethods[] = strtolower($methodName); 66} 67 68 69// pretend we tested these. 70$testedMethods[] = '__construct'; 71$testedMethods[] = 'clone'; 72 73foreach ($methods as $method) { 74 $allMethods[] = strtolower($method->getName()); 75} 76 77// Have we tested all but __construct 78$missedMethods = array_diff($allMethods, $testedMethods); 79 80if (count($missedMethods) !== 0) { 81 echo "We didn't test all of the ImagickPixel methods\n"; 82 var_dump($missedMethods); 83} 84 85echo "Ok" 86 87?> 88--EXPECTF-- 89 90Ok