ILIAS  release_8 Revision v8.24
ilTermsOfServiceSettingsFormGUITest Class Reference

Class ilTermsOfServiceSettingsFormGUITest. More...

+ Inheritance diagram for ilTermsOfServiceSettingsFormGUITest:
+ Collaboration diagram for ilTermsOfServiceSettingsFormGUITest:

Public Member Functions

 testFormCanBeProperlyBuilt ()
 
 testFormCanBeSavedWithDisabledService ()
 
 testFormCanBeSavedWithEnabledServiceWhenAtLeastOneDocumentExists ()
 
 testFormCannotBeSavedWithEnabledServiceWhenNoDocumentsExistAndServiceIsCurrentlyDisabled ()
 
 testFormCanBeSavedWithEnabledServiceWhenNoDocumentsExistButServiceIsAlreadyEnabled ()
 

Additional Inherited Members

- Protected Member Functions inherited from ilTermsOfServiceBaseTest
 setUp ()
 
 getLanguageMock ()
 
 getUiFactoryMock ()
 
 setGlobalVariable (string $name, $value)
 
 getCriterionConfig ($value=null)
 
- Protected Attributes inherited from ilTermsOfServiceBaseTest
Container $dic
 

Detailed Description

Member Function Documentation

◆ testFormCanBeProperlyBuilt()

ilTermsOfServiceSettingsFormGUITest::testFormCanBeProperlyBuilt ( )

Definition at line 27 of file ilTermsOfServiceSettingsFormGUITest.php.

27 : void
28 {
29 $tos = $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock();
30
31 $tos
32 ->method('getStatus')
33 ->willReturn(true);
34
35 $lng = $this->getLanguageMock();
36
37 $lng
38 ->method('txt')
39 ->willReturn('translation');
40
41 $this->setGlobalVariable('lng', $lng);
42
44 $tos,
45 '',
46 'save',
47 true
48 );
49
50 $this->assertCount(1, $form->getCommandButtons(), 'Failed asserting save button is given if form is editable');
51 $this->assertArrayHasKey(
52 0,
53 $form->getCommandButtons(),
54 'Failed asserting save button ist given if form is editable'
55 );
56 $this->assertSame(
57 'save',
58 $form->getCommandButtons()[0]['cmd'],
59 'Failed asserting save button ist given if form is editable'
60 );
61
63 $tos,
64 '',
65 'save',
66 false
67 );
68
69 $this->assertCount(
70 0,
71 $form->getCommandButtons(),
72 'Failed asserting no button is given if form is not editable'
73 );
74 }
setGlobalVariable(string $name, $value)
Class ilTermsOfServiceSettingsFormGUI.
$lng

References $lng, ilTermsOfServiceBaseTest\getLanguageMock(), and ilTermsOfServiceBaseTest\setGlobalVariable().

+ Here is the call graph for this function:

◆ testFormCanBeSavedWithDisabledService()

ilTermsOfServiceSettingsFormGUITest::testFormCanBeSavedWithDisabledService ( )

Definition at line 76 of file ilTermsOfServiceSettingsFormGUITest.php.

76 : void
77 {
78 $tos = $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock();
79
80 $tos
81 ->method('getStatus')
82 ->willReturn(false);
83
84 $tos
85 ->expects($this->once())
86 ->method('saveStatus')
87 ->with(false);
88
89 $form = $this->getMockBuilder(ilTermsOfServiceSettingsFormGUI::class)
90 ->setConstructorArgs([
91 $tos,
92 '',
93 'save',
94 true
95 ])
96 ->onlyMethods(['checkInput', 'getInput'])
97 ->getMock();
98
99 $form
100 ->expects($this->once())
101 ->method('checkInput')
102 ->willReturn(true);
103
104 $form
105 ->expects($this->exactly(2))
106 ->method('getInput')
107 ->willReturn(0);
108
109 $form->setCheckInputCalled(true);
110
111 $this->assertTrue($form->saveObject());
112 $this->assertFalse($form->hasTranslatedError());
113 $this->assertEmpty($form->getTranslatedError());
114 }

◆ testFormCanBeSavedWithEnabledServiceWhenAtLeastOneDocumentExists()

ilTermsOfServiceSettingsFormGUITest::testFormCanBeSavedWithEnabledServiceWhenAtLeastOneDocumentExists ( )

Definition at line 116 of file ilTermsOfServiceSettingsFormGUITest.php.

116 : void
117 {
118 $tos = $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock();
119
120 $tos
121 ->method('getStatus')
122 ->willReturn(false);
123
124 $tos
125 ->expects($this->once())
126 ->method('saveStatus')
127 ->with(true);
128
129 $form = $this->getMockBuilder(ilTermsOfServiceSettingsFormGUI::class)
130 ->setConstructorArgs([
131 $tos,
132 '',
133 'save',
134 true
135 ])
136 ->onlyMethods(['checkInput', 'getInput'])
137 ->getMock();
138
139 $form
140 ->expects($this->once())
141 ->method('checkInput')
142 ->willReturn(true);
143
144 $form
145 ->expects($this->exactly(3))
146 ->method('getInput')
147 ->willReturn(1);
148
149 $form->setCheckInputCalled(true);
150
151 $documentConnector = $this->getMockBuilder(arConnector::class)->getMock();
152
153 $documentConnector
154 ->expects($this->once())
155 ->method('affectedRows')
156 ->willReturn(2);
157
158 arConnectorMap::register(new ilTermsOfServiceDocument(), $documentConnector);
159
160 $this->assertTrue($form->saveObject());
161 $this->assertFalse($form->hasTranslatedError());
162 $this->assertEmpty($form->getTranslatedError());
163 }
static register(ActiveRecord $ar, arConnector $connector)
Class ilTermsOfServiceDocument.

References arConnectorMap\register().

+ Here is the call graph for this function:

◆ testFormCanBeSavedWithEnabledServiceWhenNoDocumentsExistButServiceIsAlreadyEnabled()

ilTermsOfServiceSettingsFormGUITest::testFormCanBeSavedWithEnabledServiceWhenNoDocumentsExistButServiceIsAlreadyEnabled ( )

Definition at line 221 of file ilTermsOfServiceSettingsFormGUITest.php.

221 : void
222 {
223 $tos = $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock();
224
225 $tos
226 ->method('getStatus')
227 ->willReturn(true);
228
229 $tos
230 ->expects($this->once())
231 ->method('saveStatus');
232
233 $form = $this->getMockBuilder(ilTermsOfServiceSettingsFormGUI::class)
234 ->setConstructorArgs([
235 $tos,
236 '',
237 'save',
238 true
239 ])
240 ->onlyMethods(['checkInput', 'getInput'])
241 ->getMock();
242
243 $form
244 ->expects($this->once())
245 ->method('checkInput')
246 ->willReturn(true);
247
248 $form
249 ->expects($this->exactly(3))
250 ->method('getInput')
251 ->willReturn(1);
252
253 $form->setCheckInputCalled(true);
254
255 $documentConnector = $this->getMockBuilder(arConnector::class)->getMock();#
256
257 $documentConnector
258 ->expects($this->once())
259 ->method('affectedRows')
260 ->willReturn(0);
261
262 arConnectorMap::register(new ilTermsOfServiceDocument(), $documentConnector);
263
264 $this->assertTrue($form->saveObject());
265 $this->assertFalse($form->hasTranslatedError());
266 $this->assertEmpty($form->getTranslatedError());
267 }

References arConnectorMap\register().

+ Here is the call graph for this function:

◆ testFormCannotBeSavedWithEnabledServiceWhenNoDocumentsExistAndServiceIsCurrentlyDisabled()

ilTermsOfServiceSettingsFormGUITest::testFormCannotBeSavedWithEnabledServiceWhenNoDocumentsExistAndServiceIsCurrentlyDisabled ( )

Definition at line 165 of file ilTermsOfServiceSettingsFormGUITest.php.

165 : void
166 {
167 $lng = $this->getLanguageMock();
168
169 $lng
170 ->method('txt')
171 ->willReturn('translation');
172
173 $this->setGlobalVariable('lng', $lng);
174
175 $tos = $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock();
176
177 $tos
178 ->method('getStatus')
179 ->willReturn(false);
180
181 $tos
182 ->expects($this->never())
183 ->method('saveStatus');
184
185 $form = $this->getMockBuilder(ilTermsOfServiceSettingsFormGUI::class)
186 ->setConstructorArgs([
187 $tos,
188 '',
189 'save',
190 true
191 ])
192 ->onlyMethods(['checkInput', 'getInput'])
193 ->getMock();
194
195 $form
196 ->expects($this->once())
197 ->method('checkInput')
198 ->willReturn(true);
199
200 $form
201 ->expects($this->once())
202 ->method('getInput')
203 ->willReturn(1);
204
205 $form->setCheckInputCalled(true);
206
207 $documentConnector = $this->getMockBuilder(arConnector::class)->getMock();#
208
209 $documentConnector
210 ->expects($this->once())
211 ->method('affectedRows')
212 ->willReturn(0);
213
214 arConnectorMap::register(new ilTermsOfServiceDocument(), $documentConnector);
215
216 $this->assertFalse($form->saveObject());
217 $this->assertTrue($form->hasTranslatedError());
218 $this->assertNotEmpty($form->getTranslatedError());
219 }

References $lng, ilTermsOfServiceBaseTest\getLanguageMock(), arConnectorMap\register(), and ilTermsOfServiceBaseTest\setGlobalVariable().

+ Here is the call graph for this function:

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