| @@ 98-105 (lines=8) @@ | ||
| 95 | $this->assertEquals($items, $field3->getSource()); |
|
| 96 | } |
|
| 97 | ||
| 98 | public function testReadonlyField() |
|
| 99 | { |
|
| 100 | $field = new DropdownField('FeelingOk', 'Are you feeling ok?', array(0 => 'No', 1 => 'Yes')); |
|
| 101 | $field->setEmptyString('(Select one)'); |
|
| 102 | $field->setValue(1); |
|
| 103 | $readonlyField = $field->performReadonlyTransformation(); |
|
| 104 | preg_match('/Yes/', $field->Field(), $matches); |
|
| 105 | $this->assertEquals($matches[0], 'Yes'); |
|
| 106 | } |
|
| 107 | ||
| 108 | public function testHasEmptyDefault() |
|
| @@ 75-83 (lines=9) @@ | ||
| 72 | $this->assertFalse($field->validate($validator)); |
|
| 73 | } |
|
| 74 | ||
| 75 | public function testReadonlyField() |
|
| 76 | { |
|
| 77 | $sourceArray = array(0 => 'No', 1 => 'Yes'); |
|
| 78 | $field = new OptionsetField('FeelingOk', 'are you feeling ok?', $sourceArray, 1); |
|
| 79 | $field->setEmptyString('(Select one)'); |
|
| 80 | $field->setValue(1); |
|
| 81 | $readonlyField = $field->performReadonlyTransformation(); |
|
| 82 | preg_match('/Yes/', $readonlyField->Field(), $matches); |
|
| 83 | $this->assertEquals($matches[0], 'Yes'); |
|
| 84 | } |
|
| 85 | ||
| 86 | public function testSafelyCast() |
|