require_once 'Savant3.php'; class Renderer_Savant3Test extends PHPUnit2_Framework_TestCase { protected $template; public function test_simple() { $template = new Savant3(); $template->setTemplate('test.savant.simple.tpl'); $template->setPath('template', 'Renderer/res/'); $template->assign('name', 'sven'); $expected = '
sven
'; $result = $template->fetch(); $result = self::stripWhitespace($result); $this->assertSameVerbose($expected, $result); } public function test_form_1() { $definition = array('name' => array('type' => 'String')); $form = patForms::createForm($definition, array('name' => 'test')); $form->setRenderer(patForms::createRenderer("Savant3", $args)); $template = $form->renderForm(array( 'tmplDir' => 'Renderer/res', 'tmplFile' => 'test.savant.form.tpl', )); $expected = ''; $result = $template->fetch(); $result = self::stripAction($result); $result = self::stripElementId($result); $result = self::stripWhitespace($result); $this->assertSameVerbose($expected, $result); } public function test_form_2() { $template = new Savant3(); $template->setTemplate('test.savant.form.tpl'); $template->setPath('template', 'Renderer/res/'); $definition = array('name' => array('type' => 'String')); $form = patForms::createForm($definition, array('name' => 'test')); $form->setRenderer(patForms::createRenderer("Savant3", $args)); $template = $form->renderForm($template); $expected = ''; $result = $template->fetch(); $result = self::stripAction($result); $result = self::stripElementId($result); $result = self::stripWhitespace($result); $this->assertSameVerbose($expected, $result); } static protected function stripAction($str) { return preg_replace('!action="[^\"]*"!', '', $str); } protected function stripElementId($element) { return preg_replace('!id="pfo[a-zA-Z0-9]*" ?!', '', $element); } static protected function stripWhitespace($str) { return preg_replace('|[\n\r\t]*|', '', $str); } protected function assertSameVerbose($expected, $result) { try { $this->assertTrue($expected == $result); } catch(Exception $e) { $lf = php_sapi_name() == 'cli' ? "\n" : '