Passed
Push — master ( bbe808...4a0efd )
by Radosław
02:19
created

ItemTest::testArrayRepresentation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
namespace Radowoj\Searcher\SearchResult;
4
5
use PHPUnit\Framework\TestCase;
6
use Radowoj\Searcher\SearchResult\Item;
7
use Radowoj\Searcher\SearchResult\IItem;
8
9
class ItemTest extends TestCase
10
{
11
    public function testInstantiation()
12
    {
13
        $item = new Item([]);
14
        $this->assertInstanceOf(IItem::class, $item);
15
    }
16
17
18
    public function testArrayRepresentation()
19
    {
20
        $array = [
21
            'url' => 'http://example.com',
22
            'title' => 'some title',
23
            'description' => 'some description',
24
        ];
25
26
        $item = new Item($array);
27
28
        $this->assertSame($array, $item->toArray());
29
    }
30
31
32
    public function testToString()
33
    {
34
        $url = 'http://example.com';
35
        $item = new Item(['url' => $url]);
36
        $this->assertSame($url, (string)$item);
37
    }
38
39
    /**
40
     * @expectedException InvalidArgumentException
41
     * @expectedExceptionMessage Invalid URL given:
42
     */
43
    public function testInvalidUrl()
44
    {
45
        $url = 'some invalid url';
46
        $item = new Item(['url' => $url]);
0 ignored issues
show
Unused Code introduced by
$item is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

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.

Loading history...
47
    }
48
}
49