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'); }
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); }
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); }
/** * constructor * * @todo include this somewhere else? * @return void */ public function __construct() { App::getInstance()->includeFile('Sonic/Extension/Transformation.php'); }
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(); }
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(); }
/** * 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; } } }
public function turbo() { while (ob_get_level()) { ob_end_flush(); } flush(); return App::getInstance()->processViewQueue(); }
<?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);
/** * raises an extension exception * * @return void */ protected function _raiseException($message) { App::getInstance()->includeFile('Sonic/Extension/Exception.php'); throw new Exception($message); }
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); }