18 declare(strict_types=1);
26 require_once(__DIR__ .
"/../../../../../../../vendor/composer/vendor/autoload.php");
27 require_once(__DIR__ .
"/../../../Base.php");
28 require_once(__DIR__ .
"/InputTest.php");
37 protected Component\Link\Standard & MockObject
$link_stub;
47 protected function setUp(): void
56 $this->menu_factory = $this->createMock(
Component\
Menu\Factory::class);
57 $this->menu_factory->method(
'drilldown')->willReturn($this->drilldown_stub);
64 array $with_stub_renderings = [],
65 array $with_additional_contexts = [],
67 $with_stub_renderings = array_merge($with_stub_renderings, [
69 $this->drilldown_stub,
70 $this->breadcrumbs_stub,
73 return parent::getDefaultRenderer($js_binding, $with_stub_renderings, $with_additional_contexts);
78 $icon_factory = $this->createMock(
Component\Symbol\
Icon\Factory::class);
79 $glyph_factory = $this->createMock(
Component\Symbol\
Glyph\Factory::class);
80 $glyph_mock = $this->createMock(
Component\Symbol\
Glyph\Glyph::class);
81 $glyph_factory->method($this->anything())->willReturn($glyph_mock);
82 $symbol_factory = $this->createMock(
Component\Symbol\Factory::class);
83 $symbol_factory->method(
'icon')->willReturn($icon_factory);
86 $button_factory->method(
'bulky')->willReturn($this->bulky_stub);
88 $link_factory = $this->createMock(
Component\
Link\Factory::class);
89 $link_factory->method(
'standard')->willReturn($this->link_stub);
91 $node_factory = $this->createMock(Field\Node\Factory::class);
92 $field_factory = $this->createMock(Field\Factory::class);
93 $field_factory->method(
'node')->willReturn($node_factory);
94 $input_factory = $this->createMock(
Component\
Input\Factory::class);
95 $input_factory->method(
'field')->willReturn($field_factory);
111 protected Component\Breadcrumbs\Breadcrumbs $breadcrumbs,
114 public function button(): Component\Button\Factory
116 return $this->button_factory;
118 public function breadcrumbs(array $crumbs): Component\Breadcrumbs\Breadcrumbs
120 return $this->breadcrumbs;
122 public function symbol(): Component\Symbol\Factory
124 return $this->symbol_factory;
126 public function link(): Component\Link\Factory
128 return $this->link_factory;
130 public function input(): Component\Input\Factory
132 return $this->input_factory;
134 public function menu(): Component\Menu\Factory
145 $component = $this->
getFieldFactory()->treeSelect($node_retrieval,
'');
146 $this->expectException(InvalidArgumentException::class);
147 $component = $component->withValue($value);
154 $component = $this->
getFieldFactory()->treeSelect($node_retrieval,
'');
155 $component = $component->withValue($value);
156 $this->assertEquals([$value], $component->getValue());
161 $node_id =
'some-existing-node-id';
162 $node_name =
'some existing node';
164 [$leaf_stub,] = $this->
getLeafStub($node_id, $node_name);
168 $component = $this->
getFieldFactory()->treeSelect($node_retrieval,
'');
169 $component = $component->withValue($node_id);
173 $expected_html = <<<HTML
174 <li data-node-
id=
"$node_id">
175 <span data-node-name>$node_name</span>
176 <
button data-action=
"remove" type=
"button" class=
"close" aria-label=
"unselect_node">
177 <span aria-hidden=
"true">×</span>
179 <input
id=
"id_2" type=
"hidden" value=
"$node_id" />
183 $actual_html =
$renderer->render($component);
187 $this->brutallyTrimHTML($actual_html),
188 $this->brutallyTrimHTML($expected_html),
197 $component = $this->
getFieldFactory()->treeSelect($node_retrieval,
'');
198 $component = $component->withDisabled(
true);
202 $expected_html = <<<HTML
203 <input
id=
"id_2" type=
"button" aria-label=
"select" value=
"select" disabled>
206 $actual_html =
$renderer->render($component);
210 $this->brutallyTrimHTML($actual_html),
211 $this->brutallyTrimHTML($expected_html),
220 $component = $this->
getFieldFactory()->treeSelect($node_retrieval,
'');
221 $component = $component->withRequired(
true);
225 $expected_html = <<<HTML
226 <label
for=
"id_2"><span
class=
"asterisk" aria-label=
"required_field">*</span></label>
229 $actual_html =
$renderer->render($component);
233 $this->brutallyTrimHTML($actual_html),
234 $this->brutallyTrimHTML($expected_html),
245 $tree_select_label =
'some tree select label';
249 $component = $this->
getFieldFactory()->treeSelect($node_retrieval, $tree_select_label);
254 $expected_html = <<<HTML
255 <fieldset
class=
"c-input" data-il-
ui-component=
"tree-select-field-input" data-il-
ui-input-name=
"name_0">
256 <label
for=
"id_3">some tree select label</label>
257 <div
class=
"c-input__field">
258 <div
class=
"c-input-tree_select">
259 <dialog
class=
"c-modal">
260 <div
class=
"modal-dialog" role=
"document">
261 <div
class=
"modal-content">
262 <div
class=
"modal-header">
263 <
button data-action=
"close" type=
"button" class=
"close" aria-label=
"close">
264 <span aria-hidden=
"true">×</span>
266 <h1
class=
"modal-title">$tree_select_label</h1>
268 <div
class=
"modal-body">
269 <
template>$this->breadcrumbs_html</
template>
270 $this->breadcrumbs_html
271 <section
class=
"c-drilldown" id=
"id_2">
272 <
header class=
"c-drilldown__header--showbacknav">
275 <div
class=
"c-drilldown__backnav"> $this->bulky_html</div>
277 <div
class=
"c-drilldown__menu">
278 <ul aria-live=
"polite" aria-label=
"$tree_select_label">
280 <li
class=
"c-drilldown__menu--no-items"> drilldown_no_items</li>
285 <div
class=
"modal-footer">
286 <
button data-action=
"close" type=
"button" class=
"btn btn-default" aria-label=
"close">
close</
button>
287 <
button data-action=
"close" type=
"button" class=
"btn btn-primary" aria-label=
"select">select</
button>
292 <ul
class=
"c-input-tree_select__selection">
295 <span data-node-name></span>
296 <
button data-action=
"remove" type=
"button" class=
"close" aria-label=
"">
297 <span aria-hidden=
"true">×</span>
299 <input
id=
"id_1" type=
"hidden" name=
"name_0[input_0][]" value=
"" /></li>
302 <input
id=
"id_3" type=
"button" aria-label=
"select" value=
"select">
308 $actual_html =
$renderer->render($component);
311 $this->brutallyTrimHTML($expected_html),
312 $this->brutallyTrimHTML($actual_html),
341 return new Component\Menu\Factory($this->signal_generator);
346 return new Field\Factory(
347 ($node_factory) ?: $this->createMock(Field\Node\Factory::class),
349 $this->signal_generator,
351 $this->getRefinery(),
362 $node_retrieval = $this->createMock(NodeRetrieval::class);
363 $node_retrieval->method(
'getNodes')->willReturnCallback(
static fn() => yield
from $node_stubs);
364 $node_retrieval->method(
'getNodesAsLeaf')->willReturnCallback(
static fn() => yield
from $leaf_stubs);
365 return $node_retrieval;
371 $stub = $this->createMock(Field\Node\Leaf::class);
372 $html = sha1(Field\Node\Leaf::class);
373 $stub->method(
'getCanonicalName')->willReturn($html);
374 $stub->method(
'getId')->willReturn(
$id);
375 $stub->method(
'getName')->willReturn($name);
376 return [$stub, $html];
406 $stub = $this->createMock($class_name);
407 $html = sha1($class_name);
408 $stub->method(
'getCanonicalName')->willReturn($html);
409 $stub->method($this->anything())->willReturnSelf();
410 return [$stub, $html];
button(string $caption, string $cmd)
getFieldFactory(?Field\Node\Factory $node_factory=null)
Component Breadcrumbs Breadcrumbs &MockObject $breadcrumbs_stub
static getInvalidArgumentsForWithValue()
testWithValueForValidArguments(string|int|null $value)
getValidArgumentsForWithValue
Component Menu Drilldown &MockObject $drilldown_stub
Component Menu Factory $menu_factory
Component Link Standard &MockObject $link_stub
getLeafStub(string|int $id='', string $name='')
Component Button Bulky &MockObject $bulky_stub
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Provides common functionality for UI tests.
close()
description: > Example for rendring a close glyph.
getNodeRetrieval(array $node_stubs=[], array $leaf_stubs=[])
Provides methods to interface with javascript.
Component SignalGeneratorInterface $signal_generator
createSimpleRenderingStub(string $class_name)
static getValidArgumentsForWithValue()
testRenderDrilldownMenu()
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__construct(Container $dic, ilPlugin $plugin)
getDefaultRenderer(?JavaScriptBinding $js_binding=null, array $with_stub_renderings=[], array $with_additional_contexts=[],)
testWithValueForInvalidArguments(mixed $value)
getInvalidArgumentsForWithValue
link(string $caption, string $href, bool $new_viewport=false)
breadcrumbs()
description: > Example showing how to construct Breadcrumbs with an array of Links and extending the...