ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
RequestValidationHelperTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Data\Factory as DataFactory;
22use ILIAS\Refinery\Factory as Refinery;
24
26{
28
29 protected function setUp(): void
30 {
31 parent::setUp();
32
33 $lng_mock = $this->getMockBuilder(ILIAS\Language\Language::class)
34 ->disableOriginalConstructor()
35 ->getMock();
36 $this->setGlobalVariable('refinery', new Refinery(new DataFactory(), $lng_mock));
37 $this->object = new ilTestLegacyFormsHelper();
38 }
39
40 public function testConstruct(): void
41 {
42 $this->assertInstanceOf(ilTestLegacyFormsHelper::class, $this->object);
43 }
44
46 {
47 $data = [];
48 $expected = 'msg_input_is_required';
49 $actual = $this->object->checkPointsInput($data, true);
50 $this->assertEquals($expected, $actual);
51 }
52
54 {
55 $data = ['points' => []];
56 $expected = 'msg_input_is_required';
57 $actual = $this->object->checkPointsInput($data, true);
58 $this->assertEquals($expected, $actual);
59 }
60
62 {
63 $data = ['points' => []];
64 $expected = [];
65 $actual = $this->object->checkPointsInput($data, false);
66 $this->assertEquals($expected, $actual);
67 }
68
70 {
71 $data = ['points' => [1, 5.2, 'not a number']];
72 $expected = 'form_msg_numeric_value_required';
73 $actual = $this->object->checkPointsInput($data, false);
74 $this->assertEquals($expected, $actual);
75 }
76
78 {
79 $data = ['points' => [1, 5.2, '7.8', '9,1']];
80 $expected = [1.0, 5.2, 7.8, 9.1];
81 $actual = $this->object->checkPointsInput($data, false);
82 $this->assertEquals($expected, $actual);
83 }
84
86 {
87 $data = ['points' => [0, -6]];
88 $expected = 'enter_enough_positive_points';
89 $actual = $this->object->checkPointsInputEnoughPositive($data, true);
90 $this->assertEquals($expected, $actual);
91 }
92
94 {
95 $data = ['points' => [1, 5.2, 7.8, 9.1]];
96 $expected = [1.0, 5.2, 7.8, 9.1];
97 $actual = $this->object->checkPointsInputEnoughPositive($data, true);
98 $this->assertEquals($expected, $actual);
99 }
100
102 {
103 $array = [];
104 $key = 'test';
105 $this->assertFalse($this->object->inArray($array, $key));
106 }
107
109 {
110 $array = ['not_test' => 'value'];
111 $key = 'test';
112 $this->assertFalse($this->object->inArray($array, $key));
113 }
114
116 {
117 $array = ['test' => 'value'];
118 $key = 'test';
119 $this->assertTrue($this->object->inArray($array, $key));
120 }
122 {
123 $array = ['test' => ''];
124 $key = 'test';
125 $this->assertFalse($this->object->inArray($array, $key));
126 }
127
129 {
130 $array = ['test' => []];
131 $key = 'test';
132 $this->assertFalse($this->object->inArray($array, $key));
133 }
134}
Builds data types.
Definition: Factory.php:36
Class assBaseTestCase.
setGlobalVariable(string $name, mixed $value)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.