ImageTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 56
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A itThrowsForMissingImage() 0 4 1
A itThrowsForInvalidImage() 0 4 1
A itCreatesImages() 0 17 1
A itDerivesDifferences() 0 11 1
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) {
0 ignored issues
show
Unused Code introduced by
The parameter $p is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $q is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
62
            return 0;
63
        };
64
65
        $this->assertInstanceOf(Difference::class, $image1->difference($image2, $method));
66
    }
67
}