mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 15:05:42 +00:00
Merge pull request #534 from tractorcow/pulls/fix-checkbox-validation
BUG Fix issue with UserFormsCheckboxSetField
This commit is contained in:
commit
8e4ad8f4df
11
.travis.yml
11
.travis.yml
@ -7,17 +7,13 @@ language: php
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- php: 5.3
|
- php: 5.3
|
||||||
env: DB=MYSQL CORE_RELEASE=3.1
|
env: DB=MYSQL CORE_RELEASE=3.4
|
||||||
- php: 5.4
|
- php: 5.4
|
||||||
env: DB=MYSQL CORE_RELEASE=3.2
|
env: DB=MYSQL CORE_RELEASE=3.5
|
||||||
- php: 5.5
|
|
||||||
env: DB=MYSQL CORE_RELEASE=3.3
|
|
||||||
- php: 5.6
|
- php: 5.6
|
||||||
env: DB=MYSQL CORE_RELEASE=3
|
env: DB=MYSQL CORE_RELEASE=3
|
||||||
- php: 5.6
|
- php: 5.6
|
||||||
env: DB=MYSQL CORE_RELEASE=3.1 SECUREASSETS=1
|
env: DB=MYSQL CORE_RELEASE=3.5 SECUREASSETS=1
|
||||||
- php: 5.6
|
|
||||||
env: DB=PGSQL CORE_RELEASE=3.3
|
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
|
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
|
||||||
@ -28,6 +24,7 @@ before_script:
|
|||||||
script:
|
script:
|
||||||
- vendor/bin/phpunit --coverage-clover coverage.clover userforms/tests
|
- vendor/bin/phpunit --coverage-clover coverage.clover userforms/tests
|
||||||
- wget https://scrutinizer-ci.com/ocular.phar
|
- wget https://scrutinizer-ci.com/ocular.phar
|
||||||
|
- cd ./userforms
|
||||||
- git remote rm origin
|
- git remote rm origin
|
||||||
- git remote add origin git@github.com:silverstripe/silverstripe-userforms.git
|
- git remote add origin git@github.com:silverstripe/silverstripe-userforms.git
|
||||||
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
|
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
|
||||||
|
@ -23,18 +23,6 @@ class UserFormsCheckboxSetField extends CheckboxSetField
|
|||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getSourceAsArray()
|
|
||||||
{
|
|
||||||
$array = parent::getSourceAsArray();
|
|
||||||
|
|
||||||
return array_values($array);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*
|
*
|
||||||
|
29
tests/UserFormsCheckboxSetFieldTest.php
Normal file
29
tests/UserFormsCheckboxSetFieldTest.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class UserFormsCheckboxSetFieldTest extends SapphireTest
|
||||||
|
{
|
||||||
|
public function testValidate() {
|
||||||
|
$field = new UserFormsCheckboxSetField('Field', 'My field', array('One' => 'One', 'Two' => 'Two'));
|
||||||
|
$validator = new RequiredFields();
|
||||||
|
|
||||||
|
// String values
|
||||||
|
$field->setValue('One');
|
||||||
|
$this->assertTrue($field->validate($validator));
|
||||||
|
$field->setValue('One,Two');
|
||||||
|
$this->assertTrue($field->validate($validator));
|
||||||
|
$field->setValue('Three,Four');
|
||||||
|
$this->assertFalse($field->validate($validator));
|
||||||
|
|
||||||
|
// Array values
|
||||||
|
$field->setValue(array('One'));
|
||||||
|
$this->assertTrue($field->validate($validator));
|
||||||
|
$field->setValue(array('One', 'Two'));
|
||||||
|
$this->assertTrue($field->validate($validator));
|
||||||
|
|
||||||
|
// Invalid
|
||||||
|
$field->setValue('Three');
|
||||||
|
$this->assertFalse($field->validate($validator));
|
||||||
|
$field->setValue(array('Three', 'Four'));
|
||||||
|
$this->assertFalse($field->validate($validator));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user