ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTermsOfServiceNullCriterionTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
24 
30 {
32  protected ilLanguage $lng;
33 
34  protected function setUp(): void
35  {
36  parent::setUp();
37 
38  $this->lng = $this->getLanguageMock();
39 
40  $this->lng
41  ->method('txt')
42  ->willReturn('dummy');
43  }
44 
46  {
47  return new ilTermsOfServiceNullCriterion();
48  }
49 
51  {
52  $criterion = $this->getInstance();
53 
54  $this->assertSame('null', $criterion->getTypeIdent());
55  $this->assertFalse($criterion->hasUniqueNature());
56 
57  return $criterion;
58  }
59 
64  protected function buildForm(
67  $form = $this->getFormMock();
68 
69  $radioGroup = $this
70  ->getMockBuilder(ilRadioGroupInputGUI::class)
71  ->disableOriginalConstructor()
72  ->onlyMethods(['getPostVar', 'addOption'])
73  ->getMock();
74 
75  $form->addItem($radioGroup);
76 
77  $radioGroup
78  ->expects($this->never())
79  ->method('addOption');
80 
81  $gui->appendOption($radioGroup, $this->getCriterionConfig());
82 
83  return $form;
84  }
85 
94  $gui = $criterion->ui($this->lng);
95 
96  $this->buildForm($gui);
97 
98  return $criterion;
99  }
100 
106  {
107  $gui = $criterion->ui($this->lng);
108 
109  $form = $this->buildForm($gui);
110 
111  $form
112  ->expects($this->never())
113  ->method('getInput');
114 
115  $value = $gui->getConfigByForm($form);
116 
117  $this->assertInstanceOf(ilTermsOfServiceCriterionConfig::class, $value);
118  $this->assertEquals($this->getCriterionConfig(), $value);
119  }
120 
126  {
127  $gui = $criterion->ui($this->lng);
128 
129  $actual = $gui->getIdentPresentation();
130 
131  $this->assertIsString($actual);
132  $this->assertNotEmpty($actual);
133  }
134 
135  public function testValuePresentationMatchesExpectation(): void
136  {
137  $criterion = $this->getInstance();
138  $gui = $criterion->ui($this->lng);
139 
141  $actual = $gui->getValuePresentation(
142  $this->getCriterionConfig(),
143  $this->getUiFactoryMock()
144  );
145 
146  $this->assertInstanceOf(Component::class, $actual);
147  $this->assertInstanceOf(Legacy::class, $actual);
148  $this->assertSame('-', $actual->getContent());
149  }
150 
151  public function testEvaluationAlwaysSucceeds(): void
152  {
153  $user = $this->getUserMock();
154  $criterion = $this->getInstance();
155 
156  $this->assertTrue($criterion->evaluate($user, $this->getCriterionConfig()));
157  }
158 }
testTypeIdentPresentationEqualsANonEmptyString(ilTermsOfServiceNullCriterion $criterion)
testNoFormUserInterfaceElementsAreBuilt
Interface ilTermsOfServiceCriterionTypeGUI.
Class ilTermsOfServiceCriterionBaseTest.
buildForm(ilTermsOfServiceCriterionTypeGUI $gui)
testNoFormUserInterfaceElementsAreBuilt(ilTermsOfServiceNullCriterion $criterion)
appendOption(ilRadioGroupInputGUI $group, ilTermsOfServiceCriterionConfig $config)
testCriterionAlwaysCreateEmptyConfigValue(ilTermsOfServiceNullCriterion $criterion)
testNoFormUserInterfaceElementsAreBuilt
Class ilTermsOfServiceNullCriterion.
Class ilTermsOfServiceNullCriterionTest.