You can use the Smarty fetch() function. Below is a free example / pseudo code.
Testing Template
{* foo.tpl *} <html> <head></head> <body>{$hi}</body> </html>
Expected Result
<html> <head></head> <body>Hello World!</body> </html>
Class TestCase
class FooTemplateTestCase extends TestCase { protected $_view; public function setup(){ $this->_view = new Smarty(); // setup smarty options, caching, etc } public function test(){ $this->_view->assign('hi', 'Hello World!'); $output = $this->_view->fetch('foo.tpl'); $expected_output = file_get_contents('foo.html'); $this->assertEquals($expected_output, $output); } }
source share