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");
46 protected function setUp(): void
48 $this->uri_string = sha1(\
ILIAS\
Data\URI::class);
49 $this->uri_stub = $this->createMock(\
ILIAS\
Data\URI::class);
50 $this->uri_stub->method(
'__toString')->willReturn($this->uri_string);
56 $this->glyph_factory->method($this->anything())->willReturn($this->glyph_stub);
59 $this->icon_factory->method(
'standard')->willReturn($this->icon_stub);
61 $this->symbol_factory = $this->createMock(
Component\
Symbol\Factory::class);
62 $this->symbol_factory->method(
'glyph')->willReturn($this->glyph_factory);
63 $this->symbol_factory->method(
'icon')->willReturn($this->icon_factory);
70 array $with_stub_renderings = [],
71 array $with_additional_contexts = [],
73 $with_stub_renderings = array_merge($with_stub_renderings, [
78 return parent::getDefaultRenderer($js_binding, $with_stub_renderings, $with_additional_contexts);
83 return new class ($this->symbol_factory) extends \
NoUIFactory {
90 return $this->symbol_factory;
97 $node_id =
'some-existing-node-id';
98 $node_name =
'some existing node name';
100 $component = $this->getNodeFactory()->async($this->uri_stub, [$node_id], $node_name);
104<li data-node-
id=
"$node_id" class=
"c-input-node c-input-node__async c-drilldown__branch" data-render-url=
"$this->uri_string">
105 <
button type=
"button" class=
"c-drilldown__menulevel--trigger" aria-expanded=
"false">
106 <span> $this->icon_html<span data-node-name>$node_name</span></span>
107 <span> $this->glyph_html</span>
109 <
button type=
"button" class=
"c-input-node__select" aria-label=
"select_node">
110 <span data-action=
"select">$this->glyph_html</span>
111 <span
class=
"hidden" data-action=
"remove">$this->glyph_html</span>
120 $this->brutallyTrimHTML($expected),
121 $this->brutallyTrimHTML($actual),
127 [$icon_stub, $icon_html] = $this->createSimpleRenderingStub(
Component\
Symbol\
Icon\Custom::class);
129 $component = $this->getNodeFactory()->async($this->uri_stub, [
''], $icon_stub);
130 $renderer = $this->getDefaultRenderer(
null, [$icon_stub]);
134 $this->assertTrue(str_contains($actual, $icon_html));
139 $first_node_name_letter =
's';
140 $node_name =
"{$first_node_name_letter}ome existing node name";
142 $this->icon_factory->expects($this->once())->method(
'standard');
143 $this->icon_stub->expects($this->once())->method(
'withAbbreviation')->with($first_node_name_letter);
145 $component = $this->getNodeFactory()->async($this->uri_stub, [
''], $node_name);
150 $this->assertTrue(str_contains($actual, $this->icon_html));
156 $level_one_node_id = 1;
157 $level_two_node_id = 2;
158 $parent_ids = [$root_node_id, $level_one_node_id];
159 $full_node_path = [...$parent_ids, $level_two_node_id];
161 $node = $this->getNodeFactory()->async($this->uri_stub, $full_node_path,
"");
163 $this->assertEquals($full_node_path, $node->getFullPath());
164 $this->assertEquals($parent_ids, $node->getParentIds());
165 $this->assertEquals($level_two_node_id, $node->getId());
168 #[DataProvider('provideInvalidNodePaths')]
171 $this->expectException(\InvalidArgumentException::class);
172 $this->getNodeFactory()->async($this->uri_stub,
$path,
"");
205 $stub = $this->createMock($class_name);
206 $html = sha1($class_name);
207 $stub->method(
'getCanonicalName')->willReturn($html);
208 $stub->method($this->anything())->willReturnSelf();
209 return [$stub, $html];
Component Symbol Icon Icon &MockObject $icon_stub
createSimpleRenderingStub(string $class_name)
testConstructorWithValidNodePath()
testConstructorWithInvalidNodePath(array $path)
Component Symbol Icon Factory &MockObject $icon_factory
ILIAS Data URI &MockObject $uri_stub
static provideInvalidNodePaths()
getDefaultRenderer(?JavaScriptBinding $js_binding=null, array $with_stub_renderings=[], array $with_additional_contexts=[],)
Component Symbol Glyph Factory &MockObject $glyph_factory
Component Symbol Glyph Glyph &MockObject $glyph_stub
Component Symbol Factory &MockObject $symbol_factory
Provides common functionality for UI tests.
Provides methods to interface with javascript.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
button(string $caption, string $cmd)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.