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