mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #2689 from halkyon/checkboxsetfield_test
Adding test for CheckboxSetField saving into a text DB field.
This commit is contained in:
commit
2fbe8d325b
@ -122,6 +122,26 @@ class CheckboxSetFieldTest extends SapphireTest {
|
||||
'CheckboxSetField loads data from a manymany relationship in an object through Form->loadDataFrom()'
|
||||
);
|
||||
}
|
||||
|
||||
public function testSavingIntoTextField() {
|
||||
$field = new CheckboxSetField('Content', 'Content', array(
|
||||
'Test' => 'Test',
|
||||
'Another' => 'Another',
|
||||
'Something' => 'Something'
|
||||
));
|
||||
$article = new CheckboxSetFieldTest_Article();
|
||||
$field->setValue(array('Test' => 'Test', 'Another' => 'Another'));
|
||||
$field->saveInto($article);
|
||||
$article->write();
|
||||
|
||||
$dbValue = DB::query(sprintf(
|
||||
'SELECT "Content" FROM "CheckboxSetFieldTest_Article" WHERE "ID" = %s',
|
||||
$article->ID
|
||||
))->value();
|
||||
|
||||
$this->assertEquals('Test,Another', $dbValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CheckboxSetFieldTest_Article extends DataObject implements TestOnly {
|
||||
|
Loading…
Reference in New Issue
Block a user