Completed
Push — master ( 363ead...e52e2c )
by Oleg
06:33
created

ItemTest::itemFactory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 20
rs 9.4285
cc 1
eloc 14
nc 1
nop 0
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
}