1 <?php declare(strict_types=1);
41 ->expects($this->any())
43 ->willReturn(
'dummy');
45 $this->countries = [
'EN',
'DE'];
63 $this->assertEquals(
'usr_country', $criterion->getTypeIdent());
64 $this->assertEquals(
true, $criterion->hasUniqueNature());
77 string $httpCriterionSelectionBodyParameter
84 ->expects($this->any())
85 ->method(
'getPostVar')
86 ->willReturn($httpCriterionSelectionBodyParameter);
88 $form->addItem($radioGroup);
104 $httpCriterionSelectionBodyParameter =
'criterion';
105 $httpCriterionConfigBodyParameter = $criterion->
getTypeIdent() .
'_country';
107 $gui = $criterion->
ui($this->lng);
109 $this->assertInstanceOf(ilTermsOfServiceUserHasCountryCriterionGUI::class, $gui);
111 $form = $this->
buildForm($gui, $httpCriterionSelectionBodyParameter);
113 $countrySelection = $form->getItemByPostVar($httpCriterionConfigBodyParameter);
114 $this->assertInstanceOf(ilSelectInputGUI::class, $countrySelection);
128 $httpCriterionSelectionBodyParameter =
'criterion';
129 $httpCriterionConfigBodyParameter = $criterion->
getTypeIdent() .
'_country';
131 $gui = $criterion->
ui($this->lng);
133 $form = $this->
buildForm($gui, $httpCriterionSelectionBodyParameter);
136 ->expects($this->once())
138 ->with($httpCriterionConfigBodyParameter)
139 ->will($this->returnCallback(
function () {
143 $value = $gui->getConfigByForm($form);
145 $this->assertInstanceOf(ilTermsOfServiceCriterionConfig::class, $value);
146 $this->assertEquals($this->expectedAfterFormSubmitValue, $value[
'country']);
147 $this->assertEquals($this->
getCriterionConfig([
'country' => $this->expectedAfterFormSubmitValue]), $value);
157 $gui = $criterion->
ui($this->lng);
159 $actual = $gui->getIdentPresentation();
161 $this->assertIsString($actual);
162 $this->assertNotEmpty($actual);
173 'Invalid Languages' => [
'invalid_country',
''],
183 public function testValuePresentationMatchesExpectation(
string $country,
string $translation) :
void 188 ->expects($this->any())
190 ->with(
'meta_c_' . $country,
'')
191 ->willReturn($translation);
194 $gui = $criterion->ui($language);
197 $actual = $gui->getValuePresentation(
202 $this->assertInstanceOf(Component::class, $actual);
203 $this->assertInstanceOf(Legacy::class, $actual);
204 $this->assertEquals($translation, $actual->getContent());
215 'English Language where German is Expected' => [$criterion, $this->
getCriterionConfig([
'country' =>
'en'])],
220 'Wrong Key Provided for Extracting Language' => [
237 'German Language Uppercase' => [$criterion, $this->
getCriterionConfig([
'country' =>
'DE'])],
254 ->expects($this->any())
255 ->method(
'getSelectedCountry')
258 $this->assertFalse($criterion->
evaluate($user, $config));
274 ->expects($this->any())
275 ->method(
'getSelectedCountry')
278 $this->assertTrue($criterion->
evaluate($user, $config));
$germanLanguageTranslation
Class ilTermsOfServiceUserHasCountryCriterionTest.
Interface ilTermsOfServiceCriterionTypeGUI.
testInstanceCanBeCreated()
Class ilTermsOfServiceCriterionBaseTest.
ui(ilLanguage $lng)
ilTermsOfServiceCriterionTypeGUI
Class ilTermsOfServiceCriterionConfig.
getTypeIdent()
Returns a unique id of the criterion type.string
getCriterionConfig($value=null)
testValuesFromFormUserInterfaceElementsCanBeRetrieved(ilTermsOfServiceUserHasCountryCriterion $criterion)
testFormUserInterfaceElementsAreProperlyBuilt
testEvaluationFailsIfUserCountryDoesNotMatchDefinedLanguage(ilTermsOfServiceUserHasCountryCriterion $criterion, ilTermsOfServiceCriterionConfig $config)
Class ilTermsOfServiceUserHasCountryCriterion.
buildForm(ilTermsOfServiceCriterionTypeGUI $gui, string $httpCriterionSelectionBodyParameter)
testEvaluationSucceedsIfUserCountryDoesMatchDefinedLanguage(ilTermsOfServiceUserHasCountryCriterion $criterion, ilTermsOfServiceCriterionConfig $config)
$englishLanguageTranslation
testFormUserInterfaceElementsAreProperlyBuilt(ilTermsOfServiceUserHasCountryCriterion $criterion)
testTypeIdentPresentationIsANonEmptyString(ilTermsOfServiceUserHasCountryCriterion $criterion)
testFormUserInterfaceElementsAreProperlyBuilt
evaluate(ilObjUser $user, ilTermsOfServiceCriterionConfig $config)
bool
succeedingConfigProvider()
$expectedAfterFormSubmitValue
appendOption(ilRadioGroupInputGUI $option, ilTermsOfServiceCriterionConfig $config)