|
1
|
|
|
<?php |
|
2
|
|
|
namespace HtImgModuleTest\Imagine\Filter; |
|
3
|
|
|
|
|
4
|
|
|
use Imagine\Gd\Imagine; |
|
5
|
|
|
use HtImgModule\Imagine\Filter\Watermark; |
|
6
|
|
|
|
|
7
|
|
|
class WatermarkTest 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
|
|
|
$watermark = new Watermark($archos, '50%'); |
|
15
|
|
|
$newImage = $watermark->apply($flowers); |
|
|
|
|
|
|
16
|
|
|
$watermark = new Watermark($archos, '50%', 'right'); |
|
17
|
|
|
$newImage = $watermark->apply($flowers); |
|
|
|
|
|
|
18
|
|
|
//$newImage->save('resources/watermark.jpg'); |
|
|
|
|
|
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
public function testGetExceptionWithInvalidPosition() |
|
22
|
|
|
{ |
|
23
|
|
|
$this->setExpectedException('HtImgModule\Exception\InvalidArgumentException'); |
|
|
|
|
|
|
24
|
|
|
$imagine = new Imagine(); |
|
25
|
|
|
$archos = $imagine->open('resources/Archos.jpg'); |
|
26
|
|
|
$flowers = $imagine->open('resources/flowers.jpg'); |
|
27
|
|
|
$watermark = new Watermark($archos, null, 'asdf'); |
|
28
|
|
|
$newImage = $watermark->apply($flowers); |
|
|
|
|
|
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function testGetExceptionWithInvalidWatermarkSize() |
|
32
|
|
|
{ |
|
33
|
|
|
$this->setExpectedException('HtImgModule\Exception\InvalidArgumentException'); |
|
|
|
|
|
|
34
|
|
|
$imagine = new Imagine(); |
|
35
|
|
|
$archos = $imagine->open('resources/Archos.jpg'); |
|
36
|
|
|
$watermark = new Watermark($archos, 'asfd', 'asdf'); |
|
|
|
|
|
|
37
|
|
|
} |
|
38
|
|
|
} |
|
39
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.