forked from zendframework/zendframework
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change to dataprovider for duplicate type setting test for NotEmpty v…
…alidator
- Loading branch information
David Stockton
committed
Feb 26, 2014
1 parent
0c0c19b
commit 447a376
Showing
1 changed file
with
34 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -414,30 +414,44 @@ public function testStringNotation() | |
* Ensures that the validator follows expected behavior so if a string is specified more than once, it doesn't | ||
* cause different validations to run | ||
* | ||
* @param string $string Array of string type values | ||
* @param integer $expected Expected type setting value | ||
* | ||
* @return void | ||
* | ||
* @dataProvider duplicateStringSettingProvider | ||
*/ | ||
public function testStringNotationWithDuplicate() | ||
public function testStringNotationWithDuplicate($string, $expected) | ||
{ | ||
$filter = new NotEmpty( | ||
array( | ||
// Should only count as 'boolean' | ||
'type' => array('boolean', 'boolean') | ||
) | ||
); | ||
$type = array($string, $string); | ||
$this->validator->setType($type); | ||
|
||
$this->assertFalse($filter->isValid(false)); | ||
$this->assertTrue($filter->isValid(true)); | ||
$this->assertTrue($filter->isValid(0)); | ||
$this->assertTrue($filter->isValid(1)); | ||
$this->assertTrue($filter->isValid((float) 0.0)); | ||
$this->assertTrue($filter->isValid((float) 1.0)); | ||
$this->assertTrue($filter->isValid('')); | ||
$this->assertTrue($filter->isValid('abc')); | ||
$this->assertTrue($filter->isValid('0')); | ||
$this->assertTrue($filter->isValid('1')); | ||
$this->assertTrue($filter->isValid(array())); | ||
$this->assertTrue($filter->isValid(array('xxx'))); | ||
$this->assertTrue($filter->isValid(null)); | ||
$this->assertEquals($expected, $this->validator->getType()); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dstockto
Owner
|
||
} | ||
|
||
/** | ||
* Data provider for testStringNotationWithDuplicate method. Provides a string which will be duplicated. The test | ||
* ensures that setting a string value more than once only turns on the appropriate bit once | ||
* | ||
* @return array | ||
*/ | ||
public function duplicateStringSettingProvider() | ||
{ | ||
return array( | ||
array('boolean', NotEmpty::BOOLEAN), | ||
array('integer', NotEmpty::INTEGER), | ||
array('float', NotEmpty::FLOAT), | ||
array('string', NotEmpty::STRING), | ||
array('zero', NotEmpty::ZERO), | ||
array('array', NotEmpty::EMPTY_ARRAY), | ||
array('null', NotEmpty::NULL), | ||
array('php', NotEmpty::PHP), | ||
array('space', NotEmpty::SPACE), | ||
array('object', NotEmpty::OBJECT), | ||
array('objectstring', NotEmpty::OBJECT_STRING), | ||
array('objectcount', NotEmpty::OBJECT_COUNT), | ||
array('all', NotEmpty::ALL), | ||
); | ||
} | ||
|
||
/** | ||
|
This don't test isValid method.