ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
SortationTest.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 2017 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */
3
4require_once("libs/composer/vendor/autoload.php");
5require_once(__DIR__ . "/../../Base.php");
6
7use \ILIAS\UI\Component as C;
9
14{
15 protected $options = array(
16 'internal_rating' => 'Best',
17 'date_desc' => 'Most Recent',
18 'date_asc' => 'Oldest',
19 );
20
21 private function getFactory()
22 {
23 $f = new \ILIAS\UI\Implementation\Factory();
24 return $f->viewControl();
25 }
26
27 public function testConstruction()
28 {
29 $f = $this->getFactory();
30 $sortation = $f->sortation($this->options);
31 $this->assertInstanceOf(
32 "ILIAS\\UI\\Component\\ViewControl\\Sortation",
33 $sortation
34 );
35 $this->assertInstanceOf(
36 "ILIAS\\UI\\Component\\Signal",
37 $sortation->getSelectSignal()
38 );
39 }
40
41 public function testAttributes()
42 {
43 $f = $this->getFactory();
44 $s = $f->sortation($this->options);
45
46 $this->assertEquals($this->options, $s->getOptions());
47
48 $this->assertEquals('label', $s->withLabel('label')->getLabel());
49
50 $s = $s->withTargetURL('#', 'param');
51 $this->assertEquals('#', $s->getTargetURL());
52 $this->assertEquals('param', $s->getParameterName());
53
54 $this->assertEquals(array(), $s->getTriggeredSignals());
55 $generator = new SignalGenerator();
56 $signal = $generator->create();
57 $this->assertEquals(
58 $signal,
59 $s->withOnSort($signal)->getTriggeredSignals()[0]->getSignal()
60 );
61 }
62
63 public function testRendering()
64 {
65 $f = $this->getFactory();
66 $r = $this->getDefaultRenderer();
67 $s = $f->sortation($this->options);
68
69 $html = $this->normalizeHTML($r->render($s));
70 $this->assertEquals(
72 $html
73 );
74 }
75
76 protected function getSortationExpectedHTML()
77 {
78 $expected = <<<EOT
79<div class="il-viewcontrol-sortation" id=""><div class="dropdown"><button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" > <span class="caret"></span></button><ul class="dropdown-menu">
80 <li><a class="btn btn-link" href="?sortation=internal_rating" data-action="?sortation=internal_rating" >Best</a></li>
81 <li><a class="btn btn-link" href="?sortation=date_desc" data-action="?sortation=date_desc" >Most Recent</a></li>
82 <li><a class="btn btn-link" href="?sortation=date_asc" data-action="?sortation=date_asc" >Oldest</a></li></ul></div>
83</div>
84EOT;
85 return $this->normalizeHTML($expected);
86 }
87}
An exception for terminatinating execution or to throw for unit testing.
Provides common functionality for UI tests.
Definition: Base.php:178
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:216
normalizeHTML($html)
Definition: Base.php:243
Test on icon implementation.
$html
Definition: example_001.php:87
$r
Definition: example_031.php:79
$s
Definition: pwgen.php:45
$this data['403_header']