Skip to content

Commit

Permalink
BUG: #2503 Fixes performReadonlyTransformation for OptionSetField
Browse files Browse the repository at this point in the history
NEW: Adding unit test for performReadonlyTransformation #nd fixing OptionSetField #2503

BUG: Fixing undefined variables and function parameters for PerformReadonlyTransformation unit tests

NEW: Adding unit test to OptionsetField for read only fields
  • Loading branch information
kmayo-ss committed Jan 30, 2014
1 parent d81c357 commit 44a8537
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion forms/OptionsetField.php
Expand Up @@ -93,7 +93,7 @@ public function Field($properties = array()) {
public function performReadonlyTransformation() {
// Source and values are DataObject sets.
$field = $this->castedCopy('LookupField');
$field->setValue($this->getSource());
$field->setSource($this->getSource());
$field->setReadonly(true);

return $field;
Expand Down
10 changes: 10 additions & 0 deletions tests/forms/OptionsetFieldTest.php
Expand Up @@ -24,4 +24,14 @@ public function testSetDisabledItems() {
''
);
}

public function testReadonlyField() {
$sourceArray = array(0 => 'No', 1 => 'Yes');
$field = new OptionsetField('FeelingOk', 'are you feeling ok?', $sourceArray, 1);
$field->setEmptyString('(Select one)');
$field->setValue(1);
$readonlyField = $field->performReadonlyTransformation();
preg_match('/Yes/', $field->Field(), $matches);
$this->assertEquals($matches[0], 'Yes');
}
}

0 comments on commit 44a8537

Please sign in to comment.