1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
This file is part of WideImage. |
4
|
|
|
|
5
|
|
|
WideImage is free software; you can redistribute it and/or modify |
6
|
|
|
it under the terms of the GNU Lesser General Public License as published by |
7
|
|
|
the Free Software Foundation; either version 2.1 of the License, or |
8
|
|
|
(at your option) any later version. |
9
|
|
|
|
10
|
|
|
WideImage is distributed in the hope that it will be useful, |
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
GNU Lesser General Public License for more details. |
14
|
|
|
|
15
|
|
|
You should have received a copy of the GNU Lesser General Public License |
16
|
|
|
along with WideImage; if not, write to the Free Software |
17
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
18
|
|
|
|
19
|
|
|
* @package Tests |
20
|
|
|
**/ |
21
|
|
|
|
22
|
|
|
namespace Test\WideImage\Mapper; |
23
|
|
|
|
24
|
|
|
use WideImage\WideImage; |
25
|
|
|
use WideImage\MapperFactory; |
26
|
|
|
use WideImage\vendor\de77; |
27
|
|
|
use Test\WideImage_TestCase; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @package Tests |
31
|
|
|
*/ |
32
|
|
|
class BMPTest extends WideImage_TestCase |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @var WideImage_Mapper_BMP |
|
|
|
|
36
|
|
|
*/ |
37
|
|
|
protected $mapper; |
38
|
|
|
|
39
|
|
|
public function setup() |
40
|
|
|
{ |
41
|
|
|
$this->mapper = MapperFactory::selectMapper(null, 'bmp'); |
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function teardown() |
45
|
|
|
{ |
46
|
|
|
$this->mapper = null; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function imageProvider() |
50
|
|
|
{ |
51
|
|
|
return array( |
52
|
|
|
array(IMG_PATH . 'fgnl.bmp', 174, 287), |
53
|
|
|
array(IMG_PATH . 'bmp' . DIRECTORY_SEPARATOR . 'favicon.ico', 30, 30) |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @dataProvider imageProvider |
59
|
|
|
*/ |
60
|
|
|
public function testLoad($image, $width, $height) |
61
|
|
|
{ |
62
|
|
|
$handle = $this->mapper->load($image); |
63
|
|
|
$this->assertTrue(WideImage::isValidImageHandle($handle)); |
64
|
|
|
$this->assertEquals($width, imagesx($handle)); |
65
|
|
|
$this->assertEquals($height, imagesy($handle)); |
66
|
|
|
imagedestroy($handle); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function testSaveToString() |
70
|
|
|
{ |
71
|
|
|
$handle = de77\BMP::imagecreatefrombmp(IMG_PATH . 'fgnl.bmp'); |
72
|
|
|
ob_start(); |
73
|
|
|
$this->mapper->save($handle); |
74
|
|
|
$string = ob_get_clean(); |
75
|
|
|
$this->assertTrue(strlen($string) > 0); |
76
|
|
|
imagedestroy($handle); |
|
|
|
|
77
|
|
|
|
78
|
|
|
// string contains valid image data |
79
|
|
|
$handle = $this->mapper->loadFromString($string); |
80
|
|
|
$this->assertTrue(WideImage::isValidImageHandle($handle)); |
81
|
|
|
imagedestroy($handle); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function testSaveToFile() |
85
|
|
|
{ |
86
|
|
|
$handle = imagecreatefromgif(IMG_PATH . '100x100-color-hole.gif'); |
87
|
|
|
$this->mapper->save($handle, IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.bmp'); |
88
|
|
|
$this->assertTrue(filesize(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.bmp') > 0); |
89
|
|
|
imagedestroy($handle); |
90
|
|
|
|
91
|
|
|
// file is a valid image |
92
|
|
|
$handle = $this->mapper->load(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.bmp'); |
93
|
|
|
$this->assertTrue(WideImage::isValidImageHandle($handle)); |
94
|
|
|
imagedestroy($handle); |
95
|
|
|
|
96
|
|
|
unlink(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.bmp'); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
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