Skip to content

Commit

Permalink
Added more testcases to ChoiceTest
Browse files Browse the repository at this point in the history
  • Loading branch information
rpkamp committed May 28, 2012
1 parent 7b3500e commit 5c49173
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions tests/Structr/Test/Composite/ChoiceTest.php
Expand Up @@ -6,36 +6,37 @@

class ChoiceTest extends \PHPUnit_Framework_TestCase
{

public function testSimpleMap() {
$array = array(
3,
6,
"3.1415"
);

$expected = array(
3,
6,
3.1415
public function testSimpleData()
{
return array(
array(3, 3, true),
array(6, 6, true),
array('3.1415', 3.1415, true),
array('a', '', false),
array(array(1,2,3), '', false),
array(new \stdClass(), '', false)
);

$result = Structr::ize($array)
->isList()
->item()
->isChoice()
->altPrototype()
->isInteger()->end()
->endPrototype()
->altPrototype()
->isFloat()->coerce()->end()
->endPrototype()
->end()
->endItem()
}

/**
* @dataProvider testSimpleData
*/
public function testSimple($input, $expected, $success) {
if (!$success) {
$this->setExpectedException('\Structr\Exception');
}

$result = Structr::ize($input)
->isChoice()
->altPrototype()
->isInteger()->end()
->endPrototype()
->altPrototype()
->isFloat()->coerce(true)->end()
->endPrototype()
->end()
->run();

$this->assertSame($expected, $result);
}

}

0 comments on commit 5c49173

Please sign in to comment.