Ejemplo n.º 1
0
 /**
  * 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);
 }
Ejemplo n.º 2
0
 /**
  * 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)));
 }