37 ->expects($this->any())
39 ->willReturn(
'dummy');
42 ->expects($this->any())
43 ->method(
'getInstalledLanguages')
44 ->willReturn([$this->expectedAfterFormSubmitValue, $this->expectedInitialValue]);
52 return new \ilTermsOfServiceUserHasLanguageCriterion();
62 $this->assertEquals(
'usr_language', $criterion->getTypeIdent());
63 $this->assertEquals(
true, $criterion->hasUniqueNature());
75 string $httpCriterionSelectionBodyParameter
82 ->expects($this->any())
83 ->method(
'getPostVar')
84 ->willReturn($httpCriterionSelectionBodyParameter);
86 $form->addItem($radioGroup);
100 $httpCriterionSelectionBodyParameter =
'criterion';
101 $httpCriterionConfigBodyParameter = $criterion->
getTypeIdent() .
'_lng';
103 $gui = $criterion->
ui($this->lng);
105 $this->assertInstanceOf(\ilTermsOfServiceUserHasLanguageCriterionGUI::class, $gui);
107 $form = $this->
buildForm($gui, $httpCriterionSelectionBodyParameter);
109 $languageSelection =
$form->getItemByPostVar($httpCriterionConfigBodyParameter);
110 $this->assertInstanceOf(\ilSelectInputGUI::class, $languageSelection);
122 $httpCriterionSelectionBodyParameter =
'criterion';
123 $httpCriterionConfigBodyParameter = $criterion->
getTypeIdent() .
'_lng';
125 $gui = $criterion->
ui($this->lng);
127 $form = $this->
buildForm($gui, $httpCriterionSelectionBodyParameter);
130 ->expects($this->
once())
132 ->with($httpCriterionConfigBodyParameter)
133 ->will($this->returnCallback(
function () {
137 $value = $gui->getConfigByForm(
$form);
139 $this->assertInstanceOf(\ilTermsOfServiceCriterionConfig::class, $value);
140 $this->assertEquals($this->expectedAfterFormSubmitValue, $value[
'lng']);
141 $this->assertEquals($this->
getCriterionConfig([
'lng' => $this->expectedAfterFormSubmitValue]), $value);
150 $gui = $criterion->
ui($this->lng);
152 $actual = $gui->getIdentPresentation();
154 $this->assertInternalType(
'string', $actual);
155 $this->assertNotEmpty($actual);
175 public function testValuePresentationMatchesExpectation(
string $lng,
string $translation)
180 ->expects($this->any())
182 ->with(
'meta_l_' . $lng,
'')
183 ->willReturn($translation);
186 $criterion = new \ilTermsOfServiceUserHasLanguageCriterion();
190 $actual = $gui->getValuePresentation(
192 $this->dic->ui()->factory()
195 $this->assertInstanceOf(Component::class, $actual);
196 $this->assertInstanceOf(Legacy::class, $actual);
197 $this->assertEquals($translation, $actual->getContent());
243 ->expects($this->any())
244 ->method(
'getLanguage')
262 ->expects($this->any())
263 ->method(
'getLanguage')
Interface ilTermsOfServiceCriterionTypeGUI.
testValuesFromFormUserInterfaceElementsCanBeRetrieved(\ilTermsOfServiceUserHasLanguageCriterion $criterion)
testFormUserInterfaceElementsAreProperlyBuilt
$germanLanguageTranslation
Class ilTermsOfServiceCriterionBaseTest.
$expectedAfterFormSubmitValue
testTypeIdentPresentationIsANonEmptyString(\ilTermsOfServiceUserHasLanguageCriterion $criterion)
testFormUserInterfaceElementsAreProperlyBuilt
testFormUserInterfaceElementsAreProperlyBuilt(\ilTermsOfServiceUserHasLanguageCriterion $criterion)
Class ilTermsOfServiceCriterionConfig.
getCriterionConfig($value=null)
if(isset($_POST['submit'])) $form
evaluate(\ilObjUser $user, \ilTermsOfServiceCriterionConfig $config)
bool
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
testEvaluationFailsIfUserLanguageDoesNotMatchDefinedLanguage(\ilTermsOfServiceUserHasLanguageCriterion $criterion, \ilTermsOfServiceCriterionConfig $config)
testEvaluationSucceedsIfUserLanguageDoesMatchDefinedLanguage(\ilTermsOfServiceUserHasLanguageCriterion $criterion, \ilTermsOfServiceCriterionConfig $config)
appendOption(\ilRadioGroupInputGUI $option, \ilTermsOfServiceCriterionConfig $config)
Class ilTermsOfServiceUserHasLanguageCriterion.
succeedingConfigProvider()
testInstanceCanBeCreated()
getTypeIdent()
Returns a unique id of the criterion type.string
buildForm(\ilTermsOfServiceCriterionTypeGUI $gui, string $httpCriterionSelectionBodyParameter)
Class ilTermsOfServiceUserHasLanguageCriterionTest.
$englishLanguageTranslation