Completed
Push — master ( 79027c...8f1f38 )
by Oleg
03:47
created

LinkTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 4
1
<?php
2
namespace Malezha\Menu\Tests\ElementTests;
3
4
use Malezha\Menu\Contracts\Attributes;
5
use Malezha\Menu\Factory\LinkFactory;
6
use Malezha\Menu\Tests\TestCase;
7
8
/**
9
 * Class LinkTest
10
 * @package Malezha\Menu\Tests\ElementTests
11
 */
12
class LinkTest extends TestCase
13
{
14
    /**
15
     * @return LinkFactory
16
     */
17
    protected function factory()
18
    {
19
        return new LinkFactory($this->app);
20
    }
21
    
22
    protected function elementRender()
23
    {
24
        return "<li class=\"link\"><a href=\"/news\">News</a></li>\n";
25
    }
26
27
    protected function serializeStub()
28
    {
29
        return $this->getStub('serialized/link_element.txt');
30
    }
31
    
32
    public function testFactory()
33
    {
34
        $factory = $this->factory();
35
        $factory->title = 'Title';
36
        
37
        $this->assertEquals('Title', $factory->title);
38
        $this->assertInstanceOf(Attributes::class, $factory->attributes);
39
        
40
        $link = $factory->build(['title' => 'New title']);
41
        $this->assertEquals('New title', $link->title);
42
    }
43
    
44
    public function testElement()
45
    {
46
        $factory = $this->factory();
47
        $factory->title = 'News';
48
        $factory->url = '/news';
49
        $link = $factory->build();
50
        $link->attributes->put('class', 'link');
51
        
52
        $html = $link->render();
53
        $this->assertEquals($this->elementRender(), $html);
54
    }
55
}