Conditions | 1 |
Paths | 1 |
Total Lines | 70 |
Code Lines | 42 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
77 | public function testValidationOfNestedConditionalRequiredFields() |
||
78 | { |
||
79 | $page = $this->objFromFixture(UserDefinedForm::class, 'required-nested-custom-rules-form'); |
||
80 | $this->assertEquals(4, $page->Fields()->count()); |
||
81 | $validator = $this->getValidatorFromPage($page); |
||
82 | $this->assertNotNull($validator); |
||
83 | |||
84 | $this->assertFalse( |
||
85 | $validator->php([]), |
||
86 | 'Fails when non-conditional required field is empty' |
||
87 | ); |
||
88 | |||
89 | $this->assertTrue( |
||
90 | $validator->php( |
||
91 | [ |
||
92 | 'required-text-field-3' => 'some text', |
||
93 | 'radio-option-2' => 'N', |
||
94 | 'conditional-required-text-2' => '', |
||
95 | 'conditional-required-text-3' => '' |
||
96 | ] |
||
97 | ), |
||
98 | 'Passes when non-conditional required field has a value' |
||
99 | ); |
||
100 | |||
101 | $this->assertFalse( |
||
102 | $validator->php( |
||
103 | [ |
||
104 | 'required-text-field-3' => 'some text', |
||
105 | 'radio-option-2' => 'Y', |
||
106 | 'conditional-required-text-2' => '', |
||
107 | 'conditional-required-text-3' => '' |
||
108 | ] |
||
109 | ), |
||
110 | 'Fails when conditional required is displayed but not completed' |
||
111 | ); |
||
112 | |||
113 | $this->assertTrue( |
||
114 | $validator->php( |
||
115 | [ |
||
116 | 'required-text-field-3' => 'some text', |
||
117 | 'radio-option-3' => 'Y', |
||
118 | 'conditional-required-text-2' => 'this text', |
||
119 | 'conditional-required-text-3' => '' |
||
120 | ] |
||
121 | ), |
||
122 | 'Passes when non-conditional required field has a value' |
||
123 | ); |
||
124 | |||
125 | $this->assertFalse( |
||
126 | $validator->php( |
||
127 | [ |
||
128 | 'required-text-field-3' => 'some text', |
||
129 | 'radio-option-3' => 'Y', |
||
130 | 'conditional-required-text-2' => 'Show more', |
||
131 | 'conditional-required-text-3' => '' |
||
132 | ] |
||
133 | ), |
||
134 | 'Fails when nested conditional required is displayed but not completed' |
||
135 | ); |
||
136 | |||
137 | $this->assertTrue( |
||
138 | $validator->php( |
||
139 | [ |
||
140 | 'required-text-field-3' => 'some text', |
||
141 | 'radio-option-3' => 'Y', |
||
142 | 'conditional-required-text-2' => 'Show more', |
||
143 | 'conditional-required-text-3' => 'more text' |
||
144 | ] |
||
145 | ), |
||
146 | 'Passes when nested conditional required field has a value' |
||
147 | ); |
||
150 |