public static function init($config = 'config/config.php') { //set up our autoloader spl_autoload_register(array('PhpReports', 'loader'), true, true); if (!file_exists($config)) { throw new Exception("Cannot find config file"); } // The config.php.sample is used to populate default values should the config.php be incomplete. // As a result, we require it be there. if (!file_exists('config/config.php.sample')) { throw new Exception("Cannot find sample config. Please leave config/config.php.sample in place for default values."); } $default_config = (include 'config/config.php.sample'); $config = (include $config); self::$config = array_merge($default_config, $config); self::$request = Flight::request(); $path = self::$request->base; if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { $protocol = 'https://'; } else { $protocol = 'http://'; } self::$request->base = $protocol . rtrim($_SERVER['HTTP_HOST'] . self::$request->base, '/'); //the load order for templates is: "templates/local", "templates/default", "templates" //this means loading the template "html/report.twig" will load the local first and then the default //if you want to extend a default template from within a local template, you can do {% extends "default/html/report.twig" %} and it will fall back to the last loader $template_dirs = array('templates/default', 'templates'); if (file_exists('templates/local')) { array_unshift($template_dirs, 'templates/local'); } $loader = new Twig_Loader_Chain(array(new Twig_Loader_Filesystem($template_dirs), new Twig_Loader_String())); self::$twig = new Twig_Environment($loader); self::$twig->addFunction(new Twig_SimpleFunction('dbdate', 'PhpReports::dbdate')); self::$twig->addFunction(new Twig_SimpleFunction('sqlin', 'PhpReports::generateSqlIN')); if (isset($_COOKIE['reports-theme']) && $_COOKIE['reports-theme']) { $theme = $_COOKIE['reports-theme']; } else { $theme = self::$config['bootstrap_theme']; } self::$twig->addGlobal('theme', $theme); self::$twig->addGlobal('path', $path); self::$twig->addFilter('var_dump', new Twig_Filter_Function('var_dump')); self::$twig_string = new Twig_Environment(new Twig_Loader_String(), array('autoescape' => false)); self::$twig_string->addFunction(new Twig_SimpleFunction('sqlin', 'PhpReports::generateSqlIN')); FileSystemCache::$cacheDir = self::$config['cacheDir']; if (!isset($_SESSION['environment']) || !isset(self::$config['environments'][$_SESSION['environment']])) { $_SESSION['environment'] = array_shift(array_keys(self::$config['environments'])); } }
<?php require_once 'vendor/autoload.php'; FileSystemCache::$cacheDir = __DIR__ . '/data/'; $console = new ConsoleKit\Console(); $console->addCommand('oat\\deploymentsTools\\AddCommand'); $console->addCommand('oat\\deploymentsTools\\CleanStackCommand'); $console->addCommand('oat\\deploymentsTools\\DebugCommand'); $console->addCommand('oat\\deploymentsTools\\ExecCommand'); $console->run();
<?php require_once __DIR__ . "/../lib/FileSystemCache.php"; FileSystemCache::$cacheDir = __DIR__ . "/cache"; class FileSystemCacheTest extends PHPUnit_Framework_TestCase { /** * @dataProvider keyDataProvider */ function testGenerateKey($key_data, $group) { $key = FileSystemCache::generateCacheKey($key_data, $group); $this->assertInstanceOf('FileSystemCacheKey', $key); } /** * @dataProvider dataProvider */ function testStoreDataTypes($data) { $key = FileSystemCache::generateCacheKey('mytestkey'); FileSystemCache::invalidate($key); $this->assertFalse(FileSystemCache::retrieve($key)); FileSystemCache::store($key, $data); $this->assertEquals($data, FileSystemCache::retrieve($key)); FileSystemCache::invalidate($key); $this->assertFalse(FileSystemCache::retrieve($key)); } /** * @dataProvider keyDataProvider */ function testStore($key_data, $group)