ILIAS  release_7 Revision v7.30-3-g800a261c036
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

 setUp ()
 
 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

 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

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

Detailed Description

Member Function Documentation

◆ buildForm()

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

Definition at line 83 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

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

Referenced by testFormUserInterfaceElementsAreProperlyBuilt(), and testValuesFromFormUserInterfaceElementsCanBeRetrieved().

87  $form = $this->getFormMock();
88 
89  $radioGroup = $this->getRadioGroupMock();
90 
91  $radioGroup
92  ->expects($this->any())
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  }
This class represents a property form user interface.
Class ilTermsOfServiceCriterionConfig.
appendOption(ilRadioGroupInputGUI $option, ilTermsOfServiceCriterionConfig $config)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ failingConfigProvider()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::failingConfigProvider ( )
Returns
array
Exceptions
ReflectionException

Definition at line 223 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

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

223  : array
224  {
225  $criterion = $this->getInstance();
226 
227  return [
228  'Array' => [$criterion, $this->getCriterionConfig(['role_id' => []])],
229  'Object' => [$criterion, $this->getCriterionConfig(['role_id' => new stdClass()])],
230  'Double' => [$criterion, $this->getCriterionConfig(['role_id' => 1.424])],
231  'String' => [$criterion, $this->getCriterionConfig(['role_id' => 'phpunit'])],
232  'Wrong Key Provided for Extracting Role' => [
233  $criterion,
234  $this->getCriterionConfig(['another_config_key' => true])
235  ],
236  'Empty Configuration' => [$criterion, $this->getCriterionConfig()],
237  ];
238  }
+ Here is the call graph for this function:

◆ getInstance()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::getInstance ( )
protected

◆ objectCacheProvider()

◆ setUp()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::setUp ( )

Definition at line 35 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

References ilTermsOfServiceBaseTest\getLanguageMock().

35  : void
36  {
37  parent::setUp();
38 
39  $this->lng = $this->getLanguageMock();
40 
41  $this->lng
42  ->expects($this->any())
43  ->method('txt')
44  ->willReturn('dummy');
45  }
+ Here is the call graph for this function:

◆ testEvaluationFailsIfConfiguredRoleDoesNotMatchTheExpectedFormat()

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

Definition at line 246 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

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

249  : void {
250  $user = $this->getUserMock();
251 
252  $this->assertFalse($criterion->evaluate($user, $config));
253  }
evaluate(ilObjUser $user, ilTermsOfServiceCriterionConfig $config)
bool
+ Here is the call graph for this function:

◆ testEvaluationFailsIfConfiguredRoleIsNotAGlobalRole()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::testEvaluationFailsIfConfiguredRoleIsNotAGlobalRole ( )
Exceptions
ReflectionException

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(false);
267 
268  $this->assertFalse(
269  $criterion->evaluate($user, $this->getCriterionConfig(['role_id' => $this->expectedAfterFormSubmitValue]))
270  );
271  }
+ Here is the call graph for this function:

◆ testEvaluationFailsIfUserIsNotAssignedToConfiguredGlobalRole()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::testEvaluationFailsIfUserIsNotAssignedToConfiguredGlobalRole ( )
Exceptions
ReflectionException

Definition at line 276 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

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

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

◆ testEvaluationSucceedsIfUserIsAssignedToDefinedGlobalRole()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::testEvaluationSucceedsIfUserIsAssignedToDefinedGlobalRole ( )
Exceptions
ReflectionException

Definition at line 299 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

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

299  : void
300  {
301  $user = $this->getUserMock();
302  $criterion = $this->getInstance();
303 
304  $this->rbacReview
305  ->expects($this->once())
306  ->method('isGlobalRole')
307  ->willReturn(true);
308 
309  $this->rbacReview
310  ->expects($this->once())
311  ->method('isAssigned')
312  ->willReturn(true);
313 
314  $this->assertTrue(
315  $criterion->evaluate($user, $this->getCriterionConfig(['role_id' => $this->expectedAfterFormSubmitValue]))
316  );
317  }
+ Here is the call graph for this function:

◆ testFormUserInterfaceElementsAreProperlyBuilt()

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

Definition at line 112 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

References $expectedInitialValue, buildForm(), ilTermsOfServiceUserHasGlobalRoleCriterion\getTypeIdent(), and ilTermsOfServiceUserHasGlobalRoleCriterion\ui().

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

◆ testInstanceCanBeCreated()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::testInstanceCanBeCreated ( )
Returns
ilTermsOfServiceUserHasGlobalRoleCriterion
Exceptions
ReflectionException

Definition at line 67 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

References getInstance().

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

◆ testTypeIdentPresentationIsANonEmptyString()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::testTypeIdentPresentationIsANonEmptyString ( ilTermsOfServiceUserHasGlobalRoleCriterion  $criterion)

testFormUserInterfaceElementsAreProperlyBuilt

Parameters
ilTermsOfServiceUserHasGlobalRoleCriterion$criterion

Definition at line 165 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

References ilTermsOfServiceUserHasGlobalRoleCriterion\ui().

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

◆ testValuesFromFormUserInterfaceElementsCanBeRetrieved()

ilTermsOfServiceUserHasGlobalRoleCriterionTest::testValuesFromFormUserInterfaceElementsCanBeRetrieved ( ilTermsOfServiceUserHasGlobalRoleCriterion  $criterion)

testFormUserInterfaceElementsAreProperlyBuilt

Parameters
ilTermsOfServiceUserHasGlobalRoleCriterion$criterion
Exceptions
ReflectionException

Definition at line 136 of file ilTermsOfServiceUserHasGlobalRoleCriterionTest.php.

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

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

Field Documentation

◆ $adminRoleTitle

ilTermsOfServiceUserHasGlobalRoleCriterionTest::$adminRoleTitle = 'Administrator'
protected

◆ $expectedAfterFormSubmitValue

ilTermsOfServiceUserHasGlobalRoleCriterionTest::$expectedAfterFormSubmitValue = 4
protected

◆ $expectedInitialValue

ilTermsOfServiceUserHasGlobalRoleCriterionTest::$expectedInitialValue = 2
protected

◆ $lng

ilTermsOfServiceUserHasGlobalRoleCriterionTest::$lng
protected

◆ $rbacReview

ilTermsOfServiceUserHasGlobalRoleCriterionTest::$rbacReview
protected

◆ $userRoleTitle

ilTermsOfServiceUserHasGlobalRoleCriterionTest::$userRoleTitle = 'User'
protected

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