ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
RequestValidationHelperTest Class Reference
+ Inheritance diagram for RequestValidationHelperTest:
+ Collaboration diagram for RequestValidationHelperTest:

Public Member Functions

 testConstruct ()
 
 test_checkPointsFromRequest_shouldAbort_whenEmptyData ()
 
 test_checkPointsFromRequest_shouldAbort_whenEmptyPoints ()
 
 test_checkPointsFromRequest_shouldReturn_whenEmptyPoints ()
 
 test_checkPointsFromRequest_shouldAbort_whenNonNumericPoints ()
 
 test_checkPointsFromRequest_shouldReturn_whenPointsAsString ()
 
 test_checkPointsFromRequest_shouldAbort_whenZeroPoints ()
 
 test_checkPointsFromRequest_shouldReturn_whenNonZeroPoints ()
 
 test_inArray_shouldReturnFalse_whenEmptyArray ()
 
 test_inArray_shouldReturnFalse_whenKeyNotFound ()
 
 test_inArray_shouldReturnTrue_whenKeyFound ()
 
 test_inArray_shouldReturnFalse_whenEmptyStringValue ()
 
 test_inArray_shouldReturnFalse_whenEmptyArrayValue ()
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from assBaseTestCase
 setUp ()
 
 tearDown ()
 
 getIRSSMock ()
 

Private Attributes

ilTestLegacyFormsHelper $object
 

Additional Inherited Members

- Protected Attributes inherited from assBaseTestCase
Container $dic = null
 

Detailed Description

Definition at line 25 of file RequestValidationHelperTest.php.

Member Function Documentation

◆ setUp()

RequestValidationHelperTest::setUp ( )
protected

Reimplemented from assBaseTestCase.

Definition at line 29 of file RequestValidationHelperTest.php.

29 : 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 }
setGlobalVariable(string $name, mixed $value)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References setGlobalVariable().

+ Here is the call graph for this function:

◆ test_checkPointsFromRequest_shouldAbort_whenEmptyData()

RequestValidationHelperTest::test_checkPointsFromRequest_shouldAbort_whenEmptyData ( )

Definition at line 45 of file RequestValidationHelperTest.php.

45 : void
46 {
47 $data = [];
48 $expected = 'msg_input_is_required';
49 $actual = $this->object->checkPointsInput($data, true);
50 $this->assertEquals($expected, $actual);
51 }

References $data.

◆ test_checkPointsFromRequest_shouldAbort_whenEmptyPoints()

RequestValidationHelperTest::test_checkPointsFromRequest_shouldAbort_whenEmptyPoints ( )

Definition at line 53 of file RequestValidationHelperTest.php.

53 : void
54 {
55 $data = ['points' => []];
56 $expected = 'msg_input_is_required';
57 $actual = $this->object->checkPointsInput($data, true);
58 $this->assertEquals($expected, $actual);
59 }

References $data.

◆ test_checkPointsFromRequest_shouldAbort_whenNonNumericPoints()

RequestValidationHelperTest::test_checkPointsFromRequest_shouldAbort_whenNonNumericPoints ( )

Definition at line 69 of file RequestValidationHelperTest.php.

69 : void
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 }

References $data.

◆ test_checkPointsFromRequest_shouldAbort_whenZeroPoints()

RequestValidationHelperTest::test_checkPointsFromRequest_shouldAbort_whenZeroPoints ( )

Definition at line 85 of file RequestValidationHelperTest.php.

85 : void
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 }

References $data.

◆ test_checkPointsFromRequest_shouldReturn_whenEmptyPoints()

RequestValidationHelperTest::test_checkPointsFromRequest_shouldReturn_whenEmptyPoints ( )

Definition at line 61 of file RequestValidationHelperTest.php.

61 : void
62 {
63 $data = ['points' => []];
64 $expected = [];
65 $actual = $this->object->checkPointsInput($data, false);
66 $this->assertEquals($expected, $actual);
67 }

References $data.

◆ test_checkPointsFromRequest_shouldReturn_whenNonZeroPoints()

RequestValidationHelperTest::test_checkPointsFromRequest_shouldReturn_whenNonZeroPoints ( )

Definition at line 93 of file RequestValidationHelperTest.php.

93 : void
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 }

References $data.

◆ test_checkPointsFromRequest_shouldReturn_whenPointsAsString()

RequestValidationHelperTest::test_checkPointsFromRequest_shouldReturn_whenPointsAsString ( )

Definition at line 77 of file RequestValidationHelperTest.php.

77 : void
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 }

References $data.

◆ test_inArray_shouldReturnFalse_whenEmptyArray()

RequestValidationHelperTest::test_inArray_shouldReturnFalse_whenEmptyArray ( )

Definition at line 101 of file RequestValidationHelperTest.php.

101 : void
102 {
103 $array = [];
104 $key = 'test';
105 $this->assertFalse($this->object->inArray($array, $key));
106 }

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ test_inArray_shouldReturnFalse_whenEmptyArrayValue()

RequestValidationHelperTest::test_inArray_shouldReturnFalse_whenEmptyArrayValue ( )

Definition at line 128 of file RequestValidationHelperTest.php.

128 : void
129 {
130 $array = ['test' => []];
131 $key = 'test';
132 $this->assertFalse($this->object->inArray($array, $key));
133 }

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ test_inArray_shouldReturnFalse_whenEmptyStringValue()

RequestValidationHelperTest::test_inArray_shouldReturnFalse_whenEmptyStringValue ( )

Definition at line 121 of file RequestValidationHelperTest.php.

121 : void
122 {
123 $array = ['test' => ''];
124 $key = 'test';
125 $this->assertFalse($this->object->inArray($array, $key));
126 }

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ test_inArray_shouldReturnFalse_whenKeyNotFound()

RequestValidationHelperTest::test_inArray_shouldReturnFalse_whenKeyNotFound ( )

Definition at line 108 of file RequestValidationHelperTest.php.

108 : void
109 {
110 $array = ['not_test' => 'value'];
111 $key = 'test';
112 $this->assertFalse($this->object->inArray($array, $key));
113 }

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ test_inArray_shouldReturnTrue_whenKeyFound()

RequestValidationHelperTest::test_inArray_shouldReturnTrue_whenKeyFound ( )

Definition at line 115 of file RequestValidationHelperTest.php.

115 : void
116 {
117 $array = ['test' => 'value'];
118 $key = 'test';
119 $this->assertTrue($this->object->inArray($array, $key));
120 }

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ testConstruct()

RequestValidationHelperTest::testConstruct ( )

Definition at line 40 of file RequestValidationHelperTest.php.

40 : void
41 {
42 $this->assertInstanceOf(ilTestLegacyFormsHelper::class, $this->object);
43 }

Field Documentation

◆ $object

ilTestLegacyFormsHelper RequestValidationHelperTest::$object
private

Definition at line 27 of file RequestValidationHelperTest.php.


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