ILIAS  release_7 Revision v7.30-3-g800a261c036
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 class extends NoUIFactory {
19 public function breadcrumbs(array $crumbs)
20 {
21 return new I\Component\Breadcrumbs\Breadcrumbs($crumbs);
22 }
23 };
24 }
25
27 {
28 $f = $this->getFactory();
29 $c = $f->breadcrumbs(array());
30
31 $this->assertInstanceOf("ILIAS\\UI\\Factory", $f);
32 $this->assertInstanceOf(
33 "ILIAS\\UI\\Component\\Breadcrumbs\\Breadcrumbs",
34 $f->breadcrumbs(array())
35 );
36 }
37
38 public function testCrumbs()
39 {
40 $f = $this->getFactory();
41 $crumbs = array(
42 new I\Component\Link\Standard("label", '#'),
43 new I\Component\Link\Standard("label2", '#')
44 );
45
46 $c = $f->breadcrumbs($crumbs);
47 $this->assertEquals($crumbs, $c->getItems());
48 }
49
50 public function testAppending()
51 {
52 $f = $this->getFactory();
53 $crumb = new I\Component\Link\Standard("label2", '#');
54
55 $c = $f->Breadcrumbs(array())
56 ->withAppendedItem($crumb);
57 $this->assertEquals(array($crumb), $c->getItems());
58 }
59
60 public function testRendering()
61 {
62 $f = $this->getFactory();
63 $r = $this->getDefaultRenderer();
64
65 $crumbs = array(
66 new I\Component\Link\Standard("label", '#'),
67 new I\Component\Link\Standard("label2", '#')
68 );
69 $c = $f->Breadcrumbs($crumbs);
70
71 $html = $this->normalizeHTML($r->render($c));
72 $expected = '<nav aria-label="breadcrumbs_aria_label" class="breadcrumb_wrapper">'
73 . ' <div class="breadcrumb">'
74 . ' <span class="crumb">'
75 . ' <a href="#">label</a>'
76 . ' </span>'
77 . ' <span class="crumb">'
78 . ' <a href="#">label2</a>'
79 . ' </span>'
80 . ' </div>'
81 . '</nav>';
82
83 $this->assertHTMLEquals($expected, $html);
84 }
85}
breadcrumbs()
Definition: breadcrumbs.php:2
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:263
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
normalizeHTML($html)
Definition: Base.php:363
$c
Definition: cli.php:37