ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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;
9
14{
15 public function getFactory()
16 {
17 return new \ILIAS\UI\Implementation\Factory();
18 }
19
21 {
22 $f = $this->getFactory();
23 $c = $f->Breadcrumbs(array());
24
25 $this->assertInstanceOf("ILIAS\\UI\\Factory", $f);
26 $this->assertInstanceOf(
27 "ILIAS\\UI\\Component\\Breadcrumbs\\Breadcrumbs",
28 $f->Breadcrumbs(array())
29 );
30 }
31
32 public function testCrumbs()
33 {
34 $f = $this->getFactory();
35 $crumbs = array(
36 $f->link()->standard("label", '#'),
37 $f->link()->standard("label2", '#')
38 );
39
40 $c = $f->Breadcrumbs($crumbs);
41 $this->assertEquals($crumbs, $c->getItems());
42 }
43
44 public function testAppending()
45 {
46 $f = $this->getFactory();
47 $crumb = $f->link()->standard("label", '#');
48
49 $c = $f->Breadcrumbs(array())
50 ->withAppendedItem($crumb);
51 $this->assertEquals(array($crumb), $c->getItems());
52 }
53
54 public function testRendering()
55 {
56 $f = $this->getFactory();
57 $r = $this->getDefaultRenderer();
58
59 $crumbs = array(
60 $f->link()->standard("label", '#'),
61 $f->link()->standard("label2", '#')
62 );
63 $c = $f->Breadcrumbs($crumbs);
64
65 $html = $this->normalizeHTML($r->render($c));
66 $expected = '<nav role="navigation" aria-label="breadcrumbs">'
67 . ' <ul class="breadcrumb">'
68 . ' <li class="crumb">'
69 . ' <a href="#">label</a>'
70 . ' </li>'
71 . ' <li class="crumb">'
72 . ' <a href="#">label2</a>'
73 . ' </li>'
74 . ' </ul>'
75 . '</nav>';
76
77 $this->assertHTMLEquals($expected, $html);
78 }
79}
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:178
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:252
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:216
normalizeHTML($html)
Definition: Base.php:243
$html
Definition: example_001.php:87
$r
Definition: example_031.php:79