define('WWW_ROOT', ROOT . DS . 'webroot' . DS); define('CONFIG', dirname(__FILE__) . DS . 'config' . DS); ini_set('intl.default_locale', 'de-DE'); require ROOT . '/vendor/autoload.php'; require CORE_PATH . 'config/bootstrap.php'; Cake\Core\Configure::write('App', ['namespace' => 'App', 'encoding' => 'UTF-8']); Cake\Core\Configure::write('debug', true); Cake\Core\Configure::write('EmailTransport', ['default' => ['className' => 'Debug']]); Cake\Core\Configure::write('Email', ['default' => ['transport' => 'default', 'from' => 'you@localhost']]); mb_internal_encoding('UTF-8'); $Tmp = new \Cake\Filesystem\Folder(TMP); $Tmp->create(TMP . 'cache/models', 0770); $Tmp->create(TMP . 'cache/persistent', 0770); $Tmp->create(TMP . 'cache/views', 0770); $cache = ['default' => ['engine' => 'File', 'path' => CACHE], '_cake_core_' => ['className' => 'File', 'prefix' => 'crud_myapp_cake_core_', 'path' => CACHE . 'persistent/', 'serialize' => true, 'duration' => '+10 seconds'], '_cake_model_' => ['className' => 'File', 'prefix' => 'crud_my_app_cake_model_', 'path' => CACHE . 'models/', 'serialize' => 'File', 'duration' => '+10 seconds']]; Cake\Cache\Cache::config($cache); Cake\Core\Plugin::load('Queue', ['path' => ROOT . DS]); Cake\Core\Plugin::load('Tools', ['path' => ROOT . DS . 'plugins' . DS . 'Tools' . DS]); Cake\Network\Email\Email::configTransport('default', ['className' => 'Debug']); Cake\Network\Email\Email::configTransport('queue', ['className' => 'Queue.Queue']); Cake\Network\Email\Email::config('default', ['transport' => 'default']); // Ensure default test connection is defined if (!getenv('db_class')) { putenv('db_class=Cake\\Database\\Driver\\Sqlite'); putenv('db_dsn=sqlite::memory:'); } if (WINDOWS) { Cake\Datasource\ConnectionManager::config('test', ['className' => 'Cake\\Database\\Connection', 'driver' => 'Cake\\Database\\Driver\\Mysql', 'database' => 'cake_test', 'username' => 'root', 'password' => '', 'timezone' => 'UTC', 'quoteIdentifiers' => true, 'cacheMetadata' => true]); return; } Cake\Datasource\ConnectionManager::config('test', ['className' => 'Cake\\Database\\Connection', 'driver' => getenv('db_class'), 'dsn' => getenv('db_dsn'), 'database' => getenv('db_database'), 'username' => getenv('db_username'), 'password' => getenv('db_password'), 'timezone' => 'UTC', 'quoteIdentifiers' => true, 'cacheMetadata' => true]);
do { $lastRoot = $root; $root = dirname($root); if (is_dir($root . '/vendor/cakephp/cakephp')) { return $root; } } while ($root !== $lastRoot); throw new Exception("Cannot find the root of the application, unable to run tests"); }; $root = $findRoot(__FILE__); unset($findRoot); chdir($root); require_once 'vendor/cakephp/cakephp/src/basics.php'; require_once 'vendor/autoload.php'; define('ROOT', $root . DS . 'tests' . DS . 'test_app' . DS); define('APP', ROOT . 'App' . DS); define('TMP', sys_get_temp_dir() . DS); // Path to config files for tests define('PATH_TO_CONFIG_FILES', dirname(__DIR__) . DS . 'tests' . DS . 'config' . DS); // require $root . '/config/bootstrap.php'; Configure::write('debug', true); Configure::write('App', ['namespace' => 'App', 'paths' => ['plugins' => [ROOT . 'Plugin' . DS], 'templates' => [ROOT . 'App' . DS . 'Template' . DS]]]); Cake\Cache\Cache::config(['_cake_core_' => ['engine' => 'File', 'prefix' => 'cake_core_', 'serialize' => true, 'path' => '/tmp'], '_cake_model_' => ['engine' => 'File', 'prefix' => 'cake_model_', 'serialize' => true, 'path' => '/tmp']]); if (!getenv('db_dsn')) { putenv('db_dsn=sqlite:///:memory:'); } if (!getenv('DB')) { putenv('DB=sqlite'); } ConnectionManager::config('test', ['url' => getenv('db_dsn')]); Plugin::load('Recaptcha', ['path' => dirname(dirname(__FILE__)) . DS]);