2016-01-05 11:01:02 +01:00
|
|
|
<?php
|
|
|
|
|
// This is global bootstrap for autoloading
|
2016-01-05 11:52:07 +01:00
|
|
|
|
|
|
|
|
namespace Grav;
|
|
|
|
|
|
2016-01-06 17:30:13 +01:00
|
|
|
use Codeception\Util\Fixtures;
|
2016-01-06 17:30:53 +01:00
|
|
|
use Faker\Factory;
|
2016-02-04 14:12:27 +01:00
|
|
|
use Grav\Common\Grav;
|
2016-02-04 14:15:30 +01:00
|
|
|
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
|
2016-01-05 11:52:07 +01:00
|
|
|
|
2016-01-29 18:28:38 +01:00
|
|
|
ini_set('error_log', __DIR__ . '/error.log');
|
|
|
|
|
|
2016-02-04 14:12:27 +01:00
|
|
|
$grav = function() {
|
|
|
|
|
// Ensure vendor libraries exist
|
|
|
|
|
$autoload = __DIR__ . '/../vendor/autoload.php';
|
2016-01-05 11:52:07 +01:00
|
|
|
|
2016-02-04 14:12:27 +01:00
|
|
|
if (!is_file($autoload)) {
|
|
|
|
|
throw new \RuntimeException("Please run: <i>bin/grav install</i>");
|
|
|
|
|
}
|
2016-01-05 11:52:07 +01:00
|
|
|
|
2016-02-04 14:12:27 +01:00
|
|
|
// Register the auto-loader.
|
|
|
|
|
$loader = require_once $autoload;
|
2016-01-05 11:52:07 +01:00
|
|
|
|
2016-02-04 14:12:27 +01:00
|
|
|
if (version_compare($ver = PHP_VERSION, $req = GRAV_PHP_MIN, '<')) {
|
|
|
|
|
throw new \RuntimeException(sprintf('You are running PHP %s, but Grav needs at least <strong>PHP %s</strong> to run.', $ver, $req));
|
|
|
|
|
}
|
2016-01-05 11:52:07 +01:00
|
|
|
|
2016-02-04 14:12:27 +01:00
|
|
|
// Set timezone to default, falls back to system if php.ini not set
|
|
|
|
|
date_default_timezone_set(@date_default_timezone_get());
|
2016-01-05 11:52:07 +01:00
|
|
|
|
2016-02-04 14:12:27 +01:00
|
|
|
// Set internal encoding if mbstring loaded
|
|
|
|
|
if (!extension_loaded('mbstring')) {
|
|
|
|
|
throw new \RuntimeException("'mbstring' extension is not loaded. This is required for Grav to run correctly");
|
|
|
|
|
}
|
|
|
|
|
mb_internal_encoding('UTF-8');
|
2016-01-05 11:52:07 +01:00
|
|
|
|
2016-02-04 14:12:27 +01:00
|
|
|
Grav::resetInstance();
|
2016-01-05 11:52:07 +01:00
|
|
|
|
2016-02-04 14:12:27 +01:00
|
|
|
// Get the Grav instance
|
2016-02-04 14:15:30 +01:00
|
|
|
$grav = Grav::instance(['loader' => $loader]);
|
2016-01-31 19:05:37 -07:00
|
|
|
|
2016-02-04 14:12:27 +01:00
|
|
|
$grav['uri']->init();
|
|
|
|
|
$grav['debugger']->init();
|
|
|
|
|
$grav['assets']->init();
|
|
|
|
|
$grav['config']->set('system.cache.enabled', false);
|
2016-02-02 15:31:29 +01:00
|
|
|
|
2016-02-04 14:12:27 +01:00
|
|
|
/** @var UniformResourceLocator $locator */
|
|
|
|
|
$locator = $grav['locator'];
|
|
|
|
|
$locator->addPath('tests', '', 'tests', false);
|
2016-01-31 19:05:37 -07:00
|
|
|
|
2016-02-04 14:12:27 +01:00
|
|
|
// Set default $_SERVER value used for nonces
|
|
|
|
|
empty( $_SERVER['HTTP_CLIENT_IP'] ) && $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.1';
|
|
|
|
|
|
|
|
|
|
return $grav;
|
|
|
|
|
};
|
2016-02-02 15:31:29 +01:00
|
|
|
|
2016-01-06 17:30:53 +01:00
|
|
|
|
|
|
|
|
Fixtures::add('grav', $grav);
|
2016-02-04 14:12:27 +01:00
|
|
|
|
|
|
|
|
$fake = Factory::create();
|
|
|
|
|
Fixtures::add('fake', $fake);
|
|
|
|
|
|