ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SortationTest Class Reference

Test on icon implementation. More...

+ Inheritance diagram for SortationTest:
+ Collaboration diagram for SortationTest:

Public Member Functions

 testConstruction ()
 
 testFaultyConstruction ()
 
 testAttributes ()
 
 testRendering ()
 
 testRenderingWithSelected ()
 
 testRenderingWithJsBinding ()
 
 getUIFactory ()
 

Protected Attributes

array $options
 

Private Member Functions

 getFactory ()
 

Detailed Description

Test on icon implementation.

Definition at line 31 of file SortationTest.php.

Member Function Documentation

◆ getFactory()

SortationTest::getFactory ( )
private

Definition at line 39 of file SortationTest.php.

39 : I\Component\ViewControl\Factory
40 {
41 return new I\Component\ViewControl\Factory(
42 new SignalGenerator()
43 );
44 }

Referenced by testAttributes(), testConstruction(), testFaultyConstruction(), testRendering(), testRenderingWithJsBinding(), and testRenderingWithSelected().

+ Here is the caller graph for this function:

◆ getUIFactory()

SortationTest::getUIFactory ( )

Definition at line 162 of file SortationTest.php.

163 {
164 return new class () extends NoUIFactory {
165 public function button(): I\Component\Button\Factory
166 {
167 return new I\Component\Button\Factory();
168 }
169 public function dropdown(): I\Component\Dropdown\Factory
170 {
171 return new I\Component\Dropdown\Factory();
172 }
173 };
174 }
button(string $caption, string $cmd)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21

References ILIAS\Repository\button().

+ Here is the call graph for this function:

◆ testAttributes()

SortationTest::testAttributes ( )

Definition at line 61 of file SortationTest.php.

61 : void
62 {
63 $f = $this->getFactory();
64 $s = $f->sortation($this->options, 'date_desc');
65
66 $this->assertEquals($this->options, $s->getOptions());
67
68 $s = $s->withTargetURL('#', 'param');
69 $this->assertEquals('#', $s->getTargetURL());
70 $this->assertEquals('param', $s->getParameterName());
71
72 $this->assertEquals(array(), $s->getTriggeredSignals());
73 $generator = new SignalGenerator();
74 $signal = $generator->create();
75 $this->assertEquals($signal, $s->withOnSort($signal)->getTriggeredSignals()[0]->getSignal());
76 $this->assertEquals('internal_rating', $s->withSelected('internal_rating')->getSelected());
77 }

References Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

◆ testConstruction()

SortationTest::testConstruction ( )

Definition at line 46 of file SortationTest.php.

46 : void
47 {
48 $f = $this->getFactory();
49 $sortation = $f->sortation($this->options, 'date_desc');
50 $this->assertInstanceOf("ILIAS\\UI\\Component\\ViewControl\\Sortation", $sortation);
51 $this->assertInstanceOf("ILIAS\\UI\\Component\\Signal", $sortation->getSelectSignal());
52 }

References Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

◆ testFaultyConstruction()

SortationTest::testFaultyConstruction ( )

Definition at line 54 of file SortationTest.php.

54 : void
55 {
56 $this->expectException(\InvalidArgumentException::class);
57 $f = $this->getFactory();
58 $sortation = $f->sortation($this->options, 'not_in_options');
59 }

References Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

◆ testRendering()

SortationTest::testRendering ( )

Definition at line 79 of file SortationTest.php.

79 : void
80 {
81 $f = $this->getFactory();
82 $r = $this->getDefaultRenderer();
83 $s = $f->sortation($this->options, 'date_desc');
84
85 $expected = <<<EOT
86<div class="dropdown il-viewcontrol il-viewcontrol-sortation l-bar__element" id="id_1">
87 <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-label="sortation" aria-haspopup="true" aria-expanded="false" aria-controls="id_1_ctrl">
88 <span class="label">vc_sort Most Recent</span>
89 <span class="glyphicon-sort"></span>
90 </button>
91 <ul id="id_1_ctrl" class="dropdown-menu">
92 <li><button class="btn btn-link" data-action="?sortation=internal_rating" id="id_2">Best</button></li>
93 <li class="selected"><button class="btn btn-link" data-action="?sortation=date_desc" id="id_3">Most Recent</button></li>
94 <li><button class="btn btn-link" data-action="?sortation=date_asc" id="id_4">Oldest</button></li>
95 </ul>
96</div>
97EOT;
98 $html = $this->brutallyTrimHTML($r->render($s));
99 $this->assertEquals($this->brutallyTrimHTML($expected), $html);
100 }

References Vendor\Package\$f, ILIAS\Repository\button(), and getFactory().

+ Here is the call graph for this function:

◆ testRenderingWithJsBinding()

SortationTest::testRenderingWithJsBinding ( )

Definition at line 126 of file SortationTest.php.

126 : void
127 {
128 $f = $this->getFactory();
129 $r = $this->getDefaultRenderer();
130 $s = $f->sortation($this->options, array_key_first($this->options))
131 ->withAdditionalOnLoadCode(
132 function ($id) {
133 return "";
134 }
135 );
136
137 $id = ' id="id_1"';
138 $id_ctrl = "id_1_ctrl";
139 $button1_id = "id_2";
140 $button2_id = "id_3";
141 $button3_id = "id_4";
142 $dropdown_id = "id_5";
143 $dropdown_menu_id = $dropdown_id . "_menu";
144
145 $expected = <<<EOT
146<div class="dropdown il-viewcontrol il-viewcontrol-sortation l-bar__element"$id>
147 <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-label="sortation" aria-haspopup="true" aria-expanded="false" aria-controls="{$id_ctrl}">
148 <span class="label">vc_sort Best</span>
149 <span class="glyphicon-sort"></span>
150 </button>
151 <ul id="{$id_ctrl}" class="dropdown-menu">
152 <li class="selected"><button class="btn btn-link" data-action="?sortation=internal_rating" id="$button1_id">Best</button></li>
153 <li><button class="btn btn-link" data-action="?sortation=date_desc" id="$button2_id">Most Recent</button></li>
154 <li><button class="btn btn-link" data-action="?sortation=date_asc" id="$button3_id">Oldest</button></li>
155 </ul>
156</div>
157EOT;
158 $html = $this->brutallyTrimHTML($r->render($s));
159 $this->assertEquals($this->brutallyTrimHTML($expected), $html);
160 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References Vendor\Package\$f, $id, ILIAS\Repository\button(), and getFactory().

+ Here is the call graph for this function:

◆ testRenderingWithSelected()

SortationTest::testRenderingWithSelected ( )

Definition at line 102 of file SortationTest.php.

102 : void
103 {
104 $f = $this->getFactory();
105 $r = $this->getDefaultRenderer();
106 $s = $f->sortation($this->options, 'internal_rating')
107 ->withSelected('date_desc');
108
109 $expected = <<<EOT
110<div class="dropdown il-viewcontrol il-viewcontrol-sortation l-bar__element" id="id_1">
111 <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-label="sortation" aria-haspopup="true" aria-expanded="false" aria-controls="id_1_ctrl">
112 <span class="label">vc_sort Most Recent</span>
113 <span class="glyphicon-sort"></span>
114 </button>
115 <ul id="id_1_ctrl" class="dropdown-menu">
116 <li><button class="btn btn-link" data-action="?sortation=internal_rating" id="id_2">Best</button></li>
117 <li class="selected"><button class="btn btn-link" data-action="?sortation=date_desc" id="id_3">Most Recent</button></li>
118 <li><button class="btn btn-link" data-action="?sortation=date_asc" id="id_4">Oldest</button></li>
119 </ul>
120</div>
121EOT;
122 $html = $this->brutallyTrimHTML($r->render($s));
123 $this->assertEquals($this->brutallyTrimHTML($expected), $html);
124 }

References Vendor\Package\$f, ILIAS\Repository\button(), and getFactory().

+ Here is the call graph for this function:

Field Documentation

◆ $options

array SortationTest::$options
protected
Initial value:
= [
'internal_rating' => 'Best',
'date_desc' => 'Most Recent',
'date_asc' => 'Oldest',
]

Definition at line 33 of file SortationTest.php.


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