Пример #1
0
 public function testRender()
 {
     $mockBody = $this->getMockBuilder('Psr\\Http\\Message\\StreamInterface')->disableOriginalConstructor()->getMock();
     $mockResponse = $this->getMockBuilder('Psr\\Http\\Message\\ResponseInterface')->disableOriginalConstructor()->getMock();
     $mockBody->expects($this->once())->method('write')->with("<p>Hello, my name is Matheus.</p>\n")->willReturn(34);
     $mockResponse->expects($this->once())->method('getBody')->willReturn($mockBody);
     $response = $this->view->render($mockResponse, 'hello.tpl', ['name' => 'Matheus']);
     $this->assertInstanceOf('Psr\\Http\\Message\\ResponseInterface', $response);
 }
Пример #2
0
 public function registerExtension($file)
 {
     if (is_file($file) && $this->isPHPFile($file)) {
         $params = $this->getExtensionParams($file);
         if ($params) {
             require_once $file;
             if (function_exists($params['callback'])) {
                 $this->smartyInstance->registerPlugin($params['type'], $params['name'], $params['callback']);
             }
         }
     }
 }
Пример #3
0
 /**
  * Fetch rendered template
  *
  * @param  string $template Template pathname relative to templates directory
  * @param  array $data Associative array of template variables
  *
  * @return string
  */
 public function fetch($template, $data = [])
 {
     $data = array_merge($this->defaultVariables, $data);
     $this->smarty->assign($data);
     return $this->smarty->fetch($template);
 }
Пример #4
0
 public function testPluginDirs()
 {
     $this->assertGreaterThanOrEqual(2, count($this->view->getSmarty()->getPluginsDir()));
 }