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 $component = $this->getNodeFactory()->leaf([$node_id], $node_name);
98<li data-node-
id=
"$node_id" class=
"c-input-node c-input-node__leaf c-drilldown__leaf">
99 <p
class=
"il-link link-bulky c-input-node__name" tabindex=
"0">
100 $this->icon_html<span data-node-name>$node_name</span>
102 <
button type=
"button" class=
"c-input-node__select" aria-label=
"select_node">
103 <span data-action=
"select">$this->glyph_html</span>
104 <span
class=
"hidden" data-action=
"remove">$this->glyph_html</span>
112 $this->brutallyTrimHTML($expected),
113 $this->brutallyTrimHTML($actual),
119 [$icon_stub, $icon_html] = $this->createSimpleRenderingStub(
Component\
Symbol\
Icon\Custom::class);
121 $component = $this->getNodeFactory()->leaf([
''],
'');
122 $renderer = $this->getDefaultRenderer(
null, [$icon_stub]);
126 $this->assertTrue(str_contains($actual, $icon_html));
131 $first_node_name_letter =
's';
132 $node_name =
"{$first_node_name_letter}ome existing node name";
134 $this->icon_factory->expects($this->once())->method(
'standard');
135 $this->icon_stub->expects($this->once())->method(
'withAbbreviation')->with($first_node_name_letter);
137 $component = $this->getNodeFactory()->leaf([
''], $node_name);
142 $this->assertTrue(str_contains($actual, $this->icon_html));
148 $level_one_node_id = 1;
149 $level_two_node_id = 2;
150 $parent_ids = [$root_node_id, $level_one_node_id];
151 $full_node_path = [...$parent_ids, $level_two_node_id];
153 $node = $this->getNodeFactory()->leaf($full_node_path,
"");
155 $this->assertEquals($full_node_path, $node->getFullPath());
156 $this->assertEquals($parent_ids, $node->getParentIds());
157 $this->assertEquals($level_two_node_id, $node->getId());
160 #[DataProvider('provideInvalidNodePaths')]
163 $this->expectException(\InvalidArgumentException::class);
164 $this->getNodeFactory()->leaf(
$path,
"");
197 $stub = $this->createMock($class_name);
198 $html = sha1($class_name);
199 $stub->method(
'getCanonicalName')->willReturn($html);
200 $stub->method($this->anything())->willReturnSelf();
201 return [$stub, $html];
Component Symbol Icon Factory &MockObject $icon_factory
createSimpleRenderingStub(string $class_name)
Component Symbol Icon Icon &MockObject $icon_stub
testConstructorWithInvalidNodePath(array $path)
Component Symbol Factory &MockObject $symbol_factory
testConstructorWithValidNodePath()
Component Symbol Glyph Factory &MockObject $glyph_factory
Component Symbol Glyph Glyph &MockObject $glyph_stub
static provideInvalidNodePaths()
getDefaultRenderer(?JavaScriptBinding $js_binding=null, array $with_stub_renderings=[], array $with_additional_contexts=[],)
Provides common functionality for UI tests.
Provides methods to interface with javascript.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
button(string $caption, string $cmd)