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