*/
namespace Whoops\Util;
use Whoops\TestCase;
use Whoops\Util\TemplateHelper;
class TemplateHelperTest extends TestCase
{
/**
* @var Whoops\Util\TemplateHelper
*/
private $helper;
/**
* {@inheritDoc}
*/
public function setUp()
{
$this->helper = new TemplateHelper;
}
/**
* @covers Whoops\Util\TemplateHelper::escapeButPreserveUris
* @covers Whoops\Util\TemplateHelper::escape
*/
public function testEscape()
{
$original = "This is a Foo test string";
$this->assertEquals(
$this->helper->escape($original),
"This is a <a href=''>Foo</a> test string"
);
}
/**
* @covers Whoops\Util\TemplateHelper::escapeButPreserveUris
*/
public function testEscapeButPreserveUris()
{
$original = "This is a http://google.com test string";
$this->assertEquals(
$this->helper->escapeButPreserveUris($original),
"This is a <a href=''>http://google.com</a> test string"
);
}
/**
* @covers Whoops\Util\TemplateHelper::slug
*/
public function testSlug()
{
$this->assertEquals("hello-world", $this->helper->slug("Hello, world!"));
$this->assertEquals("potato-class", $this->helper->slug("Potato class"));
}
/**
* @covers Whoops\Util\TemplateHelper::render
*/
public function testRender()
{
$template = __DIR__ . "/../../fixtures/template.php";
ob_start();
$this->helper->render($template, array("name" => "Bb"));
$output = ob_get_clean();
$this->assertEquals(
$output,
"hello-world\nMy name is B<o>b"
);
}
}