1
|
|
|
<?php |
2
|
|
|
namespace HtImgModuleTest\Imagine\Filter; |
3
|
|
|
|
4
|
|
|
use Imagine\Gd\Imagine; |
5
|
|
|
use HtImgModule\Imagine\Filter\Paste; |
6
|
|
|
|
7
|
|
|
class PasteTest extends \PHPUnit_Framework_TestCase |
8
|
|
|
{ |
9
|
|
|
public function testFilter() |
10
|
|
|
{ |
11
|
|
|
$imagine = new Imagine(); |
12
|
|
|
$flowers = $imagine->open('resources/flowers.jpg'); |
13
|
|
|
$archos = $imagine->open('resources/Archos.jpg'); |
14
|
|
|
$paste = new Paste($archos, 10, 30); |
15
|
|
|
$newImage = $paste->apply($flowers); |
|
|
|
|
16
|
|
|
$paste = new Paste($archos, 'right', 'middle'); |
17
|
|
|
$newImage = $paste->apply($flowers); |
|
|
|
|
18
|
|
|
//$newImage->save('resources/paste.jpg'); |
|
|
|
|
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function testGetExceptionWithInvalidStringXCoordinate() |
22
|
|
|
{ |
23
|
|
|
$this->setExpectedException('HtImgModule\Exception\InvalidArgumentException'); |
|
|
|
|
24
|
|
|
$imagine = new Imagine(); |
|
|
|
|
25
|
|
|
$archos = $this->createMock('Imagine\Image\ImageInterface'); |
26
|
|
|
$paste = new Paste($archos, 'asdf', 'asdf'); |
|
|
|
|
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function testGetExceptionWithInvalidStringYCoordinate() |
30
|
|
|
{ |
31
|
|
|
$this->setExpectedException('HtImgModule\Exception\InvalidArgumentException'); |
|
|
|
|
32
|
|
|
$imagine = new Imagine(); |
|
|
|
|
33
|
|
|
$archos = $this->createMock('Imagine\Image\ImageInterface'); |
34
|
|
|
$paste = new Paste($archos, 546, 'asdf'); |
|
|
|
|
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testConvertStringCoordinateToNumber() |
38
|
|
|
{ |
39
|
|
|
$imagine = new Imagine(); |
40
|
|
|
$flowers = $imagine->open('resources/flowers.jpg'); |
41
|
|
|
$archos = $imagine->open('resources/Archos.jpg'); |
42
|
|
|
$paste = new Paste($archos, 'center', 'top'); |
43
|
|
|
$newImage = $paste->apply($flowers); |
|
|
|
|
44
|
|
|
$paste = new Paste($archos, 'left', 'bottom'); |
45
|
|
|
$newImage = $paste->apply($flowers); |
|
|
|
|
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testGetExceptionWIthNegativeCoordinate() |
49
|
|
|
{ |
50
|
|
|
$this->setExpectedException('HtImgModule\Exception\InvalidArgumentException'); |
|
|
|
|
51
|
|
|
$image = $this->createMock('Imagine\Image\ImageInterface'); |
52
|
|
|
$paste = new Paste($image, -100, 'top'); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.