1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Malezha\Menu\Tests; |
4
|
|
|
|
5
|
|
|
use Malezha\Menu\Contracts\Attributes; |
6
|
|
|
use Malezha\Menu\Contracts\Builder; |
7
|
|
|
use Malezha\Menu\Contracts\Item; |
8
|
|
|
use Malezha\Menu\Contracts\Link; |
9
|
|
|
|
10
|
|
|
class ItemTest extends TestCase |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @return Item |
14
|
|
|
*/ |
15
|
|
|
protected function itemFactory() |
16
|
|
|
{ |
17
|
|
|
$builder = $this->app->make(Builder::class, [ |
18
|
|
|
'name' => 'test', |
19
|
|
|
'activeAttributes' => ['class' => 'active'], |
20
|
|
|
]); |
21
|
|
|
$link = $this->app->make(Link::class, [ |
22
|
|
|
'title' => 'Index', |
23
|
|
|
'url' => '/index', |
24
|
|
|
'attributes' => $this->app->make(Attributes::class, ['attributes' => ['class' => 'link']]), |
25
|
|
|
]); |
26
|
|
|
$item = $this->app->make(Item::class, [ |
27
|
|
|
'builder' => $builder, |
28
|
|
|
'attributes' => $this->app->make(Attributes::class, ['attributes' => []]), |
29
|
|
|
'link' => $link, |
30
|
|
|
'request' => $this->app->make('request'), |
31
|
|
|
]); |
32
|
|
|
|
33
|
|
|
return $item; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function testLink() |
37
|
|
|
{ |
38
|
|
|
$item = $this->itemFactory(); |
39
|
|
|
|
40
|
|
|
$this->assertInstanceOf(Link::class, $item->getLink()); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testBuildAttributes() |
44
|
|
|
{ |
45
|
|
|
$item = $this->itemFactory(); |
46
|
|
|
|
47
|
|
|
$this->assertInternalType('string', $item->buildAttributes()); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testIsActiveUrl() |
51
|
|
|
{ |
52
|
|
|
$item = $this->itemFactory(); |
53
|
|
|
|
54
|
|
|
$this->assertEquals(' class="active"', $item->buildAttributes()); |
55
|
|
|
} |
56
|
|
|
} |