ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTermsOfServiceUserHasLanguageCriterionTest Class Reference

Class ilTermsOfServiceUserHasLanguageCriterionTest. More...

+ Inheritance diagram for ilTermsOfServiceUserHasLanguageCriterionTest:
+ Collaboration diagram for ilTermsOfServiceUserHasLanguageCriterionTest:

Public Member Functions

 setUp ()
 
 testInstanceCanBeCreated ()
 
 testFormUserInterfaceElementsAreProperlyBuilt (\ilTermsOfServiceUserHasLanguageCriterion $criterion)
 
 testValuesFromFormUserInterfaceElementsCanBeRetrieved (\ilTermsOfServiceUserHasLanguageCriterion $criterion)
 testFormUserInterfaceElementsAreProperlyBuilt More...
 
 testTypeIdentPresentationIsANonEmptyString (\ilTermsOfServiceUserHasLanguageCriterion $criterion)
 testFormUserInterfaceElementsAreProperlyBuilt More...
 
 languageProvider ()
 
 failingConfigProvider ()
 
 succeedingConfigProvider ()
 
 testEvaluationFailsIfUserLanguageDoesNotMatchDefinedLanguage (\ilTermsOfServiceUserHasLanguageCriterion $criterion, \ilTermsOfServiceCriterionConfig $config)
 
 testEvaluationSucceedsIfUserLanguageDoesMatchDefinedLanguage (\ilTermsOfServiceUserHasLanguageCriterion $criterion, \ilTermsOfServiceCriterionConfig $config)
 

Protected Member Functions

 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 ()
 
 setGlobalVariable (string $name, $value)
 
 assertException (string $exceptionClass)
 
 getCriterionConfig ($value=null)
 

Protected Attributes

 $lng
 
 $expectedInitialValue = 'en'
 
 $expectedAfterFormSubmitValue = 'de'
 
 $englishLanguageTranslation = 'English'
 
 $germanLanguageTranslation = 'German'
 
- Protected Attributes inherited from ilTermsOfServiceBaseTest
 $dic
 

Detailed Description

Member Function Documentation

◆ buildForm()

ilTermsOfServiceUserHasLanguageCriterionTest::buildForm ( \ilTermsOfServiceCriterionTypeGUI  $gui,
string  $httpCriterionSelectionBodyParameter 
)
protected
Parameters
\ilTermsOfServiceCriterionTypeGUI$gui
string$httpCriterionSelectionBodyParameter
Returns
PHPUnit_Framework_MockObject_MockObject|

Definition at line 73 of file ilTermsOfServiceUserHasLanguageCriterionTest.php.

References $form, 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  ->expects($this->any())
83  ->method('getPostVar')
84  ->willReturn($httpCriterionSelectionBodyParameter);
85 
86  $form->addItem($radioGroup);
87 
88  $gui->appendOption($radioGroup, $this->getCriterionConfig(['lng' => $this->expectedInitialValue]));
89 
90  return $form;
91  }
This class represents a property form user interface.
if(isset($_POST['submit'])) $form
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ failingConfigProvider()

ilTermsOfServiceUserHasLanguageCriterionTest::failingConfigProvider ( )
Returns
array

Definition at line 203 of file ilTermsOfServiceUserHasLanguageCriterionTest.php.

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

203  : array
204  {
205  $criterion = $this->getInstance();
206 
207  return [
208  [$criterion, $this->getCriterionConfig(['lng' => 'en'])],
209  [$criterion, $this->getCriterionConfig(['lng' => []])],
210  [$criterion, $this->getCriterionConfig(['lng' => new stdClass()])],
211  [$criterion, $this->getCriterionConfig(['lng' => 1.0])],
212  [$criterion, $this->getCriterionConfig(['lng' => 1])],
213  [$criterion, $this->getCriterionConfig(['another_config_key' => true])],
214  [$criterion, $this->getCriterionConfig()],
215  ];
216  }
+ Here is the call graph for this function:

◆ getInstance()

ilTermsOfServiceUserHasLanguageCriterionTest::getInstance ( )
protected
Returns

Definition at line 50 of file ilTermsOfServiceUserHasLanguageCriterionTest.php.

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

51  {
52  return new \ilTermsOfServiceUserHasLanguageCriterion();
53  }
+ Here is the caller graph for this function:

◆ languageProvider()

◆ setUp()

ilTermsOfServiceUserHasLanguageCriterionTest::setUp ( )

Definition at line 30 of file ilTermsOfServiceUserHasLanguageCriterionTest.php.

References ilTermsOfServiceBaseTest\getLanguageMock().

31  {
32  parent::setUp();
33 
34  $this->lng = $this->getLanguageMock();
35 
36  $this->lng
37  ->expects($this->any())
38  ->method('txt')
39  ->willReturn('dummy');
40 
41  $this->lng
42  ->expects($this->any())
43  ->method('getInstalledLanguages')
44  ->willReturn([$this->expectedAfterFormSubmitValue, $this->expectedInitialValue]);
45  }
+ Here is the call graph for this function:

◆ succeedingConfigProvider()

ilTermsOfServiceUserHasLanguageCriterionTest::succeedingConfigProvider ( )
Returns
array

Definition at line 221 of file ilTermsOfServiceUserHasLanguageCriterionTest.php.

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

221  : array
222  {
223  $criterion = $this->getInstance();
224 
225  return [
226  [$criterion, $this->getCriterionConfig(['lng' => 'de'])],
227  [$criterion, $this->getCriterionConfig(['lng' => 'DE'])],
228  ];
229  }
+ Here is the call graph for this function:

◆ testEvaluationFailsIfUserLanguageDoesNotMatchDefinedLanguage()

ilTermsOfServiceUserHasLanguageCriterionTest::testEvaluationFailsIfUserLanguageDoesNotMatchDefinedLanguage ( \ilTermsOfServiceUserHasLanguageCriterion  $criterion,
\ilTermsOfServiceCriterionConfig  $config 
)
Parameters
\ilTermsOfServiceUserHasLanguageCriterion$criterion
\ilTermsOfServiceCriterionConfig$configfailingConfigProvider

Definition at line 236 of file ilTermsOfServiceUserHasLanguageCriterionTest.php.

References $user, ilTermsOfServiceUserHasLanguageCriterion\evaluate(), and ilTermsOfServiceCriterionBaseTest\getUserMock().

239  {
240  $user = $this->getUserMock();
241 
242  $user
243  ->expects($this->any())
244  ->method('getLanguage')
245  ->willReturn('de');
246 
247  $this->assertFalse($criterion->evaluate($user, $config));
248  }
$config
Definition: bootstrap.php:15
$user
Definition: migrateto20.php:57
+ Here is the call graph for this function:

◆ testEvaluationSucceedsIfUserLanguageDoesMatchDefinedLanguage()

ilTermsOfServiceUserHasLanguageCriterionTest::testEvaluationSucceedsIfUserLanguageDoesMatchDefinedLanguage ( \ilTermsOfServiceUserHasLanguageCriterion  $criterion,
\ilTermsOfServiceCriterionConfig  $config 
)
Parameters
\ilTermsOfServiceUserHasLanguageCriterion$criterion
\ilTermsOfServiceCriterionConfig$configsucceedingConfigProvider

Definition at line 255 of file ilTermsOfServiceUserHasLanguageCriterionTest.php.

References $user, ilTermsOfServiceUserHasLanguageCriterion\evaluate(), and ilTermsOfServiceCriterionBaseTest\getUserMock().

258  {
259  $user = $this->getUserMock();
260 
261  $user
262  ->expects($this->any())
263  ->method('getLanguage')
264  ->willReturn('de');
265 
266  $this->assertTrue($criterion->evaluate($user, $config));
267  }
$config
Definition: bootstrap.php:15
$user
Definition: migrateto20.php:57
+ Here is the call graph for this function:

◆ testFormUserInterfaceElementsAreProperlyBuilt()

ilTermsOfServiceUserHasLanguageCriterionTest::testFormUserInterfaceElementsAreProperlyBuilt ( \ilTermsOfServiceUserHasLanguageCriterion  $criterion)
Parameters
\ilTermsOfServiceUserHasLanguageCriterion$criteriontestInstanceCanBeCreated
Returns
ilTermsOfServiceUserHasLanguageCriterion

Definition at line 98 of file ilTermsOfServiceUserHasLanguageCriterionTest.php.

References $expectedInitialValue, $form, buildForm(), ilTermsOfServiceUserHasLanguageCriterion\getTypeIdent(), and ilTermsOfServiceUserHasLanguageCriterion\ui().

99  {
100  $httpCriterionSelectionBodyParameter = 'criterion';
101  $httpCriterionConfigBodyParameter = $criterion->getTypeIdent() . '_lng';
102 
103  $gui = $criterion->ui($this->lng);
104 
105  $this->assertInstanceOf(\ilTermsOfServiceUserHasLanguageCriterionGUI::class, $gui);
106 
107  $form = $this->buildForm($gui, $httpCriterionSelectionBodyParameter);
108 
109  $languageSelection = $form->getItemByPostVar($httpCriterionConfigBodyParameter);
110  $this->assertInstanceOf(\ilSelectInputGUI::class, $languageSelection);
111  $this->assertEquals($languageSelection->getValue(), $this->expectedInitialValue);
112 
113  return $criterion;
114  }
if(isset($_POST['submit'])) $form
buildForm(\ilTermsOfServiceCriterionTypeGUI $gui, string $httpCriterionSelectionBodyParameter)
+ Here is the call graph for this function:

◆ testInstanceCanBeCreated()

ilTermsOfServiceUserHasLanguageCriterionTest::testInstanceCanBeCreated ( )
Returns

Definition at line 58 of file ilTermsOfServiceUserHasLanguageCriterionTest.php.

References getInstance().

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

◆ testTypeIdentPresentationIsANonEmptyString()

ilTermsOfServiceUserHasLanguageCriterionTest::testTypeIdentPresentationIsANonEmptyString ( \ilTermsOfServiceUserHasLanguageCriterion  $criterion)

testFormUserInterfaceElementsAreProperlyBuilt

Parameters
\ilTermsOfServiceUserHasLanguageCriterion$criterion

Definition at line 148 of file ilTermsOfServiceUserHasLanguageCriterionTest.php.

References ilTermsOfServiceUserHasLanguageCriterion\ui().

149  {
150  $gui = $criterion->ui($this->lng);
151 
152  $actual = $gui->getIdentPresentation();
153 
154  $this->assertInternalType('string', $actual);
155  $this->assertNotEmpty($actual);
156  }
+ Here is the call graph for this function:

◆ testValuesFromFormUserInterfaceElementsCanBeRetrieved()

ilTermsOfServiceUserHasLanguageCriterionTest::testValuesFromFormUserInterfaceElementsCanBeRetrieved ( \ilTermsOfServiceUserHasLanguageCriterion  $criterion)

testFormUserInterfaceElementsAreProperlyBuilt

Parameters
\ilTermsOfServiceUserHasLanguageCriterion$criterion

Definition at line 120 of file ilTermsOfServiceUserHasLanguageCriterionTest.php.

References $expectedAfterFormSubmitValue, $form, buildForm(), ilTermsOfServiceBaseTest\getCriterionConfig(), ilTermsOfServiceUserHasLanguageCriterion\getTypeIdent(), Sabre\Event\once(), and ilTermsOfServiceUserHasLanguageCriterion\ui().

121  {
122  $httpCriterionSelectionBodyParameter = 'criterion';
123  $httpCriterionConfigBodyParameter = $criterion->getTypeIdent() . '_lng';
124 
125  $gui = $criterion->ui($this->lng);
126 
127  $form = $this->buildForm($gui, $httpCriterionSelectionBodyParameter);
128 
129  $form
130  ->expects($this->once())
131  ->method('getInput')
132  ->with($httpCriterionConfigBodyParameter)
133  ->will($this->returnCallback(function () {
135  }));
136 
137  $value = $gui->getConfigByForm($form);
138 
139  $this->assertInstanceOf(\ilTermsOfServiceCriterionConfig::class, $value);
140  $this->assertEquals($this->expectedAfterFormSubmitValue, $value['lng']);
141  $this->assertEquals($this->getCriterionConfig(['lng' => $this->expectedAfterFormSubmitValue]), $value);
142  }
if(isset($_POST['submit'])) $form
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
buildForm(\ilTermsOfServiceCriterionTypeGUI $gui, string $httpCriterionSelectionBodyParameter)
+ Here is the call graph for this function:

Field Documentation

◆ $englishLanguageTranslation

ilTermsOfServiceUserHasLanguageCriterionTest::$englishLanguageTranslation = 'English'
protected

Definition at line 22 of file ilTermsOfServiceUserHasLanguageCriterionTest.php.

Referenced by languageProvider().

◆ $expectedAfterFormSubmitValue

ilTermsOfServiceUserHasLanguageCriterionTest::$expectedAfterFormSubmitValue = 'de'
protected

◆ $expectedInitialValue

ilTermsOfServiceUserHasLanguageCriterionTest::$expectedInitialValue = 'en'
protected

◆ $germanLanguageTranslation

ilTermsOfServiceUserHasLanguageCriterionTest::$germanLanguageTranslation = 'German'
protected

Definition at line 25 of file ilTermsOfServiceUserHasLanguageCriterionTest.php.

Referenced by languageProvider().

◆ $lng

ilTermsOfServiceUserHasLanguageCriterionTest::$lng
protected

Definition at line 13 of file ilTermsOfServiceUserHasLanguageCriterionTest.php.

Referenced by languageProvider().


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