From fea3f4073a2210876629f01ee0e5b466fe2da6e2 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Thu, 19 Dec 2013 16:58:11 -0500 Subject: [PATCH] CC-5651: Unit Test the Scheduler * Added runtests.sh script for unit tests * Use the airtime_test database config in Config.php, propel * First unit test passes! :-) --- airtime_mvc/application/configs/conf.php | 9 +++++++-- airtime_mvc/build/build.properties | 2 +- airtime_mvc/build/runtime-conf.xml | 6 ++++++ airtime_mvc/tests/application/models/ShowTest.php | 8 ++------ airtime_mvc/tests/runtests.sh | 5 +++++ 5 files changed, 21 insertions(+), 9 deletions(-) create mode 100755 airtime_mvc/tests/runtests.sh diff --git a/airtime_mvc/application/configs/conf.php b/airtime_mvc/application/configs/conf.php index 13b4a06bd..903b845c2 100644 --- a/airtime_mvc/application/configs/conf.php +++ b/airtime_mvc/application/configs/conf.php @@ -18,8 +18,13 @@ class Config { "rootDir" => __DIR__."/../.." ); - $filename = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf"; - + //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'] : "/etc/airtime/airtime.conf"; + } + $values = parse_ini_file($filename, true); // Name of the web server user diff --git a/airtime_mvc/build/build.properties b/airtime_mvc/build/build.properties index 1a83f8732..de8c64cb5 100644 --- a/airtime_mvc/build/build.properties +++ b/airtime_mvc/build/build.properties @@ -1,6 +1,6 @@ #Note: project.home is automatically generated by the propel-install script. #Any manual changes to this value will be overwritten. -project.home = /home/denise/airtime/airtime_mvc +project.home = /home/asantoni/airtime/airtime_mvc project.build = ${project.home}/build #Database driver diff --git a/airtime_mvc/build/runtime-conf.xml b/airtime_mvc/build/runtime-conf.xml index fff70863a..21f5bcfe2 100644 --- a/airtime_mvc/build/runtime-conf.xml +++ b/airtime_mvc/build/runtime-conf.xml @@ -8,6 +8,12 @@ pgsql:host=localhost;port=5432;dbname=airtime;user=airtime;password=airtime + + pgsql + + pgsql:host=localhost;port=5432;dbname=airtime_test;user=airtime;password=airtime + + diff --git a/airtime_mvc/tests/application/models/ShowTest.php b/airtime_mvc/tests/application/models/ShowTest.php index 5cbc7594d..8b93e6dad 100644 --- a/airtime_mvc/tests/application/models/ShowTest.php +++ b/airtime_mvc/tests/application/models/ShowTest.php @@ -17,18 +17,14 @@ class ShowTest extends Zend_Test_PHPUnit_DatabaseTestCase //Load Database parameters //We need to load the config before our app bootstrap runs. The config - //is normally - $_SERVER['AIRTIME_CONF'] = 'airtime.conf'; + //is normally $CC_CONFIG = Config::getConfig(); $dbuser = $CC_CONFIG['dsn']['username']; $dbpasswd = $CC_CONFIG['dsn']['password']; $dbname = $CC_CONFIG['dsn']['database']; $dbhost = $CC_CONFIG['dsn']['hostspec']; - echo($dbuser); - echo($dbpasswd); - echo($dbname); - echo($dbhost); + AirtimeInstall::createDatabase(); AirtimeInstall::createDatabaseTables($dbuser, $dbpasswd, $dbname, $dbhost); AirtimeInstall::SetDefaultTimezone(); diff --git a/airtime_mvc/tests/runtests.sh b/airtime_mvc/tests/runtests.sh new file mode 100755 index 000000000..86d1ddf5b --- /dev/null +++ b/airtime_mvc/tests/runtests.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +export AIRTIME_UNIT_TEST="1" +phpunit +