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

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
 
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 32 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 170 of file FieldAsyncNodeTest.php.

170 : array
171 {
172 $stub = $this->createMock($class_name);
173 $html = sha1($class_name);
174 $stub->method('getCanonicalName')->willReturn($html);
175 $stub->method($this->anything())->willReturnSelf();
176 return [$stub, $html];
177 }

◆ getDefaultRenderer()

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

Definition at line 67 of file FieldAsyncNodeTest.php.

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

◆ getGlyphStub()

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

Definition at line 158 of file FieldAsyncNodeTest.php.

158 : array
159 {
160 return $this->createSimpleRenderingStub(Component\Symbol\Glyph\Glyph::class);
161 }
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 164 of file FieldAsyncNodeTest.php.

164 : array
165 {
166 return $this->createSimpleRenderingStub(Component\Symbol\Icon\Standard::class);
167 }

Referenced by setUp().

+ Here is the caller graph for this function:

◆ getNodeFactory()

FieldAsyncNodeTest::getNodeFactory ( )
protected

Definition at line 152 of file FieldAsyncNodeTest.php.

152 : Field\Node\Factory
153 {
154 return new Field\Node\Factory();
155 }

◆ getUIFactory()

FieldAsyncNodeTest::getUIFactory ( )

Definition at line 80 of file FieldAsyncNodeTest.php.

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

FieldAsyncNodeTest::setUp ( )
protected

Definition at line 45 of file FieldAsyncNodeTest.php.

45 : void
46 {
47 $this->uri_string = sha1(\ILIAS\Data\URI::class);
48 $this->uri_stub = $this->createMock(\ILIAS\Data\URI::class);
49 $this->uri_stub->method('__toString')->willReturn($this->uri_string);
50
53
54 $this->glyph_factory = $this->createMock(Component\Symbol\Glyph\Factory::class);
55 $this->glyph_factory->method($this->anything())->willReturn($this->glyph_stub);
56
57 $this->icon_factory = $this->createMock(Component\Symbol\Icon\Factory::class);
58 $this->icon_factory->method('standard')->willReturn($this->icon_stub);
59
60 $this->symbol_factory = $this->createMock(Component\Symbol\Factory::class);
61 $this->symbol_factory->method('glyph')->willReturn($this->glyph_factory);
62 $this->symbol_factory->method('icon')->willReturn($this->icon_factory);
63
64 parent::setUp();
65 }
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:

◆ testRenderWithIcon()

FieldAsyncNodeTest::testRenderWithIcon ( )
protected

Definition at line 124 of file FieldAsyncNodeTest.php.

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

References $renderer.

◆ testRenderWithoutIcon()

FieldAsyncNodeTest::testRenderWithoutIcon ( )

Definition at line 136 of file FieldAsyncNodeTest.php.

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

References $renderer.

◆ testRenderWithUrl()

FieldAsyncNodeTest::testRenderWithUrl ( )

Definition at line 94 of file FieldAsyncNodeTest.php.

94 : void
95 {
96 $node_id = 'some-existing-node-id';
97 $node_name = 'some existing node name';
98
99 $component = $this->getNodeFactory()->async($this->uri_stub, $node_id, $node_name);
100 $renderer = $this->getDefaultRenderer();
101
102 $expected = <<<HTML
103<li data-node-id="$node_id" class="c-input-node c-input-node__async c-drilldown__branch" data-render-url="$this->uri_string">
104 <button type="button" class="c-drilldown__menulevel--trigger" aria-expanded="false">
105 <span> $this->icon_html<span data-node-name>$node_name</span></span>
106 <span> $this->glyph_html</span>
107 </button>
108 <button type="button" class="c-input-node__select" aria-label="select_node">
109 <span data-action="select">$this->glyph_html</span>
110 <span class="hidden" data-action="remove">$this->glyph_html</span>
111 </button>
112 <ul></ul>
113</li>
114HTML;
115
116 $actual = $renderer->render($component);
117
118 $this->assertEquals(
119 $this->brutallyTrimHTML($expected),
120 $this->brutallyTrimHTML($actual),
121 );
122 }
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 41 of file FieldAsyncNodeTest.php.

◆ $glyph_html

string FieldAsyncNodeTest::$glyph_html
protected

Definition at line 35 of file FieldAsyncNodeTest.php.

Referenced by setUp().

◆ $glyph_stub

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

Definition at line 34 of file FieldAsyncNodeTest.php.

Referenced by setUp().

◆ $icon_factory

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

Definition at line 42 of file FieldAsyncNodeTest.php.

◆ $icon_html

string FieldAsyncNodeTest::$icon_html
protected

Definition at line 37 of file FieldAsyncNodeTest.php.

Referenced by setUp().

◆ $icon_stub

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

Definition at line 36 of file FieldAsyncNodeTest.php.

Referenced by setUp().

◆ $symbol_factory

Component Symbol Factory& MockObject FieldAsyncNodeTest::$symbol_factory
protected

Definition at line 43 of file FieldAsyncNodeTest.php.

◆ $uri_string

string FieldAsyncNodeTest::$uri_string
protected

Definition at line 39 of file FieldAsyncNodeTest.php.

◆ $uri_stub

ILIAS Data URI& MockObject FieldAsyncNodeTest::$uri_stub
protected

Definition at line 38 of file FieldAsyncNodeTest.php.


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