ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTermsOfServiceUserHasGlobalRoleCriterionTest Class Reference

Class ilTermsOfServiceUserHasGlobalRoleCriterionTest. More...

+ Inheritance diagram for ilTermsOfServiceUserHasGlobalRoleCriterionTest:
+ Collaboration diagram for ilTermsOfServiceUserHasGlobalRoleCriterionTest:

Public Member Functions

 testInstanceCanBeCreated ()
 
 testFormUserInterfaceElementsAreProperlyBuilt (ilTermsOfServiceUserHasGlobalRoleCriterion $criterion)
 
 testValuesFromFormUserInterfaceElementsCanBeRetrieved (ilTermsOfServiceUserHasGlobalRoleCriterion $criterion)
 testFormUserInterfaceElementsAreProperlyBuilt More...
 
 testTypeIdentPresentationIsANonEmptyString (ilTermsOfServiceUserHasGlobalRoleCriterion $criterion)
 testFormUserInterfaceElementsAreProperlyBuilt More...
 
 objectCacheProvider ()
 
 failingConfigProvider ()
 
 testEvaluationFailsIfConfiguredRoleDoesNotMatchTheExpectedFormat (ilTermsOfServiceUserHasGlobalRoleCriterion $criterion, ilTermsOfServiceCriterionConfig $config)
 
 testEvaluationFailsIfConfiguredRoleIsNotAGlobalRole ()
 
 testEvaluationFailsIfUserIsNotAssignedToConfiguredGlobalRole ()
 
 testEvaluationSucceedsIfUserIsAssignedToDefinedGlobalRole ()
 

Protected Member Functions

 setUp ()
 
 getInstance ()
 
 buildForm (ilTermsOfServiceCriterionTypeGUI $gui, string $httpCriterionSelectionBodyParameter)
 
- Protected Member Functions inherited from ilTermsOfServiceCriterionBaseTest
 getRbacReviewMock ()
 
 getObjectDataCacheMock ()
 
 getRadioGroupMock ()
 
 getFormMock ()
 
 getUserMock ()
 
- Protected Member Functions inherited from ilTermsOfServiceBaseTest
 setUp ()
 
 getLanguageMock ()
 
 getUiFactoryMock ()
 
 setGlobalVariable (string $name, $value)
 
 getCriterionConfig ($value=null)
 

Protected Attributes

ilRbacReview $rbacReview
 
ilLanguage $lng
 
int $expectedInitialValue = 2
 
int $expectedAfterFormSubmitValue = 4
 
string $userRoleTitle = 'User'
 
string $adminRoleTitle = 'Administrator'
 
- Protected Attributes inherited from ilTermsOfServiceBaseTest
Container $dic
 

Detailed Description

Member Function Documentation

◆ buildForm()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::buildForm ( ilTermsOfServiceCriterionTypeGUI  $gui,
string  $httpCriterionSelectionBodyParameter 
)
protected
Parameters
ilTermsOfServiceCriterionTypeGUI$gui
string$httpCriterionSelectionBodyParameter
Returns
MockObject&ilPropertyFormGUI

Definition at line 84 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

References ilTermsOfServiceCriterionTypeGUI\appendOption(), ilTermsOfServiceCriterionBaseTest\getFormMock(), and ilTermsOfServiceCriterionBaseTest\getRadioGroupMock().

Referenced by testFormUserInterfaceElementsAreProperlyBuilt(), and testValuesFromFormUserInterfaceElementsCanBeRetrieved().

88  $form = $this->getFormMock();
89 
90  $radioGroup = $this->getRadioGroupMock();
91 
92  $radioGroup
93  ->method('getPostVar')
94  ->willReturn($httpCriterionSelectionBodyParameter);
95 
96  $form->addItem($radioGroup);
97 
98  $gui->appendOption(
99  $radioGroup,
100  new ilTermsOfServiceCriterionConfig(['role_id' => $this->expectedInitialValue])
101  );
102 
103  return $form;
104  }
Class ilTermsOfServiceCriterionConfig.
appendOption(ilRadioGroupInputGUI $group, ilTermsOfServiceCriterionConfig $config)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ failingConfigProvider()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::failingConfigProvider ( )

Definition at line 212 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

References ilTermsOfServiceBaseTest\getCriterionConfig(), and getInstance().

212  : array
213  {
214  $criterion = $this->getInstance();
215 
216  return [
217  'Array' => [$criterion, $this->getCriterionConfig(['role_id' => []])],
218  'Object' => [$criterion, $this->getCriterionConfig(['role_id' => new stdClass()])],
219  'Double' => [$criterion, $this->getCriterionConfig(['role_id' => 1.424])],
220  'String' => [$criterion, $this->getCriterionConfig(['role_id' => 'phpunit'])],
221  'Wrong Key Provided for Extracting Role' => [
222  $criterion,
223  $this->getCriterionConfig(['another_config_key' => true])
224  ],
225  'Empty Configuration' => [$criterion, $this->getCriterionConfig()],
226  ];
227  }
+ Here is the call graph for this function:

◆ getInstance()

◆ objectCacheProvider()

◆ setUp()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::setUp ( )
protected

Definition at line 40 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

References ilTermsOfServiceBaseTest\getLanguageMock(), and ILIAS\Repository\lng().

40  : void
41  {
42  parent::setUp();
43 
44  $this->lng = $this->getLanguageMock();
45 
46  $this->lng
47  ->method('txt')
48  ->willReturn('dummy');
49  }
+ Here is the call graph for this function:

◆ testEvaluationFailsIfConfiguredRoleDoesNotMatchTheExpectedFormat()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::testEvaluationFailsIfConfiguredRoleDoesNotMatchTheExpectedFormat ( ilTermsOfServiceUserHasGlobalRoleCriterion  $criterion,
ilTermsOfServiceCriterionConfig  $config 
)
Parameters
ilTermsOfServiceUserHasGlobalRoleCriterion$criterion
ilTermsOfServiceCriterionConfig$configfailingConfigProvider

Definition at line 234 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

References ilTermsOfServiceUserHasGlobalRoleCriterion\evaluate(), and ilTermsOfServiceCriterionBaseTest\getUserMock().

237  : void {
238  $user = $this->getUserMock();
239 
240  $this->assertFalse($criterion->evaluate($user, $config));
241  }
evaluate(ilObjUser $user, ilTermsOfServiceCriterionConfig $config)
+ Here is the call graph for this function:

◆ testEvaluationFailsIfConfiguredRoleIsNotAGlobalRole()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::testEvaluationFailsIfConfiguredRoleIsNotAGlobalRole ( )

Definition at line 243 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

References getInstance(), and ilTermsOfServiceCriterionBaseTest\getUserMock().

243  : void
244  {
245  $user = $this->getUserMock();
246  $criterion = $this->getInstance();
247 
248  $this->rbacReview
249  ->expects($this->once())
250  ->method('isGlobalRole')
251  ->willReturn(false);
252 
253  $this->assertFalse(
254  $criterion->evaluate($user, $this->getCriterionConfig(['role_id' => $this->expectedAfterFormSubmitValue]))
255  );
256  }
+ Here is the call graph for this function:

◆ testEvaluationFailsIfUserIsNotAssignedToConfiguredGlobalRole()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::testEvaluationFailsIfUserIsNotAssignedToConfiguredGlobalRole ( )

Definition at line 258 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

References getInstance(), and ilTermsOfServiceCriterionBaseTest\getUserMock().

258  : void
259  {
260  $user = $this->getUserMock();
261  $criterion = $this->getInstance();
262 
263  $this->rbacReview
264  ->expects($this->once())
265  ->method('isGlobalRole')
266  ->willReturn(true);
267 
268  $this->rbacReview
269  ->expects($this->once())
270  ->method('isAssigned')
271  ->willReturn(false);
272 
273  $this->assertFalse(
274  $criterion->evaluate($user, $this->getCriterionConfig(['role_id' => $this->expectedAfterFormSubmitValue]))
275  );
276  }
+ Here is the call graph for this function:

◆ testEvaluationSucceedsIfUserIsAssignedToDefinedGlobalRole()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::testEvaluationSucceedsIfUserIsAssignedToDefinedGlobalRole ( )

Definition at line 278 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

References getInstance(), and ilTermsOfServiceCriterionBaseTest\getUserMock().

278  : void
279  {
280  $user = $this->getUserMock();
281  $criterion = $this->getInstance();
282 
283  $this->rbacReview
284  ->expects($this->once())
285  ->method('isGlobalRole')
286  ->willReturn(true);
287 
288  $this->rbacReview
289  ->expects($this->once())
290  ->method('isAssigned')
291  ->willReturn(true);
292 
293  $this->assertTrue(
294  $criterion->evaluate($user, $this->getCriterionConfig(['role_id' => $this->expectedAfterFormSubmitValue]))
295  );
296  }
+ Here is the call graph for this function:

◆ testFormUserInterfaceElementsAreProperlyBuilt()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::testFormUserInterfaceElementsAreProperlyBuilt ( ilTermsOfServiceUserHasGlobalRoleCriterion  $criterion)
Parameters
ilTermsOfServiceUserHasGlobalRoleCriterion$criteriontestInstanceCanBeCreated
Returns
ilTermsOfServiceUserHasGlobalRoleCriterion

Definition at line 111 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

References buildForm(), ilTermsOfServiceUserHasGlobalRoleCriterion\getTypeIdent(), ILIAS\Repository\lng(), and ilTermsOfServiceUserHasGlobalRoleCriterion\ui().

114  $httpCriterionSelectionBodyParameter = 'criterion';
115  $httpCriterionConfigBodyParameter = $criterion->getTypeIdent() . '_role_id';
116 
117  $gui = $criterion->ui($this->lng);
118 
119  $this->assertInstanceOf(ilTermsOfServiceUserHasGlobalRoleCriterionGUI::class, $gui);
120 
121  $form = $this->buildForm($gui, $httpCriterionSelectionBodyParameter);
122 
123  $roleSelection = $form->getItemByPostVar($httpCriterionConfigBodyParameter);
124  $this->assertInstanceOf(ilSelectInputGUI::class, $roleSelection);
125  $this->assertEquals($roleSelection->getValue(), (string) $this->expectedInitialValue);
126 
127  return $criterion;
128  }
buildForm(ilTermsOfServiceCriterionTypeGUI $gui, string $httpCriterionSelectionBodyParameter)
+ Here is the call graph for this function:

◆ testInstanceCanBeCreated()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::testInstanceCanBeCreated ( )
Returns
ilTermsOfServiceUserHasGlobalRoleCriterion

Definition at line 69 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

References getInstance().

70  {
71  $criterion = $this->getInstance();
72 
73  $this->assertSame('usr_global_role', $criterion->getTypeIdent());
74  $this->assertFalse($criterion->hasUniqueNature());
75 
76  return $criterion;
77  }
+ Here is the call graph for this function:

◆ testTypeIdentPresentationIsANonEmptyString()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::testTypeIdentPresentationIsANonEmptyString ( ilTermsOfServiceUserHasGlobalRoleCriterion  $criterion)

testFormUserInterfaceElementsAreProperlyBuilt

Parameters
ilTermsOfServiceUserHasGlobalRoleCriterion$criterion

Definition at line 163 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

References ILIAS\Repository\lng(), and ilTermsOfServiceUserHasGlobalRoleCriterion\ui().

165  : void {
166  $gui = $criterion->ui($this->lng);
167 
168  $actual = $gui->getIdentPresentation();
169 
170  $this->assertIsString($actual);
171  $this->assertNotEmpty($actual);
172  }
+ Here is the call graph for this function:

◆ testValuesFromFormUserInterfaceElementsCanBeRetrieved()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::testValuesFromFormUserInterfaceElementsCanBeRetrieved ( ilTermsOfServiceUserHasGlobalRoleCriterion  $criterion)

testFormUserInterfaceElementsAreProperlyBuilt

Parameters
ilTermsOfServiceUserHasGlobalRoleCriterion$criterion

Definition at line 134 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

References $expectedAfterFormSubmitValue, buildForm(), ilTermsOfServiceBaseTest\getCriterionConfig(), ilTermsOfServiceUserHasGlobalRoleCriterion\getTypeIdent(), ILIAS\Repository\lng(), and ilTermsOfServiceUserHasGlobalRoleCriterion\ui().

136  : void {
137  $httpCriterionSelectionBodyParameter = 'criterion';
138  $httpCriterionConfigBodyParameter = $criterion->getTypeIdent() . '_role_id';
139 
140  $gui = $criterion->ui($this->lng);
141 
142  $form = $this->buildForm($gui, $httpCriterionSelectionBodyParameter);
143 
144  $form
145  ->expects($this->once())
146  ->method('getInput')
147  ->with($httpCriterionConfigBodyParameter)
148  ->willReturnCallback(function () {
150  });
151 
152  $value = $gui->getConfigByForm($form);
153 
154  $this->assertInstanceOf(ilTermsOfServiceCriterionConfig::class, $value);
155  $this->assertSame($this->expectedAfterFormSubmitValue, $value['role_id']);
156  $this->assertEquals($this->getCriterionConfig(['role_id' => $this->expectedAfterFormSubmitValue]), $value);
157  }
buildForm(ilTermsOfServiceCriterionTypeGUI $gui, string $httpCriterionSelectionBodyParameter)
+ Here is the call graph for this function:

Field Documentation

◆ $adminRoleTitle

string ilTermsOfServiceUserHasGlobalRoleCriterionTest::$adminRoleTitle = 'Administrator'
protected

◆ $expectedAfterFormSubmitValue

int ilTermsOfServiceUserHasGlobalRoleCriterionTest::$expectedAfterFormSubmitValue = 4
protected

◆ $expectedInitialValue

int ilTermsOfServiceUserHasGlobalRoleCriterionTest::$expectedInitialValue = 2
protected

◆ $lng

ilLanguage ilTermsOfServiceUserHasGlobalRoleCriterionTest::$lng
protected

◆ $rbacReview

ilRbacReview ilTermsOfServiceUserHasGlobalRoleCriterionTest::$rbacReview
protected

◆ $userRoleTitle

string ilTermsOfServiceUserHasGlobalRoleCriterionTest::$userRoleTitle = 'User'
protected

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