18declare(strict_types=1);
24use PHPUnit\Framework\MockObject\MockObject;
25use PHPUnit\Framework\Attributes\DataProvider;
27require_once(__DIR__ .
"/../../../../../../../../vendor/composer/vendor/autoload.php");
28require_once(__DIR__ .
"/../../../../Base.php");
44 protected function setUp(): void
50 $this->glyph_factory->method($this->anything())->willReturn($this->glyph_stub);
53 $this->icon_factory->method(
'standard')->willReturn($this->icon_stub);
55 $this->symbol_factory = $this->createMock(
Component\
Symbol\Factory::class);
56 $this->symbol_factory->method(
'glyph')->willReturn($this->glyph_factory);
57 $this->symbol_factory->method(
'icon')->willReturn($this->icon_factory);
64 array $with_stub_renderings = [],
65 array $with_additional_contexts = [],
67 $with_stub_renderings = array_merge($with_stub_renderings, [
72 return parent::getDefaultRenderer($js_binding, $with_stub_renderings, $with_additional_contexts);
77 return new class ($this->symbol_factory) extends \
NoUIFactory {
84 return $this->symbol_factory;
91 $node_id =
'some-existing-node-id';
92 $node_name =
'some existing node name';
94 [$child_node_stub, $child_node_html] = $this->createSimpleRenderingStub(Field\Node\Leaf::class);
96 $component = $this->getNodeFactory()->branch([$node_id], $node_name,
null, $child_node_stub);
97 $renderer = $this->getDefaultRenderer(
null, [$child_node_stub]);
100<li data-node-
id=
"$node_id" class=
"c-input-node c-input-node__branch c-drilldown__branch">
101 <
button type=
"button" class=
"c-drilldown__menulevel--trigger" aria-expanded=
"false">
102 <span> $this->icon_html<span data-node-name>$node_name</span></span>
103 <span> $this->glyph_html</span>
105 <
button type=
"button" class=
"c-input-node__select" aria-label=
"select_node">
106 <span data-action=
"select">$this->glyph_html</span>
107 <span
class=
"hidden" data-action=
"remove">$this->glyph_html</span>
109 <ul> $child_node_html</ul>
116 $this->brutallyTrimHTML($expected),
117 $this->brutallyTrimHTML($actual),
123 $component = $this->getNodeFactory()->branch([
''],
'');
128 $this->assertTrue(str_contains($this->brutallyTrimHTML($actual),
"<ul></ul>"));
133 [$icon_stub, $icon_html] = $this->createSimpleRenderingStub(
Component\
Symbol\
Icon\Custom::class);
135 $component = $this->getNodeFactory()->branch([
''],
'');
136 $renderer = $this->getDefaultRenderer(
null, [$icon_stub]);
140 $this->assertTrue(str_contains($actual, $icon_html));
145 $first_node_name_letter =
's';
146 $node_name =
"{$first_node_name_letter}ome existing node name";
148 $this->icon_factory->expects($this->once())->method(
'standard');
149 $this->icon_stub->expects($this->once())->method(
'withAbbreviation')->with($first_node_name_letter);
151 $component = $this->getNodeFactory()->branch([
''], $node_name);
156 $this->assertTrue(str_contains($actual, $this->icon_html));
162 $level_one_node_id = 1;
163 $level_two_node_id = 2;
164 $parent_ids = [$root_node_id, $level_one_node_id];
165 $full_node_path = [...$parent_ids, $level_two_node_id];
167 $node = $this->getNodeFactory()->branch($full_node_path,
"");
169 $this->assertEquals($full_node_path, $node->getFullPath());
170 $this->assertEquals($parent_ids, $node->getParentIds());
171 $this->assertEquals($level_two_node_id, $node->getId());
174 #[DataProvider('provideInvalidNodePaths')]
177 $this->expectException(\InvalidArgumentException::class);
178 $this->getNodeFactory()->branch(
$path,
"");
211 $stub = $this->createMock($class_name);
212 $html = sha1($class_name);
213 $stub->method(
'getCanonicalName')->willReturn($html);
214 $stub->method($this->anything())->willReturnSelf();
215 return [$stub, $html];
getDefaultRenderer(?JavaScriptBinding $js_binding=null, array $with_stub_renderings=[], array $with_additional_contexts=[],)
static provideInvalidNodePaths()
testConstructorWithInvalidNodePath(array $path)
testRenderWithoutChildren()
createSimpleRenderingStub(string $class_name)
testConstructorWithValidNodePath()
Component Symbol Icon Factory &MockObject $icon_factory
Component Symbol Icon Icon &MockObject $icon_stub
Component Symbol Glyph Factory &MockObject $glyph_factory
Component Symbol Factory &MockObject $symbol_factory
Component Symbol Glyph Glyph &MockObject $glyph_stub
Provides common functionality for UI tests.
Provides methods to interface with javascript.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
button(string $caption, string $cmd)