ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
FieldBranchNodeTest Class Reference
+ Inheritance diagram for FieldBranchNodeTest:
+ Collaboration diagram for FieldBranchNodeTest:

Public Member Functions

 getDefaultRenderer (?JavaScriptBinding $js_binding=null, array $with_stub_renderings=[], array $with_additional_contexts=[],)
 
 getUIFactory ()
 
 testRenderWithChildren ()
 
 testRenderWithoutChildren ()
 
 testRenderWithoutIcon ()
 

Static Public Member Functions

static provideInvalidNodePaths ()
 

Protected Member Functions

 setUp ()
 
 testRenderWithIcon ()
 
 testConstructorWithValidNodePath ()
 
 testConstructorWithInvalidNodePath (array $path)
 
 getNodeFactory ()
 
 getGlyphStub ()
 
 getIconStub ()
 
 createSimpleRenderingStub (string $class_name)
 

Protected Attributes

Component Symbol Glyph Glyph &MockObject $glyph_stub
 
string $glyph_html
 
Component Symbol Icon Icon &MockObject $icon_stub
 
string $icon_html
 
Component Symbol Glyph Factory &MockObject $glyph_factory
 
Component Symbol Icon Factory &MockObject $icon_factory
 
Component Symbol Factory &MockObject $symbol_factory
 

Detailed Description

Author
Thibeau Fuhrer thibe.nosp@m.au@s.nosp@m.r.sol.nosp@m.utio.nosp@m.ns

Definition at line 33 of file FieldBranchNodeTest.php.

Member Function Documentation

◆ createSimpleRenderingStub()

FieldBranchNodeTest::createSimpleRenderingStub ( string  $class_name)
protected
Returns
array{0: ILIAS\UI\Component\Component, 1: string}

Definition at line 209 of file FieldBranchNodeTest.php.

209 : array
210 {
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];
216 }

◆ getDefaultRenderer()

FieldBranchNodeTest::getDefaultRenderer ( ?JavaScriptBinding  $js_binding = null,
array  $with_stub_renderings = [],
array  $with_additional_contexts = [] 
)

Definition at line 62 of file FieldBranchNodeTest.php.

67 $with_stub_renderings = array_merge($with_stub_renderings, [
68 $this->glyph_stub,
69 $this->icon_stub,
70 ]);
71
72 return parent::getDefaultRenderer($js_binding, $with_stub_renderings, $with_additional_contexts);
73 }

◆ getGlyphStub()

FieldBranchNodeTest::getGlyphStub ( )
protected
Returns
array{0: Component\Symbol\Glyph\Glyph, 1: string}

Definition at line 197 of file FieldBranchNodeTest.php.

197 : array
198 {
199 return $this->createSimpleRenderingStub(Component\Symbol\Glyph\Glyph::class);
200 }
createSimpleRenderingStub(string $class_name)

Referenced by setUp().

+ Here is the caller graph for this function:

◆ getIconStub()

FieldBranchNodeTest::getIconStub ( )
protected
Returns
array{0: Component\Symbol\Icon\Standard, 1: string}

Definition at line 203 of file FieldBranchNodeTest.php.

203 : array
204 {
205 return $this->createSimpleRenderingStub(Component\Symbol\Icon\Standard::class);
206 }

Referenced by setUp().

+ Here is the caller graph for this function:

◆ getNodeFactory()

FieldBranchNodeTest::getNodeFactory ( )
protected

Definition at line 191 of file FieldBranchNodeTest.php.

191 : Field\Node\Factory
192 {
193 return new Field\Node\Factory();
194 }

◆ getUIFactory()

FieldBranchNodeTest::getUIFactory ( )

Definition at line 75 of file FieldBranchNodeTest.php.

76 {
77 return new class ($this->symbol_factory) extends \NoUIFactory {
78 public function __construct(
79 protected Component\Symbol\Factory $symbol_factory,
80 ) {
81 }
82 public function symbol(): Component\Symbol\Factory
83 {
85 }
86 };
87 }
Component Symbol Factory &MockObject $symbol_factory
Factory for Date Formats.
Definition: Factory.php:27
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\Repository\symbol().

+ Here is the call graph for this function:

◆ provideInvalidNodePaths()

static FieldBranchNodeTest::provideInvalidNodePaths ( )
static

Definition at line 181 of file FieldBranchNodeTest.php.

181 : array
182 {
183 return [
184 [1.0],
185 [false],
186 [null],
187 [],
188 ];
189 }

◆ setUp()

FieldBranchNodeTest::setUp ( )
protected

Definition at line 44 of file FieldBranchNodeTest.php.

44 : void
45 {
48
49 $this->glyph_factory = $this->createMock(Component\Symbol\Glyph\Factory::class);
50 $this->glyph_factory->method($this->anything())->willReturn($this->glyph_stub);
51
52 $this->icon_factory = $this->createMock(Component\Symbol\Icon\Factory::class);
53 $this->icon_factory->method('standard')->willReturn($this->icon_stub);
54
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);
58
59 parent::setUp();
60 }
Component Symbol Icon Icon &MockObject $icon_stub
Component Symbol Glyph Glyph &MockObject $glyph_stub

References $glyph_html, $glyph_stub, $icon_html, $icon_stub, getGlyphStub(), and getIconStub().

+ Here is the call graph for this function:

◆ testConstructorWithInvalidNodePath()

FieldBranchNodeTest::testConstructorWithInvalidNodePath ( array  $path)
protected

Definition at line 175 of file FieldBranchNodeTest.php.

175 : void
176 {
177 $this->expectException(\InvalidArgumentException::class);
178 $this->getNodeFactory()->branch($path, "");
179 }
$path
Definition: ltiservices.php:30

References $path.

◆ testConstructorWithValidNodePath()

FieldBranchNodeTest::testConstructorWithValidNodePath ( )
protected

Definition at line 159 of file FieldBranchNodeTest.php.

159 : void
160 {
161 $root_node_id = 0;
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];
166
167 $node = $this->getNodeFactory()->branch($full_node_path, "");
168
169 $this->assertEquals($full_node_path, $node->getFullPath());
170 $this->assertEquals($parent_ids, $node->getParentIds());
171 $this->assertEquals($level_two_node_id, $node->getId());
172 }

◆ testRenderWithChildren()

FieldBranchNodeTest::testRenderWithChildren ( )

Definition at line 89 of file FieldBranchNodeTest.php.

89 : void
90 {
91 $node_id = 'some-existing-node-id';
92 $node_name = 'some existing node name';
93
94 [$child_node_stub, $child_node_html] = $this->createSimpleRenderingStub(Field\Node\Leaf::class);
95
96 $component = $this->getNodeFactory()->branch([$node_id], $node_name, null, $child_node_stub);
97 $renderer = $this->getDefaultRenderer(null, [$child_node_stub]);
98
99 $expected = <<<HTML
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>
104 </button>
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>
108 </button>
109 <ul> $child_node_html</ul>
110</li>
111HTML;
112
113 $actual = $renderer->render($component);
114
115 $this->assertEquals(
116 $this->brutallyTrimHTML($expected),
117 $this->brutallyTrimHTML($actual),
118 );
119 }
$renderer
getDefaultRenderer(?JavaScriptBinding $js_binding=null, array $with_stub_renderings=[], array $with_additional_contexts=[],)
button(string $caption, string $cmd)

References $renderer, and ILIAS\Repository\button().

+ Here is the call graph for this function:

◆ testRenderWithIcon()

FieldBranchNodeTest::testRenderWithIcon ( )
protected

Definition at line 131 of file FieldBranchNodeTest.php.

131 : void
132 {
133 [$icon_stub, $icon_html] = $this->createSimpleRenderingStub(Component\Symbol\Icon\Custom::class);
134
135 $component = $this->getNodeFactory()->branch([''], '');
136 $renderer = $this->getDefaultRenderer(null, [$icon_stub]);
137
138 $actual = $renderer->render($component);
139
140 $this->assertTrue(str_contains($actual, $icon_html));
141 }

References $renderer.

◆ testRenderWithoutChildren()

FieldBranchNodeTest::testRenderWithoutChildren ( )

Definition at line 121 of file FieldBranchNodeTest.php.

121 : void
122 {
123 $component = $this->getNodeFactory()->branch([''], '');
124 $renderer = $this->getDefaultRenderer();
125
126 $actual = $renderer->render($component);
127
128 $this->assertTrue(str_contains($this->brutallyTrimHTML($actual), "<ul></ul>"));
129 }

References $renderer.

◆ testRenderWithoutIcon()

FieldBranchNodeTest::testRenderWithoutIcon ( )

Definition at line 143 of file FieldBranchNodeTest.php.

143 : void
144 {
145 $first_node_name_letter = 's';
146 $node_name = "{$first_node_name_letter}ome existing node name";
147
148 $this->icon_factory->expects($this->once())->method('standard');
149 $this->icon_stub->expects($this->once())->method('withAbbreviation')->with($first_node_name_letter);
150
151 $component = $this->getNodeFactory()->branch([''], $node_name);
152 $renderer = $this->getDefaultRenderer();
153
154 $actual = $renderer->render($component);
155
156 $this->assertTrue(str_contains($actual, $this->icon_html));
157 }

References $renderer.

Field Documentation

◆ $glyph_factory

Component Symbol Glyph Factory& MockObject FieldBranchNodeTest::$glyph_factory
protected

Definition at line 40 of file FieldBranchNodeTest.php.

◆ $glyph_html

string FieldBranchNodeTest::$glyph_html
protected

Definition at line 36 of file FieldBranchNodeTest.php.

Referenced by setUp().

◆ $glyph_stub

Component Symbol Glyph Glyph& MockObject FieldBranchNodeTest::$glyph_stub
protected

Definition at line 35 of file FieldBranchNodeTest.php.

Referenced by setUp().

◆ $icon_factory

Component Symbol Icon Factory& MockObject FieldBranchNodeTest::$icon_factory
protected

Definition at line 41 of file FieldBranchNodeTest.php.

◆ $icon_html

string FieldBranchNodeTest::$icon_html
protected

Definition at line 38 of file FieldBranchNodeTest.php.

Referenced by setUp().

◆ $icon_stub

Component Symbol Icon Icon& MockObject FieldBranchNodeTest::$icon_stub
protected

Definition at line 37 of file FieldBranchNodeTest.php.

Referenced by setUp().

◆ $symbol_factory

Component Symbol Factory& MockObject FieldBranchNodeTest::$symbol_factory
protected

Definition at line 42 of file FieldBranchNodeTest.php.


The documentation for this class was generated from the following file: