ILIAS  release_8 Revision v8.24
BreadcrumbsTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21require_once("libs/composer/vendor/autoload.php");
22require_once(__DIR__ . "/../../Base.php");
23
26
31{
32 public function getFactory(): NoUIFactory
33 {
34 return new class () extends NoUIFactory {
35 public function breadcrumbs(array $crumbs): C\Breadcrumbs\Breadcrumbs
36 {
37 return new I\Component\Breadcrumbs\Breadcrumbs($crumbs);
38 }
39 };
40 }
41
42 public function test_implements_factory_interface(): void
43 {
44 $f = $this->getFactory();
45
46 $this->assertInstanceOf("ILIAS\\UI\\Factory", $f);
47 $this->assertInstanceOf(
48 "ILIAS\\UI\\Component\\Breadcrumbs\\Breadcrumbs",
49 $f->breadcrumbs(array())
50 );
51 }
52
53 public function testCrumbs(): void
54 {
55 $f = $this->getFactory();
56 $crumbs = array(
57 new I\Component\Link\Standard("label", '#'),
58 new I\Component\Link\Standard("label2", '#')
59 );
60
61 $c = $f->breadcrumbs($crumbs);
62 $this->assertEquals($crumbs, $c->getItems());
63 }
64
65 public function testAppending(): void
66 {
67 $f = $this->getFactory();
68 $crumb = new I\Component\Link\Standard("label2", '#');
69
70 $c = $f->Breadcrumbs(array())
71 ->withAppendedItem($crumb);
72 $this->assertEquals(array($crumb), $c->getItems());
73 }
74
75 public function testRendering(): void
76 {
77 $f = $this->getFactory();
78 $r = $this->getDefaultRenderer();
79
80 $crumbs = array(
81 new I\Component\Link\Standard("label", '#'),
82 new I\Component\Link\Standard("label2", '#')
83 );
84 $c = $f->Breadcrumbs($crumbs);
85
86 $html = $this->normalizeHTML($r->render($c));
87 $expected = '<nav aria-label="breadcrumbs_aria_label" class="breadcrumb_wrapper">'
88 . ' <div class="breadcrumb">'
89 . ' <span class="crumb">'
90 . ' <a href="#">label</a>'
91 . ' </span>'
92 . ' <span class="crumb">'
93 . ' <a href="#">label2</a>'
94 . ' </span>'
95 . ' </div>'
96 . '</nav>';
97
98 $this->assertHTMLEquals($expected, $html);
99 }
100}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Provides common functionality for UI tests.
Definition: Base.php:299
normalizeHTML(string $html)
Definition: Base.php:422
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
$c
Definition: cli.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...