Passed
Push — master ( 3c6756...8b3b37 )
by Michael
14:24 queued 07:02
created

AutocropTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 13
c 2
b 0
f 0
dl 0
loc 24
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testAutocrop() 0 10 1
A testAutocropHalfImageBug() 0 10 1
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\Operation;
23
24
use WideImage\WideImage;
25
use WideImage\TrueColorImage;
26
use Test\WideImage_TestCase;
27
28
/**
29
 * @package Tests
30
 */
31
class AutocropTest extends WideImage_TestCase
32
{
33
	public function testAutocrop()
34
	{
35
		$img = WideImage::load(IMG_PATH . '100x100-red-spot.png');
36
		
37
		$cropped = $img->autocrop();
38
		$this->assertTrue($cropped instanceof TrueColorImage);
39
		$this->assertEquals(71, $cropped->getWidth());
40
		$this->assertEquals(70, $cropped->getHeight());
41
		
42
		$this->assertRGBNear($cropped->getRGBAt(10, 10), 255, 0, 0);
43
	}
44
	
45
	public function testAutocropHalfImageBug()
46
	{
47
		$img = WideImage::load(IMG_PATH . '100x100-red-spot-half-cut.png');
48
		
49
		$cropped = $img->autocrop();
50
		$this->assertTrue($cropped instanceof TrueColorImage);
51
		$this->assertEquals(22, $cropped->getWidth());
52
		$this->assertEquals(23, $cropped->getHeight());
53
		
54
		$this->assertRGBNear($cropped->getRGBAt(10, 10), 255, 0, 0);
55
	}
56
}
57