From 761cc63e19200dc9dd726108304b4a20e9575a21 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 28 Nov 2013 14:13:56 +1300 Subject: [PATCH] Adding test for CheckboxSetField saving into a text DB field. --- tests/forms/CheckboxSetFieldTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/forms/CheckboxSetFieldTest.php b/tests/forms/CheckboxSetFieldTest.php index 0e9e52f83..609084782 100644 --- a/tests/forms/CheckboxSetFieldTest.php +++ b/tests/forms/CheckboxSetFieldTest.php @@ -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 {