In an effort to only maintain compatibility with the latest version of PHP (currently the 5.5 branch) I dropped the sanity checks if `json_encode` was available as it is always available in PHP 5.2+. Dropping this sanity check also allowed me to remove the wrapper function and the `JSON_AVAILABLE` constant. Ideally I'd like to move towards dropping the `Convert` class entirely but will need a way to convert an array to XML as the `RSS` class still leverages it. One thought is to move that code right into the `RSS` class as it never gets used elsewhere because XML is gross.
28 lines
992 B
PHP
28 lines
992 B
PHP
<?php
|
|
|
|
require_once 'classes/Convert.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 array(
|
|
array('foo', false, ''),
|
|
array(array('foo', 'bar'), false, '<0>foo</0><1>bar</1>'),
|
|
array(array('foo', 'bar'), true, "<0>foo</0>\n<1>bar</1>\n"),
|
|
array(array('foo' => 'bar'), false, '<foo>bar</foo>'),
|
|
array(array('children' => array('child' => array('foo', 'bar'))), false, '<children><child>foo</child><child>bar</child></children>'),
|
|
array(array('children' => array('child' => array('foo', 'bar'))), true, "<children>\n\t<child>foo</child>\n\t<child>bar</child>\n</children>\n"),
|
|
);
|
|
}
|
|
}
|
|
|
|
?>
|