ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
BreadcrumbsTest.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2017 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
5require_once("libs/composer/vendor/autoload.php");
6require_once(__DIR__ . "/../../Base.php");
7
8use \ILIAS\UI\Component as C;
9use \ILIAS\UI\Implementation as I;
10
15{
16 public function getFactory()
17 {
18 return new \ILIAS\UI\Implementation\Factory(
19 $this->createMock(C\Counter\Factory::class),
20 $this->createMock(C\Glyph\Factory::class),
21 $this->createMock(C\Button\Factory::class),
22 $this->createMock(C\Listing\Factory::class),
23 $this->createMock(C\Image\Factory::class),
24 $this->createMock(C\Panel\Factory::class),
25 $this->createMock(C\Modal\Factory::class),
26 $this->createMock(C\Dropzone\Factory::class),
27 $this->createMock(C\Popover\Factory::class),
28 $this->createMock(C\Divider\Factory::class),
29 $this->createMock(C\Link\Factory::class),
30 $this->createMock(C\Dropdown\Factory::class),
31 $this->createMock(C\Item\Factory::class),
32 $this->createMock(C\Icon\Factory::class),
33 $this->createMock(C\ViewControl\Factory::class),
34 $this->createMock(C\Chart\Factory::class),
35 $this->createMock(C\Input\Factory::class),
36 $this->createMock(C\Table\Factory::class),
37 $this->createMock(C\MessageBox\Factory::class),
38 $this->createMock(C\Card\Factory::class)
39 );
40 }
41
43 {
44 $f = $this->getFactory();
45 $c = $f->Breadcrumbs(array());
46
47 $this->assertInstanceOf("ILIAS\\UI\\Factory", $f);
48 $this->assertInstanceOf(
49 "ILIAS\\UI\\Component\\Breadcrumbs\\Breadcrumbs",
50 $f->Breadcrumbs(array())
51 );
52 }
53
54 public function testCrumbs()
55 {
56 $f = $this->getFactory();
57 $crumbs = array(
58 new I\Component\Link\Standard("label", '#'),
59 new I\Component\Link\Standard("label2", '#')
60 );
61
62 $c = $f->Breadcrumbs($crumbs);
63 $this->assertEquals($crumbs, $c->getItems());
64 }
65
66 public function testAppending()
67 {
68 $f = $this->getFactory();
69 $crumb = new I\Component\Link\Standard("label2", '#');
70
71 $c = $f->Breadcrumbs(array())
72 ->withAppendedItem($crumb);
73 $this->assertEquals(array($crumb), $c->getItems());
74 }
75
76 public function testRendering()
77 {
78 $f = $this->getFactory();
79 $r = $this->getDefaultRenderer();
80
81 $crumbs = array(
82 new I\Component\Link\Standard("label", '#'),
83 new I\Component\Link\Standard("label2", '#')
84 );
85 $c = $f->Breadcrumbs($crumbs);
86
87 $html = $this->normalizeHTML($r->render($c));
88 $expected = '<nav role="navigation" aria-label="breadcrumbs">'
89 . ' <ul class="breadcrumb">'
90 . ' <li class="crumb">'
91 . ' <a href="#">label</a>'
92 . ' </li>'
93 . ' <li class="crumb">'
94 . ' <a href="#">label2</a>'
95 . ' </li>'
96 . ' </ul>'
97 . '</nav>';
98
99 $this->assertHTMLEquals($expected, $html);
100 }
101}
Tests for the Breadcrumbs-component.
An exception for terminatinating execution or to throw for unit testing.
Provides common functionality for UI tests.
Definition: Base.php:192
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
$html
Definition: example_001.php:87
$r
Definition: example_031.php:79