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

Public Member Functions

 getDefaultRenderer (?JavaScriptBinding $js_binding=null, array $with_stub_renderings=[], array $with_additional_contexts=[],)
 
 getUIFactory ()
 
 testRender ()
 
 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 FieldLeafNodeTest.php.

Member Function Documentation

◆ createSimpleRenderingStub()

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

Definition at line 195 of file FieldLeafNodeTest.php.

195 : array
196 {
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];
202 }

◆ getDefaultRenderer()

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

Definition at line 62 of file FieldLeafNodeTest.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()

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

Definition at line 183 of file FieldLeafNodeTest.php.

183 : array
184 {
185 return $this->createSimpleRenderingStub(Component\Symbol\Glyph\Glyph::class);
186 }
createSimpleRenderingStub(string $class_name)

Referenced by setUp().

+ Here is the caller graph for this function:

◆ getIconStub()

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

Definition at line 189 of file FieldLeafNodeTest.php.

189 : array
190 {
191 return $this->createSimpleRenderingStub(Component\Symbol\Icon\Standard::class);
192 }

Referenced by setUp().

+ Here is the caller graph for this function:

◆ getNodeFactory()

FieldLeafNodeTest::getNodeFactory ( )
protected

Definition at line 177 of file FieldLeafNodeTest.php.

177 : Field\Node\Factory
178 {
179 return new Field\Node\Factory();
180 }

◆ getUIFactory()

FieldLeafNodeTest::getUIFactory ( )

Definition at line 75 of file FieldLeafNodeTest.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 FieldLeafNodeTest::provideInvalidNodePaths ( )
static

Definition at line 167 of file FieldLeafNodeTest.php.

167 : array
168 {
169 return [
170 [1.0],
171 [false],
172 [null],
173 [],
174 ];
175 }

◆ setUp()

FieldLeafNodeTest::setUp ( )
protected

Definition at line 44 of file FieldLeafNodeTest.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()

FieldLeafNodeTest::testConstructorWithInvalidNodePath ( array  $path)
protected

Definition at line 161 of file FieldLeafNodeTest.php.

161 : void
162 {
163 $this->expectException(\InvalidArgumentException::class);
164 $this->getNodeFactory()->leaf($path, "");
165 }
$path
Definition: ltiservices.php:30

References $path.

◆ testConstructorWithValidNodePath()

FieldLeafNodeTest::testConstructorWithValidNodePath ( )
protected

Definition at line 145 of file FieldLeafNodeTest.php.

145 : void
146 {
147 $root_node_id = 0;
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];
152
153 $node = $this->getNodeFactory()->leaf($full_node_path, "");
154
155 $this->assertEquals($full_node_path, $node->getFullPath());
156 $this->assertEquals($parent_ids, $node->getParentIds());
157 $this->assertEquals($level_two_node_id, $node->getId());
158 }

◆ testRender()

FieldLeafNodeTest::testRender ( )

Definition at line 89 of file FieldLeafNodeTest.php.

89 : void
90 {
91 $node_id = 'some-existing-node-id';
92 $node_name = 'some existing node name';
93
94 $component = $this->getNodeFactory()->leaf([$node_id], $node_name);
96
97 $expected = <<<HTML
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>
101 </p>
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>
105 </button>
106</li>
107HTML;
108
109 $actual = $renderer->render($component);
110
111 $this->assertEquals(
112 $this->brutallyTrimHTML($expected),
113 $this->brutallyTrimHTML($actual),
114 );
115 }
$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()

FieldLeafNodeTest::testRenderWithIcon ( )
protected

Definition at line 117 of file FieldLeafNodeTest.php.

117 : void
118 {
119 [$icon_stub, $icon_html] = $this->createSimpleRenderingStub(Component\Symbol\Icon\Custom::class);
120
121 $component = $this->getNodeFactory()->leaf([''], '');
122 $renderer = $this->getDefaultRenderer(null, [$icon_stub]);
123
124 $actual = $renderer->render($component);
125
126 $this->assertTrue(str_contains($actual, $icon_html));
127 }

References $renderer.

◆ testRenderWithoutIcon()

FieldLeafNodeTest::testRenderWithoutIcon ( )

Definition at line 129 of file FieldLeafNodeTest.php.

129 : void
130 {
131 $first_node_name_letter = 's';
132 $node_name = "{$first_node_name_letter}ome existing node name";
133
134 $this->icon_factory->expects($this->once())->method('standard');
135 $this->icon_stub->expects($this->once())->method('withAbbreviation')->with($first_node_name_letter);
136
137 $component = $this->getNodeFactory()->leaf([''], $node_name);
138 $renderer = $this->getDefaultRenderer();
139
140 $actual = $renderer->render($component);
141
142 $this->assertTrue(str_contains($actual, $this->icon_html));
143 }

References $renderer.

Field Documentation

◆ $glyph_factory

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

Definition at line 40 of file FieldLeafNodeTest.php.

◆ $glyph_html

string FieldLeafNodeTest::$glyph_html
protected

Definition at line 36 of file FieldLeafNodeTest.php.

Referenced by setUp().

◆ $glyph_stub

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

Definition at line 35 of file FieldLeafNodeTest.php.

Referenced by setUp().

◆ $icon_factory

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

Definition at line 41 of file FieldLeafNodeTest.php.

◆ $icon_html

string FieldLeafNodeTest::$icon_html
protected

Definition at line 38 of file FieldLeafNodeTest.php.

Referenced by setUp().

◆ $icon_stub

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

Definition at line 37 of file FieldLeafNodeTest.php.

Referenced by setUp().

◆ $symbol_factory

Component Symbol Factory& MockObject FieldLeafNodeTest::$symbol_factory
protected

Definition at line 42 of file FieldLeafNodeTest.php.


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