Example #1
0
 public function testSetVars(IntegrationTester $I)
 {
     $I->wantToTest('Set and get View vars');
     $view = new Simple();
     $view->setViewsDir(PATH_DATA . 'views/');
     $I->assertNull($view->getVar('some_var'));
     $some_var = time();
     $view->setParamToView('some_var', $some_var);
     $I->assertNull($view->getVar('another_var'));
     $another_var = uniqid();
     $view->setVar('another_var', $another_var);
     $I->assertEquals($some_var, $view->getVar('some_var'));
     $I->assertEquals($another_var, $view->getVar('another_var'));
 }
Example #2
0
 public function testRenderWithRegisteredEngine()
 {
     $view = new View();
     $view->setDI(new Di());
     $view->setViewsDir('unit-tests/views/');
     $view->setParamToView('name', 'FooBar');
     $view->registerEngines(array('.mhtml' => 'Phalcon\\Mvc\\View\\Engine\\Volt'));
     $this->assertEquals('Hello FooBar', $view->render('test4/index'));
 }
Example #3
0
 /**
  * Tests render with variables
  *
  * @author Kamil Skowron <*****@*****.**>
  * @since  2014-05-28
  */
 public function testRenderWithVariables()
 {
     $this->specify('Render with variables does not work as expected', function () {
         $view = new Simple();
         $view->setViewsDir(PATH_DATA . 'views' . DIRECTORY_SEPARATOR);
         expect($view->render('test3/other'))->equals('here');
         $view->setParamToView('a_cool_var', 'le-this');
         expect($view->render('test3/another'))->equals('<p>le-this</p>');
     });
 }
Example #4
0
 public function testRenderWithFilenameWithEngineWithoutEngineRegistered()
 {
     $this->setExpectedException('Phalcon\\Mvc\\View\\Exception');
     $view = new View();
     $view->setDI(new Di());
     $view->setViewsDir('unit-tests/views/');
     $view->setParamToView('name', 'FooBar');
     $this->assertEquals('Hello FooBar', $view->render('test4/index.mhtml'));
 }