Passed
Push — master ( 4a0efd...7f5941 )
by Radosław
02:22
created

ItemTest::testInvalidProperty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
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
    /**
41
     * @expectedException InvalidArgumentException
42
     * @expectedExceptionMessage Invalid URL given:
43
     */
44
    public function testInvalidUrl()
45
    {
46
        $url = 'some invalid url';
47
        new Item(['url' => $url]);
48
    }
49
50
51
    /**
52
     * @expectedException InvalidArgumentException
53
     * @expectedExceptionMessage Invalid search result item property
54
     */
55
    public function testInvalidProperty()
56
    {
57
        new Item(['someInvalidProperty' => 'some value']);
58
    }
59
}
60