1 <?php declare(strict_types=1);
42 ->expects($this->any())
44 ->willReturn(
'dummy');
71 $this->assertEquals(
'usr_global_role', $criterion->getTypeIdent());
72 $this->assertEquals(
false, $criterion->hasUniqueNature());
85 string $httpCriterionSelectionBodyParameter
92 ->expects($this->any())
93 ->method(
'getPostVar')
94 ->willReturn($httpCriterionSelectionBodyParameter);
96 $form->addItem($radioGroup);
115 $httpCriterionSelectionBodyParameter =
'criterion';
116 $httpCriterionConfigBodyParameter = $criterion->
getTypeIdent() .
'_role_id';
118 $gui = $criterion->
ui($this->lng);
120 $this->assertInstanceOf(ilTermsOfServiceUserHasGlobalRoleCriterionGUI::class, $gui);
122 $form = $this->
buildForm($gui, $httpCriterionSelectionBodyParameter);
124 $roleSelection = $form->getItemByPostVar($httpCriterionConfigBodyParameter);
125 $this->assertInstanceOf(ilSelectInputGUI::class, $roleSelection);
139 $httpCriterionSelectionBodyParameter =
'criterion';
140 $httpCriterionConfigBodyParameter = $criterion->
getTypeIdent() .
'_role_id';
142 $gui = $criterion->
ui($this->lng);
144 $form = $this->
buildForm($gui, $httpCriterionSelectionBodyParameter);
147 ->expects($this->once())
149 ->with($httpCriterionConfigBodyParameter)
150 ->will($this->returnCallback(
function () {
154 $value = $gui->getConfigByForm($form);
156 $this->assertInstanceOf(ilTermsOfServiceCriterionConfig::class, $value);
157 $this->assertEquals($this->expectedAfterFormSubmitValue, $value[
'role_id']);
158 $this->assertEquals($this->
getCriterionConfig([
'role_id' => $this->expectedAfterFormSubmitValue]), $value);
168 $gui = $criterion->
ui($this->lng);
170 $actual = $gui->getIdentPresentation();
172 $this->assertIsString($actual);
173 $this->assertNotEmpty($actual);
184 'Invalid Role Id' => [-1,
''],
194 public function testValuePresentationMatchesExpectation(
int $roleId,
string $roleTitle) :
void 200 ->expects($this->any())
201 ->method(
'lookupTitle')
203 ->willReturn($roleTitle);
206 $gui = $criterion->ui($this->lng);
209 $actual = $gui->getValuePresentation(
214 $this->assertInstanceOf(Component::class, $actual);
215 $this->assertInstanceOf(Legacy::class, $actual);
216 $this->assertEquals($roleTitle, $actual->getContent());
232 'Wrong Key Provided for Extracting Role' => [
252 $this->assertFalse($criterion->
evaluate($user, $config));
264 ->expects($this->once())
265 ->method(
'isGlobalRole')
269 $criterion->evaluate($user, $this->getCriterionConfig([
'role_id' => $this->expectedAfterFormSubmitValue]))
282 ->expects($this->once())
283 ->method(
'isGlobalRole')
287 ->expects($this->once())
288 ->method(
'isAssigned')
292 $criterion->evaluate($user, $this->getCriterionConfig([
'role_id' => $this->expectedAfterFormSubmitValue]))
305 ->expects($this->once())
306 ->method(
'isGlobalRole')
310 ->expects($this->once())
311 ->method(
'isAssigned')
315 $criterion->evaluate($user, $this->getCriterionConfig([
'role_id' => $this->expectedAfterFormSubmitValue]))
getTypeIdent()
Returns a unique id of the criterion type.string
Interface ilTermsOfServiceCriterionTypeGUI.
testEvaluationFailsIfConfiguredRoleDoesNotMatchTheExpectedFormat(ilTermsOfServiceUserHasGlobalRoleCriterion $criterion, ilTermsOfServiceCriterionConfig $config)
Class ilTermsOfServiceUserHasGlobalRoleCriterion.
testEvaluationSucceedsIfUserIsAssignedToDefinedGlobalRole()
testEvaluationFailsIfUserIsNotAssignedToConfiguredGlobalRole()
Class ilTermsOfServiceCriterionBaseTest.
buildForm(ilTermsOfServiceCriterionTypeGUI $gui, string $httpCriterionSelectionBodyParameter)
Class ilTermsOfServiceUserHasGlobalRoleCriterionTest.
testFormUserInterfaceElementsAreProperlyBuilt(ilTermsOfServiceUserHasGlobalRoleCriterion $criterion)
Class ilTermsOfServiceCriterionConfig.
ui(ilLanguage $lng)
ilTermsOfServiceCriterionTypeGUI
testTypeIdentPresentationIsANonEmptyString(ilTermsOfServiceUserHasGlobalRoleCriterion $criterion)
testFormUserInterfaceElementsAreProperlyBuilt
getCriterionConfig($value=null)
evaluate(ilObjUser $user, ilTermsOfServiceCriterionConfig $config)
bool
testEvaluationFailsIfConfiguredRoleIsNotAGlobalRole()
$expectedAfterFormSubmitValue
testValuesFromFormUserInterfaceElementsCanBeRetrieved(ilTermsOfServiceUserHasGlobalRoleCriterion $criterion)
testFormUserInterfaceElementsAreProperlyBuilt
appendOption(ilRadioGroupInputGUI $option, ilTermsOfServiceCriterionConfig $config)
testInstanceCanBeCreated()