function getTempDir() { static $dir; if ($dir === NULL) { @mkdir($base = __DIR__ . DIRECTORY_SEPARATOR . 'temp'); // @ - may already exist $dir = $base . DIRECTORY_SEPARATOR . getmypid(); Tester\Helpers::purge($dir); register_shutdown_function(function () use($dir) { Tester\Helpers::purge($dir); rmdir($dir); }); } return $dir; }
<?php /** * This file is part of the Kdyby (http://www.kdyby.org) * * Copyright (c) 2008 Filip Procházka (filip@prochazka.su) * * For the full copyright and license information, please view the file license.md that was distributed with this source code. */ if (@(!(include __DIR__ . '/../../vendor/autoload.php'))) { echo 'Install Nette Tester using `composer update --dev`'; exit(1); } // configure environment Tester\Environment::setup(); class_alias('Tester\\Assert', 'Assert'); date_default_timezone_set('Europe/Prague'); // create temporary directory define('TEMP_DIR', __DIR__ . '/../tmp/' . (isset($_SERVER['argv']) ? md5(serialize($_SERVER['argv'])) : getmypid())); Tester\Helpers::purge(TEMP_DIR); $_SERVER = array_intersect_key($_SERVER, array_flip(['PHP_SELF', 'SCRIPT_NAME', 'SERVER_ADDR', 'SERVER_SOFTWARE', 'HTTP_HOST', 'DOCUMENT_ROOT', 'OS', 'argc', 'argv'])); $_SERVER['REQUEST_TIME'] = 1234567890; $_ENV = $_GET = $_POST = []; function id($val) { return $val; } function run(Tester\TestCase $testCase) { $testCase->run(isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : null); }
<?php if (!@(include __DIR__ . '/../vendor/autoload.php')) { echo 'Please install required components using "composer install".'; exit(1); } Tester\Environment::setup(); date_default_timezone_set('Europe/Prague'); define('TMPDIR', __DIR__ . '/tmp/' . lcg_value()); @mkdir(TMPDIR, 0777, TRUE); // @ - base directory may already exist register_shutdown_function(function () { Tester\Helpers::purge(TMPDIR); rmdir(TMPDIR); }); $_ENV = array_intersect_key($_ENV, ['TRAVIS' => TRUE]); $_SERVER['REQUEST_TIME'] = 1234567890; $_SERVER['REQUEST_ID'] = getmypid(); $_SERVER['REQUEST_METHOD'] = 'GET'; $_GET = $_POST = $_FILES = []; if (isset($_SERVER['argv'])) { $_SERVER['REQUEST_ID'] = md5(serialize($_SERVER['argv'])); } $_SERVER = array_intersect_key($_SERVER, array_flip(['HTTP_HOST', 'DOCUMENT_ROOT', 'OS', 'argc', 'argv', 'REQUEST_TIME', 'REQUEST_ID', 'SCRIPT_NAME', 'PHP_SELF', 'SERVER_ADDR', 'SERVER_SOFTWARE']));
<?php /** * @author Lukáš Drahník (http://drahnik-lukas.com/) * @package ldrahnik\ViewKeeper */ require __DIR__ . '/../../vendor/autoload.php'; if (!class_exists('Tester\\Assert')) { echo "Install Nette Tester using `composer update --dev`\n"; exit(1); } Tester\Environment::setup(); $temp = __DIR__ . '/temp/'; if (!file_exists($temp)) { mkdir($temp); } else { Tester\Helpers::purge($temp); } $configurator = new \Nette\Configurator(); $configurator->setDebugMode(FALSE); $configurator->setTempDirectory(__DIR__ . '/temp'); $configurator->createRobotLoader()->addDirectory(__DIR__ . '/../../src')->register(); $configurator->addConfig(__DIR__ . '/config/config.neon'); return $configurator->createContainer();
<?php if (@(!(include __DIR__ . '/../vendor/autoload.php'))) { echo 'Install Nette Tester using `composer update --dev`'; exit(1); } // configure environment Tester\Environment::setup(); date_default_timezone_set('Europe/Bratislava'); // create temporary directory define('TEMP_DIR', __DIR__ . '/tmp/' . (isset($_SERVER['argv']) ? md5(serialize($_SERVER['argv'])) : getmypid())); define('WWW_DIR', TEMP_DIR . '/www_dir'); define('FIXTURES_DIR', __DIR__ . '/fixtures'); Tester\Helpers::purge(TEMP_DIR); Tester\Helpers::purge(WWW_DIR); // robot loader $loader = new Nette\Loaders\RobotLoader(); mkdir(TEMP_DIR . '/cache'); $loader->setCacheStorage(new Nette\Caching\Storages\FileStorage(TEMP_DIR . '/cache'))->addDirectory(__DIR__ . '/../app')->addDirectory(__DIR__ . '/../vendor/others')->addDirectory(__DIR__ . '/fixtures')->register(); $_SERVER = array_intersect_key($_SERVER, array_flip(array('PHP_SELF', 'SCRIPT_NAME', 'SERVER_ADDR', 'SERVER_SOFTWARE', 'HTTP_HOST', 'DOCUMENT_ROOT', 'OS', 'argc', 'argv'))); $_SERVER['REQUEST_TIME'] = 1234567890; $_ENV = $_GET = $_POST = array(); function id($val) { return $val; } function run(Tester\TestCase $testCase) { $testCase->run(isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : NULL); }
<?php if (@(!(include __DIR__ . '/../../vendor/autoload.php'))) { echo "Install Nette Tester using `composer update`\n"; exit(1); } $setupMode = TRUE; echo "[setup] Purging temp.\n"; @mkdir(__DIR__ . '/../temp'); Tester\Helpers::purge(__DIR__ . '/../temp'); echo "[setup] All done.\n\n";