Esempio n. 1
0
 public function testGetTitle()
 {
     $app = App::getInstance();
     $layout = new Layout($app->getPath('views') . '/layouts/main.phtml');
     $title = $layout->getTitle('this is my title');
     $this->isEqual($title, 'this is my title');
     $layout->setTitlePattern('Unit Tests : ${title}');
     $title = $layout->getTitle('Layout');
     $this->isEqual($title, 'Unit Tests : Layout');
 }
Esempio n. 2
0
 public function testGetRoutesFromArray()
 {
     $app = App::getInstance();
     $request = $app->getRequest();
     $router = new Router($request);
     $routes = array('/' => array('main', 'index'), '/new-route' => array('main', 'new'));
     $router->setRoutes($routes);
     $router_routes = $router->getRoutes();
     $this->isEqual($routes, $router_routes);
 }
Esempio n. 3
0
 public function testGetViewPath()
 {
     $controller = new Controllers\Main();
     $controller->name('Main');
     $this->isFalse(file_exists($controller->getViewPath()));
     $controller->setView('test');
     $path = $controller->getViewPath();
     $this->isTrue(file_exists($path));
     $app = App::getInstance();
     $view_path = $app->getPath('views');
     $this->isEqual($view_path . '/Main/test.phtml', $path);
 }
Esempio n. 4
0
 /**
  * constructor
  *
  * @todo include this somewhere else?
  * @return void
  */
 public function __construct()
 {
     App::getInstance()->includeFile('Sonic/Extension/Transformation.php');
 }
Esempio n. 5
0
 public function error()
 {
     $this->view->exception = $e = $this->request()->getParam('exception');
     $this->view->show_exception = $this->request()->getParam('top_level_exception');
     $this->view->show_debug = \Sonic\App::getInstance()->isDev();
 }
Esempio n. 6
0
 public function testProcessViewQueue()
 {
     $app = App::getInstance();
     $app->queueView('main', 'index');
     ob_start();
     $app->getRequest()->reset();
     $app->addSetting(App::TURBO, true);
     $app->processViewQueue();
     $app->addSetting(App::TURBO, false);
     $app->processViewQueue();
     ob_end_clean();
 }
Esempio n. 7
0
 /**
  * backs up all .svn directories within this directory
  *
  * @param string $path
  * @return void
  */
 protected function _backupSvn($path)
 {
     $extension_dir = App::getInstance()->getPath('extensions');
     $files = new \RecursiveDirectoryIterator($path);
     $files = new \IteratorIterator($files);
     foreach ($files as $file) {
         if ($file->isDir() && $file->getFilename() == '.svn') {
             $new_name = '/tmp_svn_' . uniqid();
             $new_path = $extension_dir . $new_name;
             $this->_output('backing up .svn directory at ' . $file->getRealPath() . ' to ' . $new_name, true);
             $path = $file->getRealPath();
             rename($path, $new_path);
             $this->_svn[$new_path] = $path;
         }
     }
 }
Esempio n. 8
0
 public function turbo()
 {
     while (ob_get_level()) {
         ob_end_flush();
     }
     flush();
     return App::getInstance()->processViewQueue();
 }
Esempio n. 9
0
<?php

use Sonic\App;
$lib_path = str_replace('tests/_bootstrap.php', 'lib', realpath(__FILE__));
set_include_path($lib_path);
ini_set('memory_limit', '1024M');
include 'Sonic/App.php';
$app = App::getInstance();
$app->addSetting(App::AUTOLOAD, true);
$app->start(App::COMMAND_LINE);
Esempio n. 10
0
 /**
  * raises an extension exception
  *
  * @return void
  */
 protected function _raiseException($message)
 {
     App::getInstance()->includeFile('Sonic/Extension/Exception.php');
     throw new Exception($message);
 }
Esempio n. 11
0
 public function testGetArrayFail()
 {
     $app = App::getInstance();
     $path = $app->getPath('configs') . '/smart.ini';
     $config = new Config($path, 'production');
     $value = $config->get('urls', 'blah');
     $this->isNull($value);
 }