1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Test; |
5
|
|
|
|
6
|
|
|
require __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; |
7
|
|
|
|
8
|
|
|
use WideImage\WideImage; |
9
|
|
|
|
10
|
|
|
define('TEST_PATH', __DIR__ . DIRECTORY_SEPARATOR); |
11
|
|
|
define('IMG_PATH', TEST_PATH . 'images' . DIRECTORY_SEPARATOR); |
12
|
|
|
|
13
|
|
|
// check for xdebug scream |
14
|
|
|
if (ini_get('xdebug.scream') == 1) { |
15
|
|
|
ini_set('xdebug.scream', 0); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
abstract class WideImage_TestCase extends \PHPUnit_Framework_TestCase |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
public function load($file) |
21
|
|
|
{ |
22
|
|
|
return WideImage::load(IMG_PATH . $file); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function assertValidImage($image) |
26
|
|
|
{ |
27
|
|
|
$this->assertInstanceOf('WideImage\\Image', $image); |
28
|
|
|
$this->assertTrue($image->isValid()); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function assertDimensions($image, $width, $height) |
32
|
|
|
{ |
33
|
|
|
$this->assertEquals($width, $image->getWidth()); |
34
|
|
|
$this->assertEquals($height, $image->getHeight()); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function assertTransparentColorMatch($img1, $img2) |
38
|
|
|
{ |
39
|
|
|
$tc1 = $img1->getTransparentColorRGB(); |
40
|
|
|
$tc2 = $img2->getTransparentColorRGB(); |
41
|
|
|
$this->assertEquals($tc1, $tc2); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function assertTransparentColorAt($img, $x, $y) |
45
|
|
|
{ |
46
|
|
|
$this->assertEquals($img->getTransparentColor(), $img->getColorAt($x, $y)); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function assertRGBWithinMargin($rec, $r, $g, $b, $a, $margin) |
50
|
|
|
{ |
51
|
|
|
if (is_array($r)) { |
52
|
|
|
$a = $r['alpha']; |
53
|
|
|
$b = $r['blue']; |
54
|
|
|
$g = $r['green']; |
55
|
|
|
$r = $r['red']; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$result = |
59
|
|
|
abs($rec['red'] - $r) <= $margin && |
60
|
|
|
abs($rec['green'] - $g) <= $margin && |
61
|
|
|
abs($rec['blue'] - $b) <= $margin; |
62
|
|
|
|
63
|
|
|
$result = $result && ($a === null || abs($rec['alpha'] - $a) <= $margin); |
64
|
|
|
|
65
|
|
|
$this->assertTrue($result, |
66
|
|
|
"RGBA [{$rec['red']}, {$rec['green']}, {$rec['blue']}, {$rec['alpha']}] " . |
67
|
|
|
"doesn't match RGBA [$r, $g, $b, $a] within margin [$margin]."); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function assertRGBAt($img, $x, $y, $rgba) |
71
|
|
|
{ |
72
|
|
|
if (is_array($rgba)) { |
73
|
|
|
$cmp = $img->getRGBAt($x, $y); |
74
|
|
|
} else { |
75
|
|
|
$cmp = $img->getColorAt($x, $y); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
$this->assertSame($cmp, $rgba); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function assertRGBNear($rec, $r, $g = null, $b = null, $a = null) |
82
|
|
|
{ |
83
|
|
|
$this->assertRGBWithinMargin($rec, $r, $g, $b, $a, 2); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function assertRGBEqual($rec, $r, $g = null, $b = null, $a = null) |
87
|
|
|
{ |
88
|
|
|
$this->assertRGBWithinMargin($rec, $r, $g, $b, $a, 0); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths