From 1ca47d67d569a222e4ba8ad47f0a7b16d9bb86cb Mon Sep 17 00:00:00 2001 From: Lucas Bickel Date: Tue, 28 Feb 2017 12:16:03 +0100 Subject: [PATCH] Use local configuration in tests This way the tests should really run out of the box with what is described in TESTING.md. --- .travis.yml | 4 +-- airtime_mvc/application/configs/conf.php | 8 ++--- airtime_mvc/tests/{ => conf}/airtime.conf | 3 +- airtime_mvc/tests/conf/testing/airtime.conf | 35 +++++++++++++++++++ .../{ => conf/testing}/cloud_storage.conf | 0 airtime_mvc/tests/phpunit.xml | 1 + 6 files changed, 41 insertions(+), 10 deletions(-) rename airtime_mvc/tests/{ => conf}/airtime.conf (97%) create mode 100644 airtime_mvc/tests/conf/testing/airtime.conf rename airtime_mvc/tests/{ => conf/testing}/cloud_storage.conf (100%) diff --git a/.travis.yml b/.travis.yml index 0b62f90a2..f8eb9d97f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ services: env: global: - ENVIRONMENT=testing - - LIBRETIME_CONF_DIR=/tmp/libretime - LIBRETIME_LOG_DIR=/tmp/log/libretime install: - composer install @@ -17,7 +16,6 @@ before_script: - psql -c "CREATE USER libretime WITH PASSWORD 'libretime';" -U postgres - psql -c 'GRANT CONNECT ON DATABASE libretime TO libretime;' -U postgres - psql -c 'ALTER USER libretime CREATEDB;' -U postgres -- mkdir -p /tmp/libretime/testing/ /tmp/log/libretime -- cp airtime_mvc/tests/airtime.conf airtime_mvc/tests/cloud_storage.conf /tmp/libretime/testing/ +- mkdir -p /tmp/log/libretime script: - cd airtime_mvc/tests && ../../vendor/bin/phpunit diff --git a/airtime_mvc/application/configs/conf.php b/airtime_mvc/application/configs/conf.php index 29727ed8c..602c0c618 100644 --- a/airtime_mvc/application/configs/conf.php +++ b/airtime_mvc/application/configs/conf.php @@ -17,12 +17,8 @@ class Config { "rootDir" => self::$rootDir ); - //In the unit testing environment, we always want to use our local airtime.conf in airtime_mvc/application/test: - if (getenv('AIRTIME_UNIT_TEST') == '1') { - $filename = "airtime.conf"; - } else { - $filename = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : LIBRETIME_CONF_DIR . "/airtime.conf"; - } + //In the unit testing environment, LIBRETIME_CONF_DIR will our local airtime.conf in airtime_mvc/application/test/conf: + $filename = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : LIBRETIME_CONF_DIR . "/airtime.conf"; $values = parse_ini_file($filename, true); diff --git a/airtime_mvc/tests/airtime.conf b/airtime_mvc/tests/conf/airtime.conf similarity index 97% rename from airtime_mvc/tests/airtime.conf rename to airtime_mvc/tests/conf/airtime.conf index 1ae9d504f..a25ca4d35 100644 --- a/airtime_mvc/tests/airtime.conf +++ b/airtime_mvc/tests/conf/airtime.conf @@ -1,5 +1,6 @@ [database] -host = localhost + +host = postgresql dbname = libretime_test dbuser = libretime dbpass = libretime diff --git a/airtime_mvc/tests/conf/testing/airtime.conf b/airtime_mvc/tests/conf/testing/airtime.conf new file mode 100644 index 000000000..a25ca4d35 --- /dev/null +++ b/airtime_mvc/tests/conf/testing/airtime.conf @@ -0,0 +1,35 @@ +[database] + +host = postgresql +dbname = libretime_test +dbuser = libretime +dbpass = libretime + +[rabbitmq] +host = 127.0.0.1 +port = 5672 +user = airtime_tests +password = airtime_tests +vhost = /airtime_tests + +[general] +dev_env = testing +api_key = H2NRICX6CM8F50CU123C +web_server_user = www-data +airtime_dir = /usr/share/airtime +base_url = localhost +base_port = 80 +base_dir = / +cache_ahead_hours = 1 +station_id = teststation + +[monit] +monit_user = guest +monit_password = airtime + +[soundcloud] +connection_retries = 3 +time_between_retries = 60 +soundcloud_client_id = 0 +soundcloud_client_secret = 0 +soundcloud_redirect_uri = http://soundcloud.example.org/redirect diff --git a/airtime_mvc/tests/cloud_storage.conf b/airtime_mvc/tests/conf/testing/cloud_storage.conf similarity index 100% rename from airtime_mvc/tests/cloud_storage.conf rename to airtime_mvc/tests/conf/testing/cloud_storage.conf diff --git a/airtime_mvc/tests/phpunit.xml b/airtime_mvc/tests/phpunit.xml index 4409d3c77..91d14edcc 100644 --- a/airtime_mvc/tests/phpunit.xml +++ b/airtime_mvc/tests/phpunit.xml @@ -17,6 +17,7 @@ +