/** * Test json convertion of single value */ public function testConvertValue() { $data = 'This is a test of convetion'; $converted = '{}&&("This is a test of convetion")'; $result = Phprojekt_Converter_Json::convert($data); $this->assertEquals($converted, $result); $data = array('This is a test of convetion'); $converted = '{}&&(["This is a test of convetion"])'; $result = Phprojekt_Converter_Json::convert($data); $this->assertEquals($converted, $result); $result = Phprojekt_Converter_Json::convert(array()); $converted = '{}&&({"metadata":[]})'; $this->assertEquals($converted, $result); }
/** * Test json convertion of tags */ public function testConvertTags() { $tagObj = Phprojekt_Tags::getInstance(); $tags = $tagObj->getTags(1); $fields = $tagObj->getFieldDefinition(); $result = Phprojekt_Converter_Json::convert($tags, $fields); $converted = '{}&&({"metadata":[{"key":"string","label":"Tag"},{"key":"count","label":"Count"}],"data":[{"'; $this->assertEquals($converted, substr($result, 0, strlen($converted))); }