41 ->expects($this->any())
43 ->willReturn(
'dummy');
53 $criterion = new \ilTermsOfServiceUserHasGlobalRoleCriterion(
68 $this->assertEquals(
'usr_global_role', $criterion->getTypeIdent());
69 $this->assertEquals(
false, $criterion->hasUniqueNature());
81 string $httpCriterionSelectionBodyParameter
88 ->expects($this->any())
89 ->method(
'getPostVar')
90 ->willReturn($httpCriterionSelectionBodyParameter);
92 $form->addItem($radioGroup);
110 $httpCriterionSelectionBodyParameter =
'criterion';
111 $httpCriterionConfigBodyParameter = $criterion->
getTypeIdent() .
'_role_id';
113 $gui = $criterion->
ui($this->lng);
115 $this->assertInstanceOf(\ilTermsOfServiceUserHasGlobalRoleCriterionGUI::class, $gui);
117 $form = $this->
buildForm($gui, $httpCriterionSelectionBodyParameter);
119 $roleSelection =
$form->getItemByPostVar($httpCriterionConfigBodyParameter);
120 $this->assertInstanceOf(\ilSelectInputGUI::class, $roleSelection);
133 $httpCriterionSelectionBodyParameter =
'criterion';
134 $httpCriterionConfigBodyParameter = $criterion->
getTypeIdent() .
'_role_id';
136 $gui = $criterion->
ui($this->lng);
138 $form = $this->
buildForm($gui, $httpCriterionSelectionBodyParameter);
141 ->expects($this->
once())
143 ->with($httpCriterionConfigBodyParameter)
144 ->will($this->returnCallback(
function () {
148 $value = $gui->getConfigByForm(
$form);
150 $this->assertInstanceOf(\ilTermsOfServiceCriterionConfig::class, $value);
151 $this->assertEquals($this->expectedAfterFormSubmitValue, $value[
'role_id']);
152 $this->assertEquals($this->
getCriterionConfig([
'role_id' => $this->expectedAfterFormSubmitValue]), $value);
161 $gui = $criterion->
ui($this->lng);
163 $actual = $gui->getIdentPresentation();
165 $this->assertInternalType(
'string', $actual);
166 $this->assertNotEmpty($actual);
186 public function testValuePresentationMatchesExpectation(
int $roleId,
string $roleTitle)
192 ->expects($this->any())
193 ->method(
'lookupTitle')
195 ->willReturn($roleTitle);
197 $criterion = new \ilTermsOfServiceUserHasGlobalRoleCriterion(
$rbacReview, $objectDataCache);
198 $gui = $criterion->ui($this->lng);
201 $actual = $gui->getValuePresentation(
203 $this->dic->ui()->factory()
206 $this->assertInstanceOf(Component::class, $actual);
207 $this->assertInstanceOf(Legacy::class, $actual);
208 $this->assertEquals($roleTitle, $actual->getContent());
251 ->expects($this->
once())
252 ->method(
'isGlobalRole')
256 $criterion->evaluate(
$user, $this->getCriterionConfig([
'role_id' => $this->expectedAfterFormSubmitValue]))
269 ->expects($this->
once())
270 ->method(
'isGlobalRole')
274 ->expects($this->
once())
275 ->method(
'isAssigned')
279 $criterion->evaluate(
$user, $this->getCriterionConfig([
'role_id' => $this->expectedAfterFormSubmitValue]))
292 ->expects($this->
once())
293 ->method(
'isGlobalRole')
297 ->expects($this->
once())
298 ->method(
'isAssigned')
302 $criterion->evaluate(
$user, $this->getCriterionConfig([
'role_id' => $this->expectedAfterFormSubmitValue]))
getTypeIdent()
Returns a unique id of the criterion type.string
Interface ilTermsOfServiceCriterionTypeGUI.
testValuesFromFormUserInterfaceElementsCanBeRetrieved(\ilTermsOfServiceUserHasGlobalRoleCriterion $criterion)
testFormUserInterfaceElementsAreProperlyBuilt
Class ilTermsOfServiceUserHasGlobalRoleCriterion.
testEvaluationSucceedsIfUserIsAssignedToDefinedGlobalRole()
testEvaluationFailsIfUserIsNotAssignedToConfiguredGlobalRole()
Class ilTermsOfServiceCriterionBaseTest.
Class ilTermsOfServiceUserHasGlobalRoleCriterionTest.
testFormUserInterfaceElementsAreProperlyBuilt(\ilTermsOfServiceUserHasGlobalRoleCriterion $criterion)
Class ilTermsOfServiceCriterionConfig.
getCriterionConfig($value=null)
evaluate(\ilObjUser $user, \ilTermsOfServiceCriterionConfig $config)
bool
testEvaluationFailsIfConfiguredRoleIsNotAGlobalRole()
if(isset($_POST['submit'])) $form
buildForm(\ilTermsOfServiceCriterionTypeGUI $gui, string $httpCriterionSelectionBodyParameter)
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
$expectedAfterFormSubmitValue
appendOption(\ilRadioGroupInputGUI $option, \ilTermsOfServiceCriterionConfig $config)
testTypeIdentPresentationIsANonEmptyString(\ilTermsOfServiceUserHasGlobalRoleCriterion $criterion)
testFormUserInterfaceElementsAreProperlyBuilt
testEvaluationFailsIfConfiguredRoleDoesNotMatchTheExpectedFormat(\ilTermsOfServiceUserHasGlobalRoleCriterion $criterion, \ilTermsOfServiceCriterionConfig $config)
testInstanceCanBeCreated()