private function render($page) { $template_path = $GLOBALS['template_dir'] . $page; $template = file_get_contents($template_path); $this->context['ERRORS'] = UserError::format(); foreach ($this->context as $var => $value) { $template = str_replace("{{ {$var} }}", $value, $template); } $output = preg_replace('/\\{\\{.+?\\}\\}/', '', $template); echo $output; }
/** * @covers UserError::__toString */ public function test__toString() { $msg = "This field is requires"; $this->object->setMessage($msg); $this->assertEquals($msg, $this->object->__toString()); }
public function addErrorMessage($msg) { $error = new UserError(); $error->setMessage($msg); $this->errors[] = $error; }