ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTermsOfServiceNullCriterionTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
6 
12 {
14  protected $lng;
15 
19  public function setUp()
20  {
21  parent::setUp();
22 
23  $this->lng = $this->getLanguageMock();
24 
25  $this->lng
26  ->expects($this->any())
27  ->method('txt')
28  ->willReturn('dummy');
29  }
30 
35  {
36  $criterion = new \ilTermsOfServiceNullCriterion();
37 
38  return $criterion;
39  }
40 
45  {
46  $criterion = $this->getInstance();
47 
48  $this->assertEquals('null', $criterion->getTypeIdent());
49  $this->assertEquals(false, $criterion->hasUniqueNature());
50 
51  return $criterion;
52  }
53 
58  protected function buildForm(
60  ) : \ilPropertyFormGUI {
61  $form = $this->getFormMock();
62 
63  $radioGroup = $this
64  ->getMockBuilder(\ilRadioGroupInputGUI::class)
65  ->disableOriginalConstructor()
66  ->setMethods(['getPostVar', 'addOption'])
67  ->getMock();
68 
69  $form->addItem($radioGroup);
70 
71  $radioGroup
72  ->expects($this->never())
73  ->method('addOption');
74 
75  $gui->appendOption($radioGroup, $this->getCriterionConfig());
76 
77  return $form;
78  }
79 
86  {
87  $gui = $criterion->ui($this->lng);
88 
89  $this->buildForm($gui);
90 
91  return $criterion;
92  }
93 
99  {
100  $gui = $criterion->ui($this->lng);
101 
102  $form = $this->buildForm($gui);
103 
104  $form
105  ->expects($this->never())
106  ->method('getInput');
107 
108  $value = $gui->getConfigByForm($form);
109 
110  $this->assertInstanceOf(\ilTermsOfServiceCriterionConfig::class, $value);
111  $this->assertEquals($this->getCriterionConfig(), $value);
112  }
113 
119  {
120  $gui = $criterion->ui($this->lng);
121 
122  $actual = $gui->getIdentPresentation();
123 
124  $this->assertInternalType('string', $actual);
125  $this->assertNotEmpty($actual);
126  }
127 
131  public function testValuePresentationMatchesExpectation()
132  {
133  $criterion = $this->getInstance();
134  $gui = $criterion->ui($this->lng);
135 
137  $actual = $gui->getValuePresentation(
138  $this->getCriterionConfig(),
139  $this->dic->ui()->factory()
140  );
141 
142  $this->assertInstanceOf(Component::class, $actual);
143  $this->assertInstanceOf(Legacy::class, $actual);
144  $this->assertEquals('-', $actual->getContent());
145  }
146 
151  {
152  $user = $this->getUserMock();
153  $criterion = $this->getInstance();
154 
155  $this->assertTrue($criterion->evaluate($user, $this->getCriterionConfig()));
156  }
157 }
Interface ilTermsOfServiceCriterionTypeGUI.
This class represents a property form user interface.
testNoFormUserInterfaceElementsAreBuilt(\ilTermsOfServiceNullCriterion $criterion)
Class ilTermsOfServiceCriterionBaseTest.
testTypeIdentPresentatioEqualsANonEmptyString(\ilTermsOfServiceNullCriterion $criterion)
testNoFormUserInterfaceElementsAreBuilt
if(isset($_POST['submit'])) $form
$user
Definition: migrateto20.php:57
appendOption(\ilRadioGroupInputGUI $option, \ilTermsOfServiceCriterionConfig $config)
Class ilTermsOfServiceNullCriterion.
testCriterionAlwaysCreateEmptyConfigValue(\ilTermsOfServiceNullCriterion $criterion)
testNoFormUserInterfaceElementsAreBuilt
buildForm(\ilTermsOfServiceCriterionTypeGUI $gui)
Class ilTermsOfServiceNullCriterionTest.