| Conditions | 1 |
| Paths | 1 |
| Total Lines | 24 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | public function testValidate() { |
||
| 6 | $field = new UserFormsCheckboxSetField('Field', 'My field', array('One' => 'One', 'Two' => 'Two')); |
||
| 7 | $validator = new RequiredFields(); |
||
| 8 | |||
| 9 | // String values |
||
| 10 | $field->setValue('One'); |
||
| 11 | $this->assertTrue($field->validate($validator)); |
||
| 12 | $field->setValue('One,Two'); |
||
| 13 | $this->assertTrue($field->validate($validator)); |
||
| 14 | $field->setValue('Three,Four'); |
||
| 15 | $this->assertFalse($field->validate($validator)); |
||
| 16 | |||
| 17 | // Array values |
||
| 18 | $field->setValue(array('One')); |
||
| 19 | $this->assertTrue($field->validate($validator)); |
||
| 20 | $field->setValue(array('One', 'Two')); |
||
| 21 | $this->assertTrue($field->validate($validator)); |
||
| 22 | |||
| 23 | // Invalid |
||
| 24 | $field->setValue('Three'); |
||
| 25 | $this->assertFalse($field->validate($validator)); |
||
| 26 | $field->setValue(array('Three', 'Four')); |
||
| 27 | $this->assertFalse($field->validate($validator)); |
||
| 28 | } |
||
| 29 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.