pickles/tests/classes/ConvertTest.php
Joshua Sherman faaefc1b82 Getting coverage to 100% on these classes
Also found a bug in the Form class that would bork phone numbers with dashes in
them. Even though the Form class is going to go away eventually I wanted to fix
the issue.
2014-01-12 13:56:52 -05:00

28 lines
1 KiB
PHP

<?php
class ConvertTest extends PHPUnit_Framework_TestCase
{
/**
* @dataProvider providerArrayToXML
*/
public function testArrayToXML($a, $b, $c)
{
$this->assertEquals(Convert::arrayToXML($a, $b), $c);
}
public function providerArrayToXML()
{
return [
['foo', false, ''],
[['foo', 'bar'], false, '<0>foo</0><1>bar</1>'],
[['foo', 'bar'], true, "<0>foo</0>\n<1>bar</1>\n"],
[['foo' => 'bar'], false, '<foo>bar</foo>'],
[['foo' => 'b & r'], false, '<foo><![CDATA[b & r]]></foo>'],
[['children' => ['child' => ['foo', 'bar']]], false, '<children><child>foo</child><child>bar</child></children>'],
[['children' => ['child' => ['foo & bar']]], false, '<children><child><![CDATA[foo & bar]]></child></children>'],
[['children' => ['child' => ['foo', 'bar']]], true, "<children>\n\t<child>foo</child>\n\t<child>bar</child>\n</children>\n"],
];
}
}
?>