ILIAS  release_8 Revision v8.24
ViewControlFieldSelectionTest Class Reference
+ Inheritance diagram for ViewControlFieldSelectionTest:
+ Collaboration diagram for ViewControlFieldSelectionTest:

Public Member Functions

 testViewControlFieldSelectionConstruct ()
 
 testViewControlFieldSelectionWithWrongValue ()
 
 testViewControlFieldSelectionWithInput ()
 
 testViewControlFieldSelectionRendering ()
 
 testViewControlFieldSelectionRenderingOutsideContainer ()
 
- Public Member Functions inherited from ViewControlBaseTest
 getUIFactory ()
 
 getDataFactory ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Additional Inherited Members

- Protected Member Functions inherited from ViewControlBaseTest
 getNamesource ()
 
 buildDataFactory ()
 
 buildRefinery ()
 
 buildFieldFactory ()
 
 buildVCFactory ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Detailed Description

Definition at line 31 of file ViewControlFieldSelectionTest.php.

Member Function Documentation

◆ testViewControlFieldSelectionConstruct()

ViewControlFieldSelectionTest::testViewControlFieldSelectionConstruct ( )

Definition at line 33 of file ViewControlFieldSelectionTest.php.

33 : void
34 {
35 $options = [
36 'opt1' => 'A',
37 'opt2' => 'B'
38 ];
39 $vc = $this->buildVCFactory()->fieldSelection($options);
40 $this->assertInstanceOf(Signal::class, $vc->getInternalSignal());
41 $this->assertEquals($options, $vc->getOptions());
42 $this->assertEquals('', $vc->getButtonLabel());
43 }

References ViewControlBaseTest\buildVCFactory().

+ Here is the call graph for this function:

◆ testViewControlFieldSelectionRendering()

ViewControlFieldSelectionTest::testViewControlFieldSelectionRendering ( )

Definition at line 83 of file ViewControlFieldSelectionTest.php.

83 : void
84 {
85 $r = $this->getDefaultRenderer();
86 $options = [
87 'opt1' => 'A',
88 'opt2' => 'B'
89 ];
90 $vc = $this->buildVCFactory()->fieldSelection($options)
91 ->withOnChange((new SignalGenerator())->create());
92
93 $expected = $this->brutallyTrimHTML('
94<div class="dropdown il-viewcontrol il-viewcontrol-fieldselection l-bar__element" id="id_3">
95 <button class="btn btn-ctrl dropdown-toggle" type="button" data-toggle="dropdown" aria-label="label_fieldselection" aria-haspopup="true" aria-expanded="false" aria-controls="id_3_ctrl"><span class="caret"></span></button>
96 <ul id="id_3_ctrl" class="dropdown-menu">
97 <li><input type="checkbox" value="opt1" id="id_1" /><label for="id_1">A</label></li>
98 <li><input type="checkbox" value="opt2" id="id_2" /><label for="id_2">B</label></li>
99
100 <button class="btn btn-default" id="id_4">label_fieldselection_refresh</button>
101 </ul>
102 <div class="il-viewcontrol-value" role="none"></div>
103</div>
104');
105 $html = $this->brutallyTrimHTML($r->render($vc));
106 $this->assertEquals($expected, $html);
107 }
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355

References ILIAS_UI_TestBase\brutallyTrimHTML(), ViewControlBaseTest\buildVCFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

◆ testViewControlFieldSelectionRenderingOutsideContainer()

ViewControlFieldSelectionTest::testViewControlFieldSelectionRenderingOutsideContainer ( )

Definition at line 109 of file ViewControlFieldSelectionTest.php.

109 : void
110 {
111 $this->expectException(\LogicException::class);
112 $this->buildVCFactory()->fieldSelection([])->getOnChangeSignal();
113 }

References ViewControlBaseTest\buildVCFactory().

+ Here is the call graph for this function:

◆ testViewControlFieldSelectionWithInput()

ViewControlFieldSelectionTest::testViewControlFieldSelectionWithInput ( )

Definition at line 57 of file ViewControlFieldSelectionTest.php.

57 : void
58 {
59 $options = [
60 'opt1' => 'A',
61 'opt2' => 'B',
62 'opt3' => 'C',
63 ];
64 $v = ['opt1','opt2'];
65
66 $input = $this->createMock(InputData::class);
67 $input->expects($this->once())
68 ->method("getOr")
69 ->willReturn($v);
70
71 $vc = $this->buildVCFactory()->fieldSelection($options)
72 ->withNameFrom($this->getNamesource())
73 ->withInput($input);
74
75 $df = $this->buildDataFactory();
76 $this->assertEquals(
77 $df->ok(['opt1','opt2']),
78 $vc->getContent()
79 );
80 $this->assertEquals($v, $vc->getValue());
81 }

References ViewControlBaseTest\buildDataFactory(), ViewControlBaseTest\buildVCFactory(), and ViewControlBaseTest\getNamesource().

+ Here is the call graph for this function:

◆ testViewControlFieldSelectionWithWrongValue()

ViewControlFieldSelectionTest::testViewControlFieldSelectionWithWrongValue ( )

Definition at line 45 of file ViewControlFieldSelectionTest.php.

45 : void
46 {
47 $this->expectException(\Exception::class);
48 $options = [
49 'opt1' => 'A',
50 'opt2' => 'B',
51 'opt3' => 'C',
52 ];
53 $vc = $this->buildVCFactory()->fieldSelection($options)
54 ->withValue('notokvalue,something');
55 }

References ViewControlBaseTest\buildVCFactory().

+ Here is the call graph for this function:

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