diff --git a/.travis.yml b/.travis.yml index 0dc702b..3ff0fca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,8 @@ php: - 5.3 services: - mysql +env: + - KOHANA_ENV=testing before_script: - composer install --no-interaction --prefer-source # Have to prefer source or hit github rate limit - git submodule update --init --recursive @@ -13,8 +15,8 @@ before_script: - cp application/config/modules.template application/config/modules.php # db setup - #- mysql -e 'create database pingapp_test;' - #- ./minion --task=migrations:run --up + - mysql -e 'create database pingapp_test;' + - ./minion --task=migrations:run --up # webserver setup - php -S localhost:8000 httpdocs/index.php & - sleep 3 diff --git a/application/bootstrap.php b/application/bootstrap.php index 01252aa..8b69da7 100644 --- a/application/bootstrap.php +++ b/application/bootstrap.php @@ -79,20 +79,29 @@ /** * Set Kohana::$environment if a 'KOHANA_ENV' environment variable has been supplied. * - * Note: If you supply an invalid environment name, a PHP warning will be thrown - * saying "Couldn't find constant Kohana::" + * Note: If you supply an invalid environment name 'development' will be used instead */ -if (isset($_SERVER['KOHANA_ENV'])) +if (($env = getenv('KOHANA_ENV')) === FALSE OR defined('Kohana::'.strtoupper($env)) === FALSE) { - Kohana::$environment = constant('Kohana::'.strtoupper($_SERVER['KOHANA_ENV'])); + $env = 'development'; } +// Ignoring code standards error about constant case +// @codingStandardsIgnoreStart +Kohana::$environment = constant('Kohana::'.strtoupper($env)); +// @codingStandardsIgnoreEnd + /** * Attach a file reader to config. Multiple readers are supported. */ Kohana::$config = new Config; Kohana::$config->attach(new Config_File); +/** + * Attach the environment specific configuration file reader to config + */ +Kohana::$config->attach(new Config_File('config/environments/'.$env)); + /** * Initialize Kohana, setting the default options. */ diff --git a/application/config/environments/testing/auth.php b/application/config/environments/testing/auth.php new file mode 100644 index 0000000..97d5529 --- /dev/null +++ b/application/config/environments/testing/auth.php @@ -0,0 +1,18 @@ + 'ORM', + 'hash_method' => 'sha256', + 'hash_key' => 'somereallylongkey', + 'lifetime' => 1209600, + 'session_type' => Session::$default, + 'session_key' => 'auth_user', + + // Username/password combinations for the Auth File driver + 'users' => array( + // 'admin' => 'b3154acf3a344170077d11bdb5fff31532f679a1919e716a02', + 'admin' => '' + ), + +); diff --git a/application/config/environments/testing/database.php b/application/config/environments/testing/database.php new file mode 100644 index 0000000..b3123c4 --- /dev/null +++ b/application/config/environments/testing/database.php @@ -0,0 +1,29 @@ + + * @package Ushahidi\Application + * @copyright Ushahidi - http://www.ushahidi.com + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License Version 3 (GPLv3) + */ + +return array +( + 'default' => array + ( + 'type' => 'MySQL', + 'connection' => array( + 'hostname' => 'localhost', + 'database' => 'pingapp_test', + 'username' => 'root', + 'password' => '', + 'persistent' => FALSE, + ), + 'table_prefix' => '', + 'charset' => 'utf8', + 'caching' => TRUE, + 'profiling' => TRUE, + ) +);