Ejemplo n.º 1
0
 public function testTwigMixedEnginePartials()
 {
     if ($this->_loadTwig() == false) {
         return;
     }
     $di = new Phalcon\DI();
     $view = new Phalcon\Mvc\View();
     $view->setDI($di);
     $view->setViewsDir('unit-tests/views/');
     $view->registerEngines(array('.twig' => 'My_Twig_Engine', '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php'));
     $view->setParamToView('name', 'Sonny');
     $view->start();
     $view->setRenderLevel(Phalcon\Mvc\View::LEVEL_LAYOUT);
     $view->render('test12', 'info');
     $view->finish();
     $this->assertEquals($view->getContent(), 'Well, this is the view content: Hello Sonny.');
 }
Ejemplo n.º 2
0
 public function testVoltEngineBuiltInFunctions()
 {
     @unlink('unit-tests/views/test11/index.volt.php');
     $di = new Phalcon\DI();
     $view = new Phalcon\Mvc\View();
     $view->setDI($di);
     $view->setViewsDir('unit-tests/views/');
     $view->registerEngines(array('.volt' => 'Phalcon\\Mvc\\View\\Engine\\Volt'));
     $view->setVar('arr', array(1, 2, 3, 4));
     $view->setVar('obj', new SomeObject(array(1, 2, 3, 4)));
     $view->setVar('str', 'hello');
     $view->setVar('no_str', 1234);
     $view->start();
     $view->render('test11', 'index');
     $view->finish();
     $this->assertEquals($view->getContent(), 'Length Array: 4Length Object: 4Length String: 5Length No String: 4Slice Array: 1,2,3,4Slice Array: 2,3Slice Array: 1,2,3Slice Object: 2,3,4Slice Object: 2,3Slice Object: 1,2Slice String: helSlice String: elSlice String: lloSlice No String: 123Slice No String: 23Slice No String: 34');
 }
Ejemplo n.º 3
0
<?php

//Setting views directory
$view = new Phalcon\Mvc\View();
$view->setViewsDir('app/views/');
$view->start();
//Shows recent posts view (app/views/posts/recent.phtml)
$view->render('posts', 'recent');
$view->finish();
//Printing views output
echo $view->getContent();
Ejemplo n.º 4
-1
 public function testViewOptions()
 {
     $config = array('cache' => array('service' => 'otherCache'));
     $di = new Phalcon\DI();
     $di->set('otherCache', function () {
         $frontend = new Phalcon\Cache\Frontend\Output(array('lifetime' => 60));
         return new Phalcon\Cache\Backend\File($frontend, array('cacheDir' => 'unit-tests/cache/'));
     });
     $view = new Phalcon\Mvc\View($config);
     $view->setDI($di);
     $view->setViewsDir('unit-tests/views/');
     $date = date("r");
     $content = '<html>' . $date . '</html>' . PHP_EOL;
     $view->setVar("date", $date);
     $view->start();
     $view->cache(true);
     $view->render('test8', 'other');
     $view->finish();
     $this->assertEquals($view->getContent(), $content);
     $view->reset();
     sleep(1);
     $view->setVar("date", date("r"));
     $view->start();
     $view->cache(true);
     $view->render('test8', 'other');
     $view->finish();
     $this->assertEquals($view->getContent(), $content);
 }