Dropped Convert::toJSON()

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.
This commit is contained in:
Josh Sherman 2013-12-24 13:28:49 -05:00
parent 0cbc1df48f
commit 9b297f3d87
7 changed files with 6 additions and 70 deletions

View file

@ -1,40 +1,9 @@
<?php
require_once 'classes/Convert.php';
define('JSON_AVAILABLE', true);
class ConvertTest extends PHPUnit_Framework_TestCase
{
/**
* @dataProvider providerToJSON
*/
public function testToJSON($a, $b)
{
$this->assertEquals(Convert::toJSON($a), $b);
}
public function providerToJSON()
{
$object = (object)'object';
$object->foo = 'foo';
$object->bar = 'bar';
return array(
array('', '""'),
array('foo', '"foo"'),
array(array('bar'), '["bar"]'),
array(array('foo', 'bar'), '["foo","bar"]'),
array(19810223, '19810223'),
array(array(1981, 02, 23), '[1981,2,23]'),
array(array('foo', 1981), '["foo",1981]'),
array(array('foo', array('bar')), '["foo",["bar"]]'),
array($object, '{"scalar":"object","foo":"foo","bar":"bar"}'),
array(true, 'true'),
array(false, 'false'),
array(null, 'null'),
);
}
/**
* @dataProvider providerArrayToXML
*/