silverstripe-framework/tests/behat/serve-bootstrap.php
Sam Minnee 07396e4437 NEW: Move Travis behat test to run locally.
This shifts the behat test run to be triggered form composer activity
within the framework module directly,

 * silverstripe/serve is used to provide a webserver, based on the
   php -S command
 * se/selenium-server-standalone is used to install selenium rather than
   a download command

Because we’re using serve, the behat configuration can be locked down.

Further refinements could be made on this:

 * the behat-extension could be responsible for installing and
   starting/stopping selenium, making these tests more portable
 * xvfb initialisation could be provided with another bin tool in the
   begat-extension: vendor/bin/xvfb 1024x768
 * The bootstrap-file argument to serve could be provided as part of a
   composer.json setting. This would make it easier for developers to
   start a dev server simply by running vendor/bin/serve
 * the behat-extension could be responsible for installing and
   starting/stopping silverstripe/serve, removing the need for
   specifying base_url at all, and possibly utilising the same bootstrap
   file between serve and behat.
2016-09-17 15:40:37 +12:00

48 lines
1.4 KiB
PHP

<?php
// Asset folder
if(!file_exists(BASE_PATH . '/assets')) {
mkdir(BASE_PATH . '/assets', 02775);
}
// DATABASE BOOTSTRAP
if (!defined('SS_ENVIRONMENT_TYPE')) {
define('SS_ENVIRONMENT_TYPE', 'dev');
}
if (!defined('SS_DATABASE_CLASS') && !defined('SS_DATABASE_USERNAME')) {
// The default settings let us define the database config via environment vars
// Database connection, including PDO and legacy ORM support
switch(getenv('DB')) {
case "PGSQL";
define('SS_DATABASE_CLASS', getenv('PDO') ? 'PostgrePDODatabase' : 'PostgreSQLDatabase');
define('SS_DATABASE_USERNAME', 'postgres');
define('SS_DATABASE_PASSWORD', '');
break;
case "SQLITE":
define('SS_DATABASE_CLASS', getenv('PDO') ? 'SQLite3PDODatabase' : 'SQLite3Database');
define('SS_DATABASE_USERNAME', 'root');
define('SS_DATABASE_PASSWORD', '');
define('SS_SQLITE_DATABASE_PATH', ':memory:');
break;
default:
define('SS_DATABASE_CLASS', getenv('PDO') ? 'MySQLPDODatabase' : 'MySQLDatabase');
define('SS_DATABASE_USERNAME', 'root');
define('SS_DATABASE_PASSWORD', '');
}
define('SS_DATABASE_SERVER', '127.0.0.1');
define('SS_DATABASE_CHOOSE_NAME', true);
}
// Default database settings
global $database;
$database = '';
require_once(__DIR__ . '/../../conf/ConfigureFromEnv.php');
class Page extends SilverStripe\View\ViewableData {}
class Page_Controller extends SilverStripe\Control\Controller {}