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

Public Member Functions

 getDefaultRenderer (?JavaScriptBinding $js_binding=null, array $with_stub_renderings=[], array $with_additional_contexts=[],)
 
 getUIFactory ()
 
 testRenderWithUrl ()
 
 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
 
ILIAS Data URI &MockObject $uri_stub
 
string $uri_string
 
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 FieldAsyncNodeTest.php.

Member Function Documentation

◆ createSimpleRenderingStub()

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

Definition at line 203 of file FieldAsyncNodeTest.php.

203 : array
204 {
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];
210 }

◆ getDefaultRenderer()

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

Definition at line 68 of file FieldAsyncNodeTest.php.

73 $with_stub_renderings = array_merge($with_stub_renderings, [
74 $this->glyph_stub,
75 $this->icon_stub,
76 ]);
77
78 return parent::getDefaultRenderer($js_binding, $with_stub_renderings, $with_additional_contexts);
79 }

◆ getGlyphStub()

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

Definition at line 191 of file FieldAsyncNodeTest.php.

191 : array
192 {
193 return $this->createSimpleRenderingStub(Component\Symbol\Glyph\Glyph::class);
194 }
createSimpleRenderingStub(string $class_name)

Referenced by setUp().

+ Here is the caller graph for this function:

◆ getIconStub()

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

Definition at line 197 of file FieldAsyncNodeTest.php.

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

Referenced by setUp().

+ Here is the caller graph for this function:

◆ getNodeFactory()

FieldAsyncNodeTest::getNodeFactory ( )
protected

Definition at line 185 of file FieldAsyncNodeTest.php.

185 : Field\Node\Factory
186 {
187 return new Field\Node\Factory();
188 }

◆ getUIFactory()

FieldAsyncNodeTest::getUIFactory ( )

Definition at line 81 of file FieldAsyncNodeTest.php.

82 {
83 return new class ($this->symbol_factory) extends \NoUIFactory {
84 public function __construct(
85 protected Component\Symbol\Factory $symbol_factory,
86 ) {
87 }
88 public function symbol(): Component\Symbol\Factory
89 {
91 }
92 };
93 }
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 FieldAsyncNodeTest::provideInvalidNodePaths ( )
static

Definition at line 175 of file FieldAsyncNodeTest.php.

175 : array
176 {
177 return [
178 [1.0],
179 [false],
180 [null],
181 [],
182 ];
183 }

◆ setUp()

FieldAsyncNodeTest::setUp ( )
protected

Definition at line 46 of file FieldAsyncNodeTest.php.

46 : void
47 {
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);
51
54
55 $this->glyph_factory = $this->createMock(Component\Symbol\Glyph\Factory::class);
56 $this->glyph_factory->method($this->anything())->willReturn($this->glyph_stub);
57
58 $this->icon_factory = $this->createMock(Component\Symbol\Icon\Factory::class);
59 $this->icon_factory->method('standard')->willReturn($this->icon_stub);
60
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);
64
65 parent::setUp();
66 }
Component Symbol Icon Icon &MockObject $icon_stub
Component Symbol Glyph Glyph &MockObject $glyph_stub
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

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

+ Here is the call graph for this function:

◆ testConstructorWithInvalidNodePath()

FieldAsyncNodeTest::testConstructorWithInvalidNodePath ( array  $path)
protected

Definition at line 169 of file FieldAsyncNodeTest.php.

169 : void
170 {
171 $this->expectException(\InvalidArgumentException::class);
172 $this->getNodeFactory()->async($this->uri_stub, $path, "");
173 }
$path
Definition: ltiservices.php:30

References $path.

◆ testConstructorWithValidNodePath()

FieldAsyncNodeTest::testConstructorWithValidNodePath ( )
protected

Definition at line 153 of file FieldAsyncNodeTest.php.

153 : void
154 {
155 $root_node_id = 0;
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];
160
161 $node = $this->getNodeFactory()->async($this->uri_stub, $full_node_path, "");
162
163 $this->assertEquals($full_node_path, $node->getFullPath());
164 $this->assertEquals($parent_ids, $node->getParentIds());
165 $this->assertEquals($level_two_node_id, $node->getId());
166 }

◆ testRenderWithIcon()

FieldAsyncNodeTest::testRenderWithIcon ( )
protected

Definition at line 125 of file FieldAsyncNodeTest.php.

125 : void
126 {
127 [$icon_stub, $icon_html] = $this->createSimpleRenderingStub(Component\Symbol\Icon\Custom::class);
128
129 $component = $this->getNodeFactory()->async($this->uri_stub, [''], $icon_stub);
130 $renderer = $this->getDefaultRenderer(null, [$icon_stub]);
131
132 $actual = $renderer->render($component);
133
134 $this->assertTrue(str_contains($actual, $icon_html));
135 }
$renderer
getDefaultRenderer(?JavaScriptBinding $js_binding=null, array $with_stub_renderings=[], array $with_additional_contexts=[],)

References $renderer.

◆ testRenderWithoutIcon()

FieldAsyncNodeTest::testRenderWithoutIcon ( )

Definition at line 137 of file FieldAsyncNodeTest.php.

137 : void
138 {
139 $first_node_name_letter = 's';
140 $node_name = "{$first_node_name_letter}ome existing node name";
141
142 $this->icon_factory->expects($this->once())->method('standard');
143 $this->icon_stub->expects($this->once())->method('withAbbreviation')->with($first_node_name_letter);
144
145 $component = $this->getNodeFactory()->async($this->uri_stub, [''], $node_name);
146 $renderer = $this->getDefaultRenderer();
147
148 $actual = $renderer->render($component);
149
150 $this->assertTrue(str_contains($actual, $this->icon_html));
151 }

References $renderer.

◆ testRenderWithUrl()

FieldAsyncNodeTest::testRenderWithUrl ( )

Definition at line 95 of file FieldAsyncNodeTest.php.

95 : void
96 {
97 $node_id = 'some-existing-node-id';
98 $node_name = 'some existing node name';
99
100 $component = $this->getNodeFactory()->async($this->uri_stub, [$node_id], $node_name);
101 $renderer = $this->getDefaultRenderer();
102
103 $expected = <<<HTML
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>
108 </button>
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>
112 </button>
113 <ul></ul>
114</li>
115HTML;
116
117 $actual = $renderer->render($component);
118
119 $this->assertEquals(
120 $this->brutallyTrimHTML($expected),
121 $this->brutallyTrimHTML($actual),
122 );
123 }
button(string $caption, string $cmd)

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

+ Here is the call graph for this function:

Field Documentation

◆ $glyph_factory

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

Definition at line 42 of file FieldAsyncNodeTest.php.

◆ $glyph_html

string FieldAsyncNodeTest::$glyph_html
protected

Definition at line 36 of file FieldAsyncNodeTest.php.

Referenced by setUp().

◆ $glyph_stub

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

Definition at line 35 of file FieldAsyncNodeTest.php.

Referenced by setUp().

◆ $icon_factory

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

Definition at line 43 of file FieldAsyncNodeTest.php.

◆ $icon_html

string FieldAsyncNodeTest::$icon_html
protected

Definition at line 38 of file FieldAsyncNodeTest.php.

Referenced by setUp().

◆ $icon_stub

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

Definition at line 37 of file FieldAsyncNodeTest.php.

Referenced by setUp().

◆ $symbol_factory

Component Symbol Factory& MockObject FieldAsyncNodeTest::$symbol_factory
protected

Definition at line 44 of file FieldAsyncNodeTest.php.

◆ $uri_string

string FieldAsyncNodeTest::$uri_string
protected

Definition at line 40 of file FieldAsyncNodeTest.php.

◆ $uri_stub

ILIAS Data URI& MockObject FieldAsyncNodeTest::$uri_stub
protected

Definition at line 39 of file FieldAsyncNodeTest.php.


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