ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTermsOfServiceUserHasCountryCriterionTest Class Reference

Class ilTermsOfServiceUserHasCountryCriterionTest. More...

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

Public Member Functions

 testInstanceCanBeCreated ()
 
 testFormUserInterfaceElementsAreProperlyBuilt (ilTermsOfServiceUserHasCountryCriterion $criterion)
 
 testValuesFromFormUserInterfaceElementsCanBeRetrieved (ilTermsOfServiceUserHasCountryCriterion $criterion)
 testFormUserInterfaceElementsAreProperlyBuilt More...
 
 testTypeIdentPresentationIsANonEmptyString (ilTermsOfServiceUserHasCountryCriterion $criterion)
 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.

References ilTermsOfServiceCriterionTypeGUI\appendOption(), ilTermsOfServiceBaseTest\getCriterionConfig(), ilTermsOfServiceCriterionBaseTest\getFormMock(), and ilTermsOfServiceCriterionBaseTest\getRadioGroupMock().

Referenced by testFormUserInterfaceElementsAreProperlyBuilt(), and testValuesFromFormUserInterfaceElementsCanBeRetrieved().

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  }
appendOption(ilRadioGroupInputGUI $group, ilTermsOfServiceCriterionConfig $config)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ countryProvider()

◆ failingConfigProvider()

ilTermsOfServiceUserHasCountryCriterionTest::failingConfigProvider ( )

Definition at line 200 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

References ilTermsOfServiceBaseTest\getCriterionConfig(), and getInstance().

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  }
+ Here is the call graph for this function:

◆ getInstance()

ilTermsOfServiceUserHasCountryCriterionTest::getInstance ( )
protected

Definition at line 53 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

Referenced by failingConfigProvider(), succeedingConfigProvider(), and testInstanceCanBeCreated().

54  {
55  return new ilTermsOfServiceUserHasCountryCriterion($this->countries);
56  }
+ Here is the caller graph for this function:

◆ setUp()

ilTermsOfServiceUserHasCountryCriterionTest::setUp ( )
protected

Definition at line 40 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

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

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  }
+ Here is the call graph for this function:

◆ succeedingConfigProvider()

ilTermsOfServiceUserHasCountryCriterionTest::succeedingConfigProvider ( )

Definition at line 218 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

References ilTermsOfServiceBaseTest\getCriterionConfig(), and getInstance().

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  }
+ Here is the call graph for this function:

◆ testEvaluationFailsIfUserCountryDoesNotMatchDefinedLanguage()

ilTermsOfServiceUserHasCountryCriterionTest::testEvaluationFailsIfUserCountryDoesNotMatchDefinedLanguage ( ilTermsOfServiceUserHasCountryCriterion  $criterion,
ilTermsOfServiceCriterionConfig  $config 
)
Parameters
ilTermsOfServiceUserHasCountryCriterion$criterion
ilTermsOfServiceCriterionConfig$configfailingConfigProvider

Definition at line 233 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

References ilTermsOfServiceUserHasCountryCriterion\evaluate(), and ilTermsOfServiceCriterionBaseTest\getUserMock().

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)
+ Here is the call graph for this function:

◆ testEvaluationSucceedsIfUserCountryDoesMatchDefinedLanguage()

ilTermsOfServiceUserHasCountryCriterionTest::testEvaluationSucceedsIfUserCountryDoesMatchDefinedLanguage ( ilTermsOfServiceUserHasCountryCriterion  $criterion,
ilTermsOfServiceCriterionConfig  $config 
)
Parameters
ilTermsOfServiceUserHasCountryCriterion$criterion
ilTermsOfServiceCriterionConfig$configsucceedingConfigProvider

Definition at line 251 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

References ilTermsOfServiceUserHasCountryCriterion\evaluate(), and ilTermsOfServiceCriterionBaseTest\getUserMock().

254  : void {
255  $user = $this->getUserMock();
256 
257  $user
258  ->method('getSelectedCountry')
259  ->willReturn('de');
260 
261  $this->assertTrue($criterion->evaluate($user, $config));
262  }
evaluate(ilObjUser $user, ilTermsOfServiceCriterionConfig $config)
+ Here is the call graph for this function:

◆ testFormUserInterfaceElementsAreProperlyBuilt()

ilTermsOfServiceUserHasCountryCriterionTest::testFormUserInterfaceElementsAreProperlyBuilt ( ilTermsOfServiceUserHasCountryCriterion  $criterion)
Parameters
ilTermsOfServiceUserHasCountryCriterion$criteriontestInstanceCanBeCreated
Returns
ilTermsOfServiceUserHasCountryCriterion

Definition at line 97 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

References $expectedInitialValue, buildForm(), ilTermsOfServiceUserHasCountryCriterion\getTypeIdent(), ILIAS\Repository\lng(), and ilTermsOfServiceUserHasCountryCriterion\ui().

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)
+ Here is the call graph for this function:

◆ testInstanceCanBeCreated()

ilTermsOfServiceUserHasCountryCriterionTest::testInstanceCanBeCreated ( )

Definition at line 58 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

References getInstance().

59  {
60  $criterion = $this->getInstance();
61 
62  $this->assertSame('usr_country', $criterion->getTypeIdent());
63  $this->assertTrue($criterion->hasUniqueNature());
64 
65  return $criterion;
66  }
+ Here is the call graph for this function:

◆ testTypeIdentPresentationIsANonEmptyString()

ilTermsOfServiceUserHasCountryCriterionTest::testTypeIdentPresentationIsANonEmptyString ( ilTermsOfServiceUserHasCountryCriterion  $criterion)

testFormUserInterfaceElementsAreProperlyBuilt

Parameters
ilTermsOfServiceUserHasCountryCriterion$criterion

Definition at line 149 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

References ILIAS\Repository\lng(), and ilTermsOfServiceUserHasCountryCriterion\ui().

151  : void {
152  $gui = $criterion->ui($this->lng);
153 
154  $actual = $gui->getIdentPresentation();
155 
156  $this->assertIsString($actual);
157  $this->assertNotEmpty($actual);
158  }
+ Here is the call graph for this function:

◆ testValuesFromFormUserInterfaceElementsCanBeRetrieved()

ilTermsOfServiceUserHasCountryCriterionTest::testValuesFromFormUserInterfaceElementsCanBeRetrieved ( ilTermsOfServiceUserHasCountryCriterion  $criterion)

testFormUserInterfaceElementsAreProperlyBuilt

Parameters
ilTermsOfServiceUserHasCountryCriterion$criterion

Definition at line 120 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

References $expectedAfterFormSubmitValue, buildForm(), ilTermsOfServiceBaseTest\getCriterionConfig(), ilTermsOfServiceUserHasCountryCriterion\getTypeIdent(), ILIAS\Repository\lng(), and ilTermsOfServiceUserHasCountryCriterion\ui().

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  }
buildForm(ilTermsOfServiceCriterionTypeGUI $gui, string $httpCriterionSelectionBodyParameter)
+ Here is the call graph for this function:

Field Documentation

◆ $countries

array ilTermsOfServiceUserHasCountryCriterionTest::$countries = []
protected

◆ $englishLanguageTranslation

string ilTermsOfServiceUserHasCountryCriterionTest::$englishLanguageTranslation = 'English'
protected

Definition at line 35 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

Referenced by countryProvider().

◆ $expectedAfterFormSubmitValue

string ilTermsOfServiceUserHasCountryCriterionTest::$expectedAfterFormSubmitValue = 'DE'
protected

◆ $expectedInitialValue

string ilTermsOfServiceUserHasCountryCriterionTest::$expectedInitialValue = 'EN'
protected

◆ $germanLanguageTranslation

string ilTermsOfServiceUserHasCountryCriterionTest::$germanLanguageTranslation = 'German'
protected

Definition at line 36 of file ilTermsOfServiceUserHasCountryCriterionTest.php.

Referenced by countryProvider().

◆ $lng

ilLanguage ilTermsOfServiceUserHasCountryCriterionTest::$lng
protected

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