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

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 FieldLeafNodeTest.php.

Member Function Documentation

◆ createSimpleRenderingStub()

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

Definition at line 162 of file FieldLeafNodeTest.php.

Referenced by getGlyphStub(), getIconStub(), and testRenderWithIcon().

162  : array
163  {
164  $stub = $this->createMock($class_name);
165  $html = sha1($class_name);
166  $stub->method('getCanonicalName')->willReturn($html);
167  $stub->method($this->anything())->willReturnSelf();
168  return [$stub, $html];
169  }
+ Here is the caller graph for this function:

◆ getDefaultRenderer()

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

Definition at line 61 of file FieldLeafNodeTest.php.

Referenced by testRender(), testRenderWithIcon(), and testRenderWithoutIcon().

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  }
+ Here is the caller graph for this function:

◆ getGlyphStub()

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

Definition at line 150 of file FieldLeafNodeTest.php.

References createSimpleRenderingStub().

Referenced by setUp().

150  : array
151  {
152  return $this->createSimpleRenderingStub(Component\Symbol\Glyph\Glyph::class);
153  }
createSimpleRenderingStub(string $class_name)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIconStub()

FieldLeafNodeTest::getIconStub ( )
protected
Returns
array{0: Component, 1: string}

Definition at line 156 of file FieldLeafNodeTest.php.

References createSimpleRenderingStub().

Referenced by setUp().

156  : array
157  {
158  return $this->createSimpleRenderingStub(Component\Symbol\Icon\Standard::class);
159  }
createSimpleRenderingStub(string $class_name)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNodeFactory()

FieldLeafNodeTest::getNodeFactory ( )
protected

Definition at line 144 of file FieldLeafNodeTest.php.

Referenced by testRender(), testRenderWithIcon(), and testRenderWithoutIcon().

144  : Field\Node\Factory
145  {
146  return new Field\Node\Factory();
147  }
+ Here is the caller graph for this function:

◆ getUIFactory()

FieldLeafNodeTest::getUIFactory ( )

Definition at line 74 of file FieldLeafNodeTest.php.

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

74  : \NoUIFactory
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  {
83  return $this->symbol_factory;
84  }
85  };
86  }
Factory for Date Formats.
Definition: Factory.php:26
__construct(Container $dic, ilPlugin $plugin)
Component Symbol Factory &MockObject $symbol_factory
+ Here is the call graph for this function:

◆ setUp()

FieldLeafNodeTest::setUp ( )
protected

Definition at line 43 of file FieldLeafNodeTest.php.

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

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 Glyph Glyph &MockObject $glyph_stub
Component Symbol Icon Icon &MockObject $icon_stub
+ Here is the call graph for this function:

◆ testRender()

FieldLeafNodeTest::testRender ( )

Definition at line 88 of file FieldLeafNodeTest.php.

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

88  : void
89  {
90  $node_id = 'some-existing-node-id';
91  $node_name = 'some existing node name';
92 
93  $component = $this->getNodeFactory()->leaf($node_id, $node_name);
94  $renderer = $this->getDefaultRenderer();
95 
96  $expected = <<<HTML
97 <li data-node-id="$node_id" class="c-input-node c-input-node__leaf c-drilldown__leaf">
98  <p class="il-link link-bulky c-input-node__name" tabindex="0">
99  $this->icon_html<span data-node-name>$node_name</span>
100  </p>
101  <button type="button" class="c-input-node__select" aria-label="select_node">
102  <span data-action="select">$this->glyph_html</span>
103  <span class="hidden" data-action="remove">$this->glyph_html</span>
104  </button>
105 </li>
106 HTML;
107 
108  $actual = $renderer->render($component);
109 
110  $this->assertEquals(
111  $this->brutallyTrimHTML($expected),
112  $this->brutallyTrimHTML($actual),
113  );
114  }
button(string $caption, string $cmd)
$renderer
getDefaultRenderer(?JavaScriptBinding $js_binding=null, array $with_stub_renderings=[], array $with_additional_contexts=[],)
+ Here is the call graph for this function:

◆ testRenderWithIcon()

FieldLeafNodeTest::testRenderWithIcon ( )
protected

Definition at line 116 of file FieldLeafNodeTest.php.

References $icon_html, $icon_stub, $renderer, createSimpleRenderingStub(), getDefaultRenderer(), getNodeFactory(), and null.

116  : void
117  {
118  [$icon_stub, $icon_html] = $this->createSimpleRenderingStub(Component\Symbol\Icon\Custom::class);
119 
120  $component = $this->getNodeFactory()->leaf('', '');
122 
123  $actual = $renderer->render($component);
124 
125  $this->assertTrue(str_contains($actual, $icon_html));
126  }
$renderer
Component Symbol Icon Icon &MockObject $icon_stub
createSimpleRenderingStub(string $class_name)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getDefaultRenderer(?JavaScriptBinding $js_binding=null, array $with_stub_renderings=[], array $with_additional_contexts=[],)
+ Here is the call graph for this function:

◆ testRenderWithoutIcon()

FieldLeafNodeTest::testRenderWithoutIcon ( )

Definition at line 128 of file FieldLeafNodeTest.php.

References $renderer, getDefaultRenderer(), and getNodeFactory().

128  : void
129  {
130  $first_node_name_letter = 's';
131  $node_name = "{$first_node_name_letter}ome existing node name";
132 
133  $this->icon_factory->expects($this->once())->method('standard');
134  $this->icon_stub->expects($this->once())->method('withAbbreviation')->with($first_node_name_letter);
135 
136  $component = $this->getNodeFactory()->leaf('', $node_name);
137  $renderer = $this->getDefaultRenderer();
138 
139  $actual = $renderer->render($component);
140 
141  $this->assertTrue(str_contains($actual, $this->icon_html));
142  }
$renderer
getDefaultRenderer(?JavaScriptBinding $js_binding=null, array $with_stub_renderings=[], array $with_additional_contexts=[],)
+ Here is the call graph for this function:

Field Documentation

◆ $glyph_factory

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

Definition at line 39 of file FieldLeafNodeTest.php.

◆ $glyph_html

string FieldLeafNodeTest::$glyph_html
protected

Definition at line 35 of file FieldLeafNodeTest.php.

Referenced by setUp().

◆ $glyph_stub

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

Definition at line 34 of file FieldLeafNodeTest.php.

Referenced by setUp().

◆ $icon_factory

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

Definition at line 40 of file FieldLeafNodeTest.php.

◆ $icon_html

string FieldLeafNodeTest::$icon_html
protected

Definition at line 37 of file FieldLeafNodeTest.php.

Referenced by setUp(), and testRenderWithIcon().

◆ $icon_stub

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

Definition at line 36 of file FieldLeafNodeTest.php.

Referenced by setUp(), and testRenderWithIcon().

◆ $symbol_factory

Component Symbol Factory& MockObject FieldLeafNodeTest::$symbol_factory
protected

Definition at line 41 of file FieldLeafNodeTest.php.

Referenced by getUIFactory().


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