ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
ilTermsOfServiceUserHasCountryCriterionTest Class Reference

Class ilTermsOfServiceUserHasCountryCriterionTest. More...

+ Inheritance diagram for ilTermsOfServiceUserHasCountryCriterionTest:
+ Collaboration diagram for ilTermsOfServiceUserHasCountryCriterionTest:

Public Member Functions

 testInstanceCanBeCreated ()
 
 testFormUserInterfaceElementsAreProperlyBuilt (ilTermsOfServiceUserHasCountryCriterion $criterion)
 
 testValuesFromFormUserInterfaceElementsCanBeRetrieved (ilTermsOfServiceUserHasCountryCriterion $criterion)
 @depends testFormUserInterfaceElementsAreProperlyBuilt More...
 
 testTypeIdentPresentationIsANonEmptyString (ilTermsOfServiceUserHasCountryCriterion $criterion)
 @depends testFormUserInterfaceElementsAreProperlyBuilt More...
 
 countryProvider ()
 
 failingConfigProvider ()
 
 succeedingConfigProvider ()
 
 testEvaluationFailsIfUserCountryDoesNotMatchDefinedLanguage (ilTermsOfServiceUserHasCountryCriterion $criterion, ilTermsOfServiceCriterionConfig $config)
 
 testEvaluationSucceedsIfUserCountryDoesMatchDefinedLanguage (ilTermsOfServiceUserHasCountryCriterion $criterion, ilTermsOfServiceCriterionConfig $config)
 

Protected Member Functions

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

ilLanguage $lng
 
string $expectedInitialValue = 'EN'
 
string $expectedAfterFormSubmitValue = 'DE'
 
string $englishLanguageTranslation = 'English'
 
string $germanLanguageTranslation = 'German'
 
array $countries = []
 
- Protected Attributes inherited from ilTermsOfServiceBaseTest
Container $dic
 

Detailed Description

Member Function Documentation

◆ buildForm()

ilTermsOfServiceUserHasCountryCriterionTest::buildForm ( ilTermsOfServiceCriterionTypeGUI  $gui,
string  $httpCriterionSelectionBodyParameter 
)
protected
Parameters
ilTermsOfServiceCriterionTypeGUI$gui
string$httpCriterionSelectionBodyParameter
Returns
MockObject&ilPropertyFormGUI

Definition at line 73 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

77 $form = $this->getFormMock();
78
79 $radioGroup = $this->getRadioGroupMock();
80
81 $radioGroup
82 ->method('getPostVar')
83 ->willReturn($httpCriterionSelectionBodyParameter);
84
85 $form->addItem($radioGroup);
86
87 $gui->appendOption($radioGroup, $this->getCriterionConfig(['country' => $this->expectedInitialValue]));
88
89 return $form;
90 }
This class represents a property form user interface.
appendOption(ilRadioGroupInputGUI $group, ilTermsOfServiceCriterionConfig $config)

◆ countryProvider()

ilTermsOfServiceUserHasCountryCriterionTest::countryProvider ( )

◆ failingConfigProvider()

ilTermsOfServiceUserHasCountryCriterionTest::failingConfigProvider ( )

Definition at line 200 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

200 : array
201 {
202 $criterion = $this->getInstance();
203
204 return [
205 'English Language where German is Expected' => [$criterion, $this->getCriterionConfig(['country' => 'en'])],
206 'Array' => [$criterion, $this->getCriterionConfig(['country' => []])],
207 'Object' => [$criterion, $this->getCriterionConfig(['country' => new stdClass()])],
208 'Double' => [$criterion, $this->getCriterionConfig(['country' => 1.0])],
209 'Integer' => [$criterion, $this->getCriterionConfig(['country' => 1])],
210 'Wrong Key Provided for Extracting Language' => [
211 $criterion,
212 $this->getCriterionConfig(['another_config_key' => true])
213 ],
214 'Empty Configuration' => [$criterion, $this->getCriterionConfig()],
215 ];
216 }

◆ getInstance()

ilTermsOfServiceUserHasCountryCriterionTest::getInstance ( )
protected

Definition at line 53 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

Referenced by testInstanceCanBeCreated().

+ Here is the caller graph for this function:

◆ setUp()

ilTermsOfServiceUserHasCountryCriterionTest::setUp ( )
protected

Reimplemented from ilTermsOfServiceBaseTest.

Definition at line 40 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

40 : void
41 {
42 parent::setUp();
43
44 $this->lng = $this->getLanguageMock();
45
46 $this->lng
47 ->method('txt')
48 ->willReturn('dummy');
49
50 $this->countries = ['EN', 'DE'];
51 }

References ilTermsOfServiceBaseTest\getLanguageMock(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ succeedingConfigProvider()

ilTermsOfServiceUserHasCountryCriterionTest::succeedingConfigProvider ( )

Definition at line 218 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

218 : array
219 {
220 $criterion = $this->getInstance();
221
222 return [
223 'German Language' => [$criterion, $this->getCriterionConfig(['country' => 'de'])],
224 'German Language Uppercase' => [$criterion, $this->getCriterionConfig(['country' => 'DE'])],
225 ];
226 }

◆ testEvaluationFailsIfUserCountryDoesNotMatchDefinedLanguage()

ilTermsOfServiceUserHasCountryCriterionTest::testEvaluationFailsIfUserCountryDoesNotMatchDefinedLanguage ( ilTermsOfServiceUserHasCountryCriterion  $criterion,
ilTermsOfServiceCriterionConfig  $config 
)
Parameters
ilTermsOfServiceUserHasCountryCriterion$criterion
ilTermsOfServiceCriterionConfig$config@dataProvider failingConfigProvider

Definition at line 233 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

236 : void {
237 $user = $this->getUserMock();
238
239 $user
240 ->method('getSelectedCountry')
241 ->willReturn('de');
242
243 $this->assertFalse($criterion->evaluate($user, $config));
244 }
evaluate(ilObjUser $user, ilTermsOfServiceCriterionConfig $config)
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85

◆ testEvaluationSucceedsIfUserCountryDoesMatchDefinedLanguage()

ilTermsOfServiceUserHasCountryCriterionTest::testEvaluationSucceedsIfUserCountryDoesMatchDefinedLanguage ( ilTermsOfServiceUserHasCountryCriterion  $criterion,
ilTermsOfServiceCriterionConfig  $config 
)
Parameters
ilTermsOfServiceUserHasCountryCriterion$criterion
ilTermsOfServiceCriterionConfig$config@dataProvider succeedingConfigProvider

Definition at line 251 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

254 : void {
255 $user = $this->getUserMock();
256
257 $user
258 ->method('getSelectedCountry')
259 ->willReturn('de');
260
261 $this->assertTrue($criterion->evaluate($user, $config));
262 }

◆ testFormUserInterfaceElementsAreProperlyBuilt()

ilTermsOfServiceUserHasCountryCriterionTest::testFormUserInterfaceElementsAreProperlyBuilt ( ilTermsOfServiceUserHasCountryCriterion  $criterion)
Parameters
ilTermsOfServiceUserHasCountryCriterion$criterion@depends testInstanceCanBeCreated
Returns
ilTermsOfServiceUserHasCountryCriterion

Definition at line 97 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

100 $httpCriterionSelectionBodyParameter = 'criterion';
101 $httpCriterionConfigBodyParameter = $criterion->getTypeIdent() . '_country';
102
103 $gui = $criterion->ui($this->lng);
104
105 $this->assertInstanceOf(ilTermsOfServiceUserHasCountryCriterionGUI::class, $gui);
106
107 $form = $this->buildForm($gui, $httpCriterionSelectionBodyParameter);
108
109 $countrySelection = $form->getItemByPostVar($httpCriterionConfigBodyParameter);
110 $this->assertInstanceOf(ilSelectInputGUI::class, $countrySelection);
111 $this->assertSame($countrySelection->getValue(), $this->expectedInitialValue);
112
113 return $criterion;
114 }
buildForm(ilTermsOfServiceCriterionTypeGUI $gui, string $httpCriterionSelectionBodyParameter)

◆ testInstanceCanBeCreated()

ilTermsOfServiceUserHasCountryCriterionTest::testInstanceCanBeCreated ( )

Definition at line 58 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

59 {
60 $criterion = $this->getInstance();
61
62 $this->assertSame('usr_country', $criterion->getTypeIdent());
63 $this->assertTrue($criterion->hasUniqueNature());
64
65 return $criterion;
66 }

References getInstance().

+ Here is the call graph for this function:

◆ testTypeIdentPresentationIsANonEmptyString()

ilTermsOfServiceUserHasCountryCriterionTest::testTypeIdentPresentationIsANonEmptyString ( ilTermsOfServiceUserHasCountryCriterion  $criterion)

@depends testFormUserInterfaceElementsAreProperlyBuilt

Parameters
ilTermsOfServiceUserHasCountryCriterion$criterion

Definition at line 149 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

151 : void {
152 $gui = $criterion->ui($this->lng);
153
154 $actual = $gui->getIdentPresentation();
155
156 $this->assertIsString($actual);
157 $this->assertNotEmpty($actual);
158 }

◆ testValuesFromFormUserInterfaceElementsCanBeRetrieved()

ilTermsOfServiceUserHasCountryCriterionTest::testValuesFromFormUserInterfaceElementsCanBeRetrieved ( ilTermsOfServiceUserHasCountryCriterion  $criterion)

@depends testFormUserInterfaceElementsAreProperlyBuilt

Parameters
ilTermsOfServiceUserHasCountryCriterion$criterion

Definition at line 120 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

122 : void {
123 $httpCriterionSelectionBodyParameter = 'criterion';
124 $httpCriterionConfigBodyParameter = $criterion->getTypeIdent() . '_country';
125
126 $gui = $criterion->ui($this->lng);
127
128 $form = $this->buildForm($gui, $httpCriterionSelectionBodyParameter);
129
130 $form
131 ->expects($this->once())
132 ->method('getInput')
133 ->with($httpCriterionConfigBodyParameter)
134 ->willReturnCallback(function () {
136 });
137
138 $value = $gui->getConfigByForm($form);
139
140 $this->assertInstanceOf(ilTermsOfServiceCriterionConfig::class, $value);
141 $this->assertSame($this->expectedAfterFormSubmitValue, $value['country']);
142 $this->assertEquals($this->getCriterionConfig(['country' => $this->expectedAfterFormSubmitValue]), $value);
143 }

Field Documentation

◆ $countries

array ilTermsOfServiceUserHasCountryCriterionTest::$countries = []
protected

◆ $englishLanguageTranslation

string ilTermsOfServiceUserHasCountryCriterionTest::$englishLanguageTranslation = 'English'
protected

◆ $expectedAfterFormSubmitValue

string ilTermsOfServiceUserHasCountryCriterionTest::$expectedAfterFormSubmitValue = 'DE'
protected

◆ $expectedInitialValue

string ilTermsOfServiceUserHasCountryCriterionTest::$expectedInitialValue = 'EN'
protected

◆ $germanLanguageTranslation

string ilTermsOfServiceUserHasCountryCriterionTest::$germanLanguageTranslation = 'German'
protected

◆ $lng

ilLanguage ilTermsOfServiceUserHasCountryCriterionTest::$lng
protected

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