mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
improve function isEmptyValue + tests
This commit is contained in:
@@ -344,22 +344,79 @@ class CustomFieldsChoiceTest extends KernelTestCase
|
||||
////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* test the not empty with the not-empty data provider
|
||||
*
|
||||
* @param mixed $data
|
||||
* @dataProvider serializedRepresentationDataProvider
|
||||
*/
|
||||
public function testIsEmptyValueNotEmpty($data)
|
||||
{
|
||||
$this->markTestSkipped("We have to improve the isEmptyFunction");
|
||||
$customField = $this->generateCustomField(array(
|
||||
CustomFieldChoice::ALLOW_OTHER => false,
|
||||
CustomFieldChoice::MULTIPLE => true
|
||||
));
|
||||
|
||||
$isEmpty = $this->cfChoice->isEmptyValue($data, $customField);
|
||||
|
||||
$this->assertFalse($isEmpty);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @dataProvider emptyDataProvider
|
||||
* @param mixed $data
|
||||
*/
|
||||
public function testIsEmptyValueEmpty($data)
|
||||
{
|
||||
$customField = $this->generateCustomField(array(
|
||||
CustomFieldChoice::ALLOW_OTHER => false,
|
||||
CustomFieldChoice::MULTIPLE => true
|
||||
));
|
||||
|
||||
$deserialized = $this->cfChoice->deserialize($data, $customField);
|
||||
$isEmpty = $this->cfChoice->isEmptyValue($deserialized, $customField);
|
||||
$isEmpty = $this->cfChoice->isEmptyValue($data, $customField);
|
||||
|
||||
$this->assertFalse($isEmpty);
|
||||
$this->assertTrue($isEmpty);
|
||||
}
|
||||
|
||||
/**
|
||||
* provide empty data in different possible reprsentation
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider()
|
||||
{
|
||||
return array(
|
||||
// 0
|
||||
array(
|
||||
// signle
|
||||
''
|
||||
),
|
||||
// 1
|
||||
array(
|
||||
// single
|
||||
null
|
||||
),
|
||||
// 2
|
||||
array(
|
||||
// signle with allow other
|
||||
array('_other' => 'something', '_choices' => '')
|
||||
),
|
||||
// 3
|
||||
array(
|
||||
// multiple
|
||||
array()
|
||||
),
|
||||
// 4
|
||||
array(
|
||||
// multiple with allow other
|
||||
array('_other' => 'something', '_choices' => array())
|
||||
),
|
||||
// 5
|
||||
array(
|
||||
// multiple with allow other
|
||||
array('_other' => '', '_choices' => array())
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user