ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ()
 

Protected Member Functions

 setUp ()
 
 testRenderWithIcon ()
 
 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 32 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 176 of file FieldBranchNodeTest.php.

176 : array
177 {
178 $stub = $this->createMock($class_name);
179 $html = sha1($class_name);
180 $stub->method('getCanonicalName')->willReturn($html);
181 $stub->method($this->anything())->willReturnSelf();
182 return [$stub, $html];
183 }

◆ getDefaultRenderer()

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

Definition at line 61 of file FieldBranchNodeTest.php.

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

◆ getGlyphStub()

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

Definition at line 164 of file FieldBranchNodeTest.php.

164 : array
165 {
166 return $this->createSimpleRenderingStub(Component\Symbol\Glyph\Glyph::class);
167 }
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 170 of file FieldBranchNodeTest.php.

170 : array
171 {
172 return $this->createSimpleRenderingStub(Component\Symbol\Icon\Standard::class);
173 }

Referenced by setUp().

+ Here is the caller graph for this function:

◆ getNodeFactory()

FieldBranchNodeTest::getNodeFactory ( )
protected

Definition at line 158 of file FieldBranchNodeTest.php.

158 : Field\Node\Factory
159 {
160 return new Field\Node\Factory();
161 }

◆ getUIFactory()

FieldBranchNodeTest::getUIFactory ( )

Definition at line 74 of file FieldBranchNodeTest.php.

75 {
76 return new class ($this->symbol_factory) extends \NoUIFactory {
77 public function __construct(
78 protected Component\Symbol\Factory $symbol_factory,
79 ) {
80 }
81 public function symbol(): Component\Symbol\Factory
82 {
84 }
85 };
86 }
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:

◆ setUp()

FieldBranchNodeTest::setUp ( )
protected

Definition at line 43 of file FieldBranchNodeTest.php.

43 : void
44 {
47
48 $this->glyph_factory = $this->createMock(Component\Symbol\Glyph\Factory::class);
49 $this->glyph_factory->method($this->anything())->willReturn($this->glyph_stub);
50
51 $this->icon_factory = $this->createMock(Component\Symbol\Icon\Factory::class);
52 $this->icon_factory->method('standard')->willReturn($this->icon_stub);
53
54 $this->symbol_factory = $this->createMock(Component\Symbol\Factory::class);
55 $this->symbol_factory->method('glyph')->willReturn($this->glyph_factory);
56 $this->symbol_factory->method('icon')->willReturn($this->icon_factory);
57
58 parent::setUp();
59 }
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:

◆ testRenderWithChildren()

FieldBranchNodeTest::testRenderWithChildren ( )

Definition at line 88 of file FieldBranchNodeTest.php.

88 : void
89 {
90 $node_id = 'some-existing-node-id';
91 $node_name = 'some existing node name';
92
93 [$child_node_stub, $child_node_html] = $this->createSimpleRenderingStub(Field\Node\Leaf::class);
94
95 $component = $this->getNodeFactory()->branch($node_id, $node_name, null, $child_node_stub);
96 $renderer = $this->getDefaultRenderer(null, [$child_node_stub]);
97
98 $expected = <<<HTML
99<li data-node-id="$node_id" class="c-input-node c-input-node__branch c-drilldown__branch">
100 <button type="button" class="c-drilldown__menulevel--trigger" aria-expanded="false">
101 <span> $this->icon_html<span data-node-name>$node_name</span></span>
102 <span> $this->glyph_html</span>
103 </button>
104 <button type="button" class="c-input-node__select" aria-label="select_node">
105 <span data-action="select">$this->glyph_html</span>
106 <span class="hidden" data-action="remove">$this->glyph_html</span>
107 </button>
108 <ul> $child_node_html</ul>
109</li>
110HTML;
111
112 $actual = $renderer->render($component);
113
114 $this->assertEquals(
115 $this->brutallyTrimHTML($expected),
116 $this->brutallyTrimHTML($actual),
117 );
118 }
$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 130 of file FieldBranchNodeTest.php.

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

References $renderer.

◆ testRenderWithoutChildren()

FieldBranchNodeTest::testRenderWithoutChildren ( )

Definition at line 120 of file FieldBranchNodeTest.php.

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

References $renderer.

◆ testRenderWithoutIcon()

FieldBranchNodeTest::testRenderWithoutIcon ( )

Definition at line 142 of file FieldBranchNodeTest.php.

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

References $renderer.

Field Documentation

◆ $glyph_factory

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

Definition at line 39 of file FieldBranchNodeTest.php.

◆ $glyph_html

string FieldBranchNodeTest::$glyph_html
protected

Definition at line 35 of file FieldBranchNodeTest.php.

Referenced by setUp().

◆ $glyph_stub

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

Definition at line 34 of file FieldBranchNodeTest.php.

Referenced by setUp().

◆ $icon_factory

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

Definition at line 40 of file FieldBranchNodeTest.php.

◆ $icon_html

string FieldBranchNodeTest::$icon_html
protected

Definition at line 37 of file FieldBranchNodeTest.php.

Referenced by setUp().

◆ $icon_stub

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

Definition at line 36 of file FieldBranchNodeTest.php.

Referenced by setUp().

◆ $symbol_factory

Component Symbol Factory& MockObject FieldBranchNodeTest::$symbol_factory
protected

Definition at line 41 of file FieldBranchNodeTest.php.


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