class Renderer_FlexyTest extends PHPUnit2_Framework_TestCase { protected $template; public function test_simple() { $template = new HTML_Template_Flexy(array( 'templateDir' => 'Renderer/res', 'compileDir' => 'Renderer/res/templates_c', )); $template->compile('test.flexy.simple.tpl'); $template->setData('name', 'sven'); $expected = '
sven
'; $result = $template->bufferedOutputObject(); $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("Flexy")); $template = $form->renderForm(array( 'tmplFile' => 'test.flexy.form.tpl', 'tmplDir' => 'Renderer/res', 'compileDir' => 'Renderer/res/templates_c', )); $expected = ''; $result = $template->bufferedOutputObject(); $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" : '