ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
SortationTest Class Reference

Test on icon implementation. More...

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

Public Member Functions

 testConstruction ()
 
 testAttributes ()
 
 testRendering ()
 
 testRenderingWithJsBinding ()
 
 getUIFactory ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Protected Member Functions

 getSortationExpectedHTML (bool $with_id=false)
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Protected Attributes

 $options
 

Private Member Functions

 getFactory ()
 

Detailed Description

Test on icon implementation.

Definition at line 14 of file SortationTest.php.

Member Function Documentation

◆ getFactory()

SortationTest::getFactory ( )
private

Definition at line 22 of file SortationTest.php.

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

23  {
24  return new I\Component\ViewControl\Factory(
25  new SignalGenerator()
26  );
27  }
+ Here is the caller graph for this function:

◆ getSortationExpectedHTML()

SortationTest::getSortationExpectedHTML ( bool  $with_id = false)
protected

Definition at line 93 of file SortationTest.php.

References ILIAS_UI_TestBase\normalizeHTML().

Referenced by testRendering(), and testRenderingWithJsBinding().

94  {
95  $id = "";
96  $button1_id = "id_1";
97  $button2_id = "id_2";
98  $button3_id = "id_3";
99 
100  if ($with_id) {
101  $id = "id=\"id_1\"";
102  $button1_id = "id_2";
103  $button2_id = "id_3";
104  $button3_id = "id_4";
105  }
106 
107  $expected = <<<EOT
108 <div class="il-viewcontrol-sortation" $id><div class="dropdown"><button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-label="actions" aria-haspopup="true" aria-expanded="false" > <span class="caret"></span></button><ul class="dropdown-menu">
109  <li><button class="btn btn-link" data-action="?sortation=internal_rating" id="$button1_id">Best</button></li>
110  <li><button class="btn btn-link" data-action="?sortation=date_desc" id="$button2_id">Most Recent</button></li>
111  <li><button class="btn btn-link" data-action="?sortation=date_asc" id="$button3_id">Oldest</button></li></ul></div>
112 </div>
113 EOT;
114  return $this->normalizeHTML($expected);
115  }
normalizeHTML($html)
Definition: Base.php:363
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUIFactory()

SortationTest::getUIFactory ( )

Definition at line 117 of file SortationTest.php.

References $factory.

118  {
119  $factory = new class extends NoUIFactory {
120  public function button()
121  {
122  return new I\Component\Button\Factory();
123  }
124  public function dropdown()
125  {
126  return new I\Component\Dropdown\Factory();
127  }
128  };
129  return $factory;
130  }
$factory
Definition: metadata.php:58

◆ testAttributes()

SortationTest::testAttributes ( )

Definition at line 43 of file SortationTest.php.

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

44  {
45  $f = $this->getFactory();
46  $s = $f->sortation($this->options);
47 
48  $this->assertEquals($this->options, $s->getOptions());
49 
50  $this->assertEquals('label', $s->withLabel('label')->getLabel());
51 
52  $s = $s->withTargetURL('#', 'param');
53  $this->assertEquals('#', $s->getTargetURL());
54  $this->assertEquals('param', $s->getParameterName());
55 
56  $this->assertEquals(array(), $s->getTriggeredSignals());
57  $generator = new SignalGenerator();
58  $signal = $generator->create();
59  $this->assertEquals(
60  $signal,
61  $s->withOnSort($signal)->getTriggeredSignals()[0]->getSignal()
62  );
63  }
+ Here is the call graph for this function:

◆ testConstruction()

SortationTest::testConstruction ( )

Definition at line 29 of file SortationTest.php.

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

30  {
31  $f = $this->getFactory();
32  $sortation = $f->sortation($this->options);
33  $this->assertInstanceOf(
34  "ILIAS\\UI\\Component\\ViewControl\\Sortation",
35  $sortation
36  );
37  $this->assertInstanceOf(
38  "ILIAS\\UI\\Component\\Signal",
39  $sortation->getSelectSignal()
40  );
41  }
+ Here is the call graph for this function:

◆ testRendering()

SortationTest::testRendering ( )

Definition at line 65 of file SortationTest.php.

References Vendor\Package\$f, ILIAS_UI_TestBase\getDefaultRenderer(), getFactory(), getSortationExpectedHTML(), and ILIAS_UI_TestBase\normalizeHTML().

66  {
67  $f = $this->getFactory();
68  $r = $this->getDefaultRenderer();
69  $s = $f->sortation($this->options);
70 
71  $html = $this->normalizeHTML($r->render($s));
72  $this->assertEquals(
73  $this->getSortationExpectedHTML(true),
74  $html
75  );
76  }
getSortationExpectedHTML(bool $with_id=false)
normalizeHTML($html)
Definition: Base.php:363
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ testRenderingWithJsBinding()

SortationTest::testRenderingWithJsBinding ( )

Definition at line 78 of file SortationTest.php.

References Vendor\Package\$f, ILIAS_UI_TestBase\getDefaultRenderer(), getFactory(), getSortationExpectedHTML(), and ILIAS_UI_TestBase\normalizeHTML().

79  {
80  $f = $this->getFactory();
81  $r = $this->getDefaultRenderer();
82  $s = $f->sortation($this->options)->withAdditionalOnLoadCode(function ($id) {
83  return "";
84  });
85 
86  $html = $this->normalizeHTML($r->render($s));
87  $this->assertEquals(
88  $this->getSortationExpectedHTML(true),
89  $html
90  );
91  }
getSortationExpectedHTML(bool $with_id=false)
normalizeHTML($html)
Definition: Base.php:363
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

Field Documentation

◆ $options

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

Definition at line 16 of file SortationTest.php.


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