public function testToJson() { $converter = new Converter(); $this->assertEquals($converter->toJson('<h2>Test</h2>'), '{"data":[{"type":"heading","data":{"text":" Test"}}]}'); // a quote $this->assertEquals($converter->toJson('<blockquote><p>Text</p><cite>Cite</cite></blockquote>'), '{"data":[{"type":"quote","data":{"text":" Text","cite":" Cite"}}]}'); $this->assertEquals($converter->toJson('<blockquote><p>Text</p></blockquote>'), '{"data":[{"type":"quote","data":{"text":" Text","cite":""}}]}'); $this->assertEquals($converter->toJson('<img src="/path/to/img.jpg" />'), '{"data":[{"type":"image","data":{"file":{"url":"\\/path\\/to\\/img.jpg"}}}]}'); }
public function showResultAction($id) { $repositoryComment = $this->getDoctrine()->getManager()->getRepository('PouceTeamBundle:Comment'); $repositoryResult = $this->getDoctrine()->getManager()->getRepository('PouceTeamBundle:Result'); $comment = $repositoryComment->findOneByTeam($id); $result = $repositoryResult->findOneByTeam($id); // create a converter object and handle the input $converter = new Converter(); $html = $converter->toHtml($comment->getBlock()); return $this->render('PouceTeamBundle:Team:showResult.html.twig', array('html' => $html, 'result' => $result)); }