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

Public Member Functions

 testViewControlContainerConstruct ()
 
 testViewControlContainerWithControls ()
 
 testViewControlContainerWithRequest ()
 
 testViewControlContainerTransforms ()
 
- 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)
 

Protected Member Functions

 buildDataFactory ()
 
 buildRefinery ()
 
 buildContainerFactory ()
 
 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 35 of file ViewControlContainerTest.php.

Member Function Documentation

◆ buildContainerFactory()

ViewControlContainerTest::buildContainerFactory ( )
protected

Definition at line 48 of file ViewControlContainerTest.php.

49 {
50 return new VC\Factory(
51 new I\SignalGenerator(),
52 $this->buildVCFactory(),
53 );
54 }
This is how the factory for UI elements looks.
Definition: Factory.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References buildVCFactory().

Referenced by testViewControlContainerConstruct(), testViewControlContainerTransforms(), testViewControlContainerWithControls(), and testViewControlContainerWithRequest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildDataFactory()

ViewControlContainerTest::buildDataFactory ( )
protected

Definition at line 37 of file ViewControlContainerTest.php.

37 : Data\Factory
38 {
39 return new Data\Factory();
40 }

Referenced by buildFieldFactory(), buildRefinery(), buildVCFactory(), and testViewControlContainerWithRequest().

+ Here is the caller graph for this function:

◆ buildFieldFactory()

ViewControlContainerTest::buildFieldFactory ( )
protected

Definition at line 55 of file ViewControlContainerTest.php.

55 : FieldFactory
56 {
57 return new FieldFactory(
58 $this->createMock(UploadLimitResolver::class),
59 new I\SignalGenerator(),
60 $this->buildDataFactory(),
61 $this->buildRefinery(),
62 $this->getLanguage()
63 );
64 }

References buildDataFactory(), buildRefinery(), and ILIAS_UI_TestBase\getLanguage().

Referenced by buildVCFactory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildRefinery()

ViewControlContainerTest::buildRefinery ( )
protected

Definition at line 41 of file ViewControlContainerTest.php.

41 : Refinery
42 {
43 return new Refinery(
44 $this->buildDataFactory(),
45 $this->createMock(ilLanguage::class)
46 );
47 }

References buildDataFactory().

Referenced by buildFieldFactory(), buildVCFactory(), and testViewControlContainerTransforms().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildVCFactory()

ViewControlContainerTest::buildVCFactory ( )
protected

Definition at line 66 of file ViewControlContainerTest.php.

67 {
68 return new Control\Factory(
69 $this->buildFieldFactory(),
70 $this->buildDataFactory(),
71 $this->buildRefinery(),
72 new I\SignalGenerator(),
73 $this->getLanguage(),
74 );
75 }
Builds data types.
Definition: Factory.php:21

References buildDataFactory(), buildFieldFactory(), buildRefinery(), and ILIAS_UI_TestBase\getLanguage().

Referenced by buildContainerFactory(), testViewControlContainerTransforms(), testViewControlContainerWithControls(), and testViewControlContainerWithRequest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testViewControlContainerConstruct()

ViewControlContainerTest::testViewControlContainerConstruct ( )

Definition at line 77 of file ViewControlContainerTest.php.

77 : void
78 {
79 $vc = $this->buildContainerFactory()->standard([]);
80 $this->assertInstanceOf(VC\ViewControl::class, $vc);
81 $this->assertInstanceOf(I\Signal::class, $vc->getSubmissionSignal());
82 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21

References buildContainerFactory().

+ Here is the call graph for this function:

◆ testViewControlContainerTransforms()

ViewControlContainerTest::testViewControlContainerTransforms ( )

Definition at line 140 of file ViewControlContainerTest.php.

140 : void
141 {
142 $transform = $this->buildRefinery()->custom()->transformation(
143 fn ($v) => ['modified' => 'transformed']
144 );
145
146 $request = $this->createMock(ServerRequestInterface::class);
147 $request->expects($this->once())
148 ->method("getQueryParams")
149 ->willReturn(['some' => 'data']);
150
151 $controls = [
152 $this->buildVCFactory()->fieldSelection(['a1' => 'A'])
153 ];
154 $vc = $this->buildContainerFactory()->standard($controls)
155 ->withAdditionalTransformation($transform)
156 ->withRequest($request);
157
158
159 $expected = ['modified' => 'transformed'];
160 $this->assertEquals($expected, $vc->getData());
161 }

References buildContainerFactory(), buildRefinery(), and buildVCFactory().

+ Here is the call graph for this function:

◆ testViewControlContainerWithControls()

ViewControlContainerTest::testViewControlContainerWithControls ( )

Definition at line 84 of file ViewControlContainerTest.php.

84 : void
85 {
86 $c_factory = $this->buildVCFactory();
87 $controls = [
88 $c_factory->fieldSelection([]),
89 $c_factory->sortation([]),
90 $c_factory->pagination()
91 ];
92
93 $name_source = new FormInputNameSource();
94 $vc = $this->buildContainerFactory()->standard($controls);
95 $this->assertSameSize($controls, $vc->getInputs());
96
97 $named = array_map(
98 fn ($input) => $input->withNameFrom($name_source, 'view_control'),
99 $vc->getInputs()
100 );
101
102 $this->assertEquals($named, $vc->getInputs());
103 }
FormInputNameSource is responsible for generating continuous form input names.

References buildContainerFactory(), and buildVCFactory().

+ Here is the call graph for this function:

◆ testViewControlContainerWithRequest()

ViewControlContainerTest::testViewControlContainerWithRequest ( )

Definition at line 105 of file ViewControlContainerTest.php.

105 : void
106 {
107 $request = $this->createMock(ServerRequestInterface::class);
108 $request
109 ->expects($this->once())
110 ->method("getQueryParams")
111 ->willReturn([
112 'view_control/input_0' => ['a1', 'a3'],
113 'view_control/input_1/input_2' => 'a2',
114 'view_control/input_1/input_3' => 'DESC'
115 ]);
116
117 $c_factory = $this->buildVCFactory();
118 $controls = [
119 $c_factory->fieldSelection(['a1' => 'A','a2' => 'B','a3' => 'C']),
120 $c_factory->sortation([
121 '2up' => new Data\Order('a2', 'ASC'),
122 '2down' => new Data\Order('a2', 'DESC')
123 ]),
124 ];
125
126 $vc = $this->buildContainerFactory()->standard($controls);
127 $vc2 = $vc->withRequest($request);
128 $this->assertNotSame($vc2, $vc);
129
130 $data = $vc2->getData();
131 $this->assertSameSize($controls, $data);
132
133 $expected = [
134 ['a1','a3'],
135 $this->buildDataFactory()->order('a2', 'DESC')
136 ];
137 $this->assertEquals($expected, array_values($data));
138 }
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:13

References $data, buildContainerFactory(), buildDataFactory(), and buildVCFactory().

+ Here is the call graph for this function:

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