ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTermsOfServiceNullCriterionTest.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
7 
13 {
15  protected $lng;
16 
20  public function setUp() : void
21  {
22  parent::setUp();
23 
24  $this->lng = $this->getLanguageMock();
25 
26  $this->lng
27  ->expects($this->any())
28  ->method('txt')
29  ->willReturn('dummy');
30  }
31 
36  {
37  $criterion = new ilTermsOfServiceNullCriterion();
38 
39  return $criterion;
40  }
41 
46  {
47  $criterion = $this->getInstance();
48 
49  $this->assertEquals('null', $criterion->getTypeIdent());
50  $this->assertEquals(false, $criterion->hasUniqueNature());
51 
52  return $criterion;
53  }
54 
60  protected function buildForm(
62  ) : ilPropertyFormGUI {
63  $form = $this->getFormMock();
64 
65  $radioGroup = $this
66  ->getMockBuilder(ilRadioGroupInputGUI::class)
67  ->disableOriginalConstructor()
68  ->setMethods(['getPostVar', 'addOption'])
69  ->getMock();
70 
71  $form->addItem($radioGroup);
72 
73  $radioGroup
74  ->expects($this->never())
75  ->method('addOption');
76 
77  $gui->appendOption($radioGroup, $this->getCriterionConfig());
78 
79  return $form;
80  }
81 
91  $gui = $criterion->ui($this->lng);
92 
93  $this->buildForm($gui);
94 
95  return $criterion;
96  }
97 
104  {
105  $gui = $criterion->ui($this->lng);
106 
107  $form = $this->buildForm($gui);
108 
109  $form
110  ->expects($this->never())
111  ->method('getInput');
112 
113  $value = $gui->getConfigByForm($form);
114 
115  $this->assertInstanceOf(ilTermsOfServiceCriterionConfig::class, $value);
116  $this->assertEquals($this->getCriterionConfig(), $value);
117  }
118 
124  {
125  $gui = $criterion->ui($this->lng);
126 
127  $actual = $gui->getIdentPresentation();
128 
129  $this->assertIsString($actual);
130  $this->assertNotEmpty($actual);
131  }
132 
136  public function testValuePresentationMatchesExpectation() : void
137  {
138  $criterion = $this->getInstance();
139  $gui = $criterion->ui($this->lng);
140 
142  $actual = $gui->getValuePresentation(
143  $this->getCriterionConfig(),
144  $this->getUiFactoryMock()
145  );
146 
147  $this->assertInstanceOf(Component::class, $actual);
148  $this->assertInstanceOf(Legacy::class, $actual);
149  $this->assertEquals('-', $actual->getContent());
150  }
151 
155  public function testEvaluationAlwaysSucceeds() : void
156  {
157  $user = $this->getUserMock();
158  $criterion = $this->getInstance();
159 
160  $this->assertTrue($criterion->evaluate($user, $this->getCriterionConfig()));
161  }
162 }
testTypeIdentPresentationEqualsANonEmptyString(ilTermsOfServiceNullCriterion $criterion)
testNoFormUserInterfaceElementsAreBuilt
Interface ilTermsOfServiceCriterionTypeGUI.
This class represents a property form user interface.
Class ilTermsOfServiceCriterionBaseTest.
buildForm(ilTermsOfServiceCriterionTypeGUI $gui)
testNoFormUserInterfaceElementsAreBuilt(ilTermsOfServiceNullCriterion $criterion)
testCriterionAlwaysCreateEmptyConfigValue(ilTermsOfServiceNullCriterion $criterion)
testNoFormUserInterfaceElementsAreBuilt
Class ilTermsOfServiceNullCriterion.
appendOption(ilRadioGroupInputGUI $option, ilTermsOfServiceCriterionConfig $config)
Class ilTermsOfServiceNullCriterionTest.