| 1 | <?php |
||
| 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 |