| Conditions | 1 |
| Paths | 1 |
| Total Lines | 25 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | public function testValidate() |
||
| 12 | { |
||
| 13 | $field = new UserFormsCheckboxSetField('Field', 'My field', ['One' => 'One', 'Two' => 'Two']); |
||
| 14 | $validator = new RequiredFields(); |
||
| 15 | |||
| 16 | // String values |
||
| 17 | $field->setValue('One'); |
||
| 18 | $this->assertTrue($field->validate($validator)); |
||
|
|
|||
| 19 | $field->setValue('One,Two'); |
||
| 20 | $this->assertTrue($field->validate($validator)); |
||
| 21 | $field->setValue('Three,Four'); |
||
| 22 | $this->assertFalse($field->validate($validator)); |
||
| 23 | |||
| 24 | // Array values |
||
| 25 | $field->setValue(array('One')); |
||
| 26 | $this->assertTrue($field->validate($validator)); |
||
| 27 | $field->setValue(array('One', 'Two')); |
||
| 28 | $this->assertTrue($field->validate($validator)); |
||
| 29 | |||
| 30 | // Invalid |
||
| 31 | $field->setValue('Three'); |
||
| 32 | $this->assertFalse($field->validate($validator)); |
||
| 33 | $field->setValue(array('Three', 'Four')); |
||
| 34 | $this->assertFalse($field->validate($validator)); |
||
| 35 | } |
||
| 36 | } |
||
| 37 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: