/** @return Tester\Runner\PhpInterpreter */
function createInterpreter()
{
    if (defined('HHVM_VERSION')) {
        return new Tester\Runner\HhvmPhpInterpreter(PHP_BINARY);
    } elseif (defined('PHPDBG_VERSION')) {
        return new Tester\Runner\ZendPhpDbgInterpreter(PHP_BINARY, ' -c ' . Tester\Helpers::escapeArg(php_ini_loaded_file()));
    } else {
        return new Tester\Runner\ZendPhpInterpreter(PHP_BINARY, ' -c ' . Tester\Helpers::escapeArg(php_ini_loaded_file()));
    }
}
Exemple #2
0
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

/**
 * Test: Nette\Database test boostap.
 *
 * @author     Jakub Vrana
 * @author     Jan Skrasek
 * @package    Nette\Database
 */
require __DIR__ . '/../bootstrap.php';
if (!is_file(__DIR__ . '/databases.ini')) {
    Tester\Helpers::skip();
}
$options = Tester\DataProvider::load('databases.ini', isset($query) ? $query : NULL);
$options = isset($_SERVER['argv'][1]) ? $options[$_SERVER['argv'][1]] : reset($options);
try {
    $connection = new Nette\Database\Connection($options['dsn'], $options['user'], $options['password']);
} catch (PDOException $e) {
    Tester\Helpers::skip("Connection to '{$options['dsn']}' failed. Reason: " . $e->getMessage());
}
Tester\Helpers::lock($options['dsn'], dirname(TEMP_DIR));
$driverName = $connection->getAttribute(PDO::ATTR_DRIVER_NAME);
Exemple #4
0
<?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);
}
Exemple #5
0
<?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']));
Exemple #6
0
    Tester\Environment::$useColors = (bool) $options['--colors'];
} elseif ($options['--tap']) {
    Tester\Environment::$useColors = FALSE;
}
if ($cmd->isEmpty() || $options['--help']) {
    $cmd->help();
    exit;
}
$phpArgs = '';
if ($options['-c']) {
    $phpArgs .= ' -c ' . Tester\Helpers::escapeArg($options['-c']);
} elseif (!$options['--info']) {
    echo "Note: No php.ini is used.\n";
}
foreach ($options['-d'] as $item) {
    $phpArgs .= ' -d ' . Tester\Helpers::escapeArg($item);
}
$php = new Tester\Runner\PhpExecutable($options['-p'], $phpArgs);
if ($options['--info']) {
    $job = new Tester\Runner\Job(__DIR__ . '/Runner/info.php', $php);
    $job->run();
    echo $job->getOutput();
    exit;
}
if ($options['--coverage']) {
    if (!$php->hasXdebug()) {
        throw new Exception("Code coverage functionality requires Xdebug extension (used {$php->getCommandLine()})");
    }
    file_put_contents($options['--coverage'], '');
    $coverageFile = realpath($options['--coverage']);
    putenv(Tester\Environment::COVERAGE . '=' . $coverageFile);
Exemple #7
0
/** @return Tester\Runner\PhpInterpreter */
function createInterpreter()
{
    return defined('HHVM_VERSION') ? new Tester\Runner\HhvmPhpInterpreter(PHP_BINARY) : new Tester\Runner\ZendPhpInterpreter(PHP_BINARY, ' -c ' . Tester\Helpers::escapeArg(php_ini_loaded_file()));
}
Exemple #8
0
<?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

/**
 * This file is part of the SitemapGenerator
 *
 * Copyright (c) 2013 Ing. Jan Svantner (http://www.janci.net)
 *
 * For the full copyright and license information, please view
 * the file license.txt that was distributed with this source code.
 */
require __DIR__ . '/../vendor/autoload.php';
if (!class_exists('Tester\\Assert')) {
    echo "Install Nette Tester using `composer update --dev`\n";
    exit(1);
}
Tester\Helpers::setup();
function id($val)
{
    return $val;
}
/*$configurator = new \Nette\Configurator();
$configurator->setDebugMode(FALSE);
$configurator->setTempDirectory(__DIR__ . '/../temp');
$configurator->createRobotLoader()
    ->addDirectory(__DIR__ . '/../app')
    ->register();

$configurator->addParameters(array('appDir'=> __DIR__ . '/../app' ));
$configurator->addConfig(__DIR__ . '/../app/config/config.neon');
$configurator->addConfig(__DIR__ . '/../app/config/config.local.neon', $configurator::NONE); // none section
return $configurator->createContainer();*/
Exemple #10
0
<?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);
}
Exemple #11
0
<?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";