1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Undemanding\Difference\Test; |
4
|
|
|
|
5
|
|
|
use InvalidArgumentException; |
6
|
|
|
use Undemanding\Difference\Difference; |
7
|
|
|
use Undemanding\Difference\Image; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @covers Undemanding\Difference\Image |
11
|
|
|
*/ |
12
|
|
|
class ImageTest extends Test |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @test |
16
|
|
|
*/ |
17
|
|
|
public function itCreatesImages() |
18
|
|
|
{ |
19
|
|
|
$image = new Image(__DIR__ . "/fixtures/fez-1.png"); |
20
|
|
|
|
21
|
|
|
$this->assertEquals(400, $image->getWidth()); |
22
|
|
|
$this->assertEquals(300, $image->getHeight()); |
23
|
|
|
|
24
|
|
|
$bitmap = $image->getBitmap(); |
25
|
|
|
|
26
|
|
|
$this->assertInternalType("array", $bitmap); |
27
|
|
|
$this->assertEquals(300, count($bitmap)); |
28
|
|
|
|
29
|
|
|
// test secondary types |
30
|
|
|
|
31
|
|
|
new Image(__DIR__ . "/fixtures/fez-1.jpg"); |
32
|
|
|
new Image(__DIR__ . "/fixtures/fez-1.gif"); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @test |
37
|
|
|
* @expectedException InvalidArgumentException |
38
|
|
|
*/ |
39
|
|
|
public function itThrowsForMissingImage() |
40
|
|
|
{ |
41
|
|
|
new Image("does/not/exist"); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @test |
46
|
|
|
* @expectedException InvalidArgumentException |
47
|
|
|
*/ |
48
|
|
|
public function itThrowsForInvalidImage() |
49
|
|
|
{ |
50
|
|
|
new Image(__FILE__); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @test |
55
|
|
|
*/ |
56
|
|
|
public function itDerivesDifferences() |
57
|
|
|
{ |
58
|
|
|
$image1 = new Image(__DIR__ . "/fixtures/fez-1.png"); |
59
|
|
|
$image2 = new Image(__DIR__ . "/fixtures/fez-1.png"); |
60
|
|
|
|
61
|
|
|
$method = function ($p, $q) { |
|
|
|
|
62
|
|
|
return 0; |
63
|
|
|
}; |
64
|
|
|
|
65
|
|
|
$this->assertInstanceOf(Difference::class, $image1->difference($image2, $method)); |
66
|
|
|
} |
67
|
|
|
} |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.