for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sioen\Tests;
use Sioen\JsonToHtml;
class JsonToHtmlTest extends \PHPUnit_Framework_TestCase
{
public function testToHtml()
$converter = new JsonToHtml();
// let's try a basic json
$json = json_encode(array(
'data' => array(array(
'type' => 'quote',
'data' => array(
'text' => 'Text',
'cite' => 'Cite'
)
))
));
$html = $converter->toHtml($json);
$this->assertEquals(
$html,
"<blockquote><p>Text</p>\n<cite><p>Cite</p>\n</cite></blockquote>"
);
// Lets convert a normal text type that uses the default converter
'type' => 'text',
'text' => 'test'
$this->assertEquals($html, "<p>test</p>\n");
// the video conversion
'type' => 'video',
'source' => 'youtube',
'remote_id' => '4BXpi7056RM'
"<iframe src=\"//www.youtube.com/embed/4BXpi7056RM?rel=0\" frameborder=\"0\" allowfullscreen></iframe>\n"
// The heading
'type' => 'heading',
$this->assertEquals($html, "<h2>test</h2>\n");
// images
'type' => 'image',
'file' => array(
'url' => '/frontend/files/sir-trevor/images/IMG_3867.JPG'
$this->assertEquals($html, "<img src=\"/frontend/files/sir-trevor/images/IMG_3867.JPG\" />\n");
}