function loadTranslation($lang) { // read global var $app global $app; // load good json file return loadJson($app['param']['db_path_trans'] . $lang . ".json"); }
public function setUp() { // init global app var global $app; $app['param'] = getConfig("test"); $app['users'] = loadJson($app['param']['db_path_users']); $app['pages'] = loadJson($app['param']['db_path_pages']); $app['tasks'] = loadJson($app['param']['db_path_tasks']); }
public function setUp() { // init global app var global $app; $app['param'] = getConfig("test"); $app['users'] = loadJson($app['param']['db_path_users']); $app['pages'] = loadJson($app['param']['db_path_pages']); $app['tasks'] = loadJson($app['param']['db_path_tasks']); // preserve task database $this->trashFile = 'tests/datas/trash/' . microtime() . '.file'; $app['param']['db_path_tasks'] = $this->trashFile; }
public function setUp() { // init global app var global $app; $app['param'] = getConfig("test"); $app['users'] = loadJson($app['param']['db_path_users']); $app['pages'] = loadJson($app['param']['db_path_pages']); $app['tasks'] = loadJson($app['param']['db_path_tasks']); // mock a SESSION global $_SESSION; $_SESSION['auth'] = false; $_SESSION['username'] = "******"; }
function getConfig($env = 'default') { return loadJson("datas/config/parameters_" . $env . ".json"); }
public function testSaveTasks() { // save in Trash (will not break our future test !) global $app; $app['param']['db_path_tasks'] = $this->trashFile; // try to save $caught = false; try { saveTasks(); } catch (\Exception $e) { $caught = true; } $this->assertFalse($caught); // try to load this file (see if json is correct) $caught = false; try { $fileDatas = loadJson($this->trashFile); } catch (\Exception $e) { $caught = true; } $this->assertFalse($caught); // test datas in file are good one $this->assertEquals($fileDatas, $app['tasks']); }
<?php // init session if (!isset($_SESSION)) { session_start(); } // init functions include_once 'includes/autoload.php'; // init vars $app['param'] = getConfig("prod"); $app['users'] = loadJson($app['param']['db_path_users']); $app['pages'] = loadJson($app['param']['db_path_pages']); $app['tasks'] = loadJson($app['param']['db_path_tasks']); $app['trans'] = loadTranslation(getLang()); // get page $page = getActualRoute(); // secure all pages if ($page != 'login' && !isConnected()) { redirect('login'); } // load header include_once 'views/header.php'; // load content of page try { loadPhpFileByPageName($page); } catch (\Exception $e) { loadPhpFileByPageName("erreur"); } // load footer include_once 'views/footer.php';
foreach ($commandAlts as $alt) { if (commandExists($alt)) { $cmd = $alt; } } if ($cmd === null) { throw new Exception("Unable to determine composer command, tried [" . join(", ", $commandAlts) . "]", 3); } array_shift($argv); // Remove haydn.php command putenv("COMPOSER={$newConf}"); passthru("{$cmd} " . join(" ", $argv), $retVal); return $retVal; } function commandExists($cmd) { exec("which {$cmd}", $output, $retVal); return $retVal === 0; } //////////////////////////////////////////////////////////////////////////////// try { $conf = loadJson(SRC_CONF); $modifier = loadJson(MOD_CONF); override($conf, $modifier); $tempPath = writeTemp($conf); $retVal = launchComposer($tempPath, $argv); exit($retVal); } catch (Exception $e) { fwrite(STDERR, $e->getMessage() . "\n"); exit(100 + $e->getCode()); }