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

RoundCornersTest::testWhiteCorner()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 10
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 Test\WideImage_TestCase;
26
27
/**
28
 * @package Tests
29
 * @group operation
30
 */
31
class RoundCornersTest extends WideImage_TestCase
32
{
33
	public function testWhiteCorner()
34
	{
35
		$img = WideImage::load(IMG_PATH . '100x100-color-hole.png');
36
		$res = $img->roundCorners(30, $img->allocateColor(255, 255, 255), WideImage::SIDE_ALL);
37
		
38
		$this->assertEquals(100, $res->getWidth());
39
		$this->assertEquals(100, $res->getHeight());
40
		
41
		$this->assertRGBAt($res, 5, 5, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 0));
42
		$this->assertRGBAt($res, 95, 5, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 0));
43
		$this->assertRGBAt($res, 95, 95, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 0));
44
		$this->assertRGBAt($res, 5, 95, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 0));
45
	}
46
	
47
	public function testTransparentCorner()
48
	{
49
		$img = WideImage::load(IMG_PATH . '100x100-blue-alpha.png');
50
		$res = $img->roundCorners(30, null, WideImage::SIDE_ALL);
51
		
52
		$this->assertEquals(100, $res->getWidth());
53
		$this->assertEquals(100, $res->getHeight());
54
		
55
		$this->assertRGBAt($res, 5, 5, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127));
56
		$this->assertRGBAt($res, 95, 5, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127));
57
		$this->assertRGBAt($res, 95, 95, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127));
58
		$this->assertRGBAt($res, 5, 95, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127));
59
	}
60
}
61