From 8b0ac0e9c1f45343c847cae529cbbab1e7552c61 Mon Sep 17 00:00:00 2001 From: jgen Date: Wed, 19 Feb 2014 03:29:12 -0500 Subject: [PATCH] The location of the webserver should be configurable in the travis file. --- .travis.yml | 4 ++-- ext/simpletest/main.php | 8 ++++++-- tests/all_tests.php | 8 ++++++++ tests/test_install.php | 10 ++++++++-- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 177b76b6..3e1acf78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,8 +24,8 @@ install: - if [[ "$DB" == "mysql" ]]; then mysql -e "CREATE DATABASE shimmie;" -uroot; fi script: - - php tests/test_install.php -d $DB - - php tests/all_tests.php + - php tests/test_install.php -d $DB -h "http://127.0.0.1/" + - php tests/all_tests.php -h "http://127.0.0.1/" # If a failure occured then dump out a bunch of logs for debugging purposes. after_failure: diff --git a/ext/simpletest/main.php b/ext/simpletest/main.php index cd4df75f..9d6bf18f 100644 --- a/ext/simpletest/main.php +++ b/ext/simpletest/main.php @@ -111,10 +111,14 @@ class SCoreWebTestCase extends WebTestCase { */ protected function get_page($page) { if($_SERVER['HTTP_HOST'] == "") { - // FIXME: this should be a command line option. //print "http://127.0.0.1/2.Xm/index.php?q=$page"; - $raw = $this->get("http://127.0.0.1/index.php?q=".str_replace("?", "&", $page)); + + $host = constant("_TRAVIS_WEBHOST"); + // Make sure that we know where the host is. + $this->assertFalse(empty($host)); + + $raw = $this->get($host."index.php?q=".str_replace("?", "&", $page)); } else { $raw = $this->get(make_http(make_link($page))); diff --git a/tests/all_tests.php b/tests/all_tests.php index b438ec1c..833cb398 100644 --- a/tests/all_tests.php +++ b/tests/all_tests.php @@ -15,6 +15,14 @@ require_once('lib/simpletest/reporter.php'); // Enable all errors. error_reporting(E_ALL); +// Get the command line option telling us where the webserver is. +$options = getopt("h::"); +$host = trim($options["h"], "'\""); + +if (empty($host)){ $host = "http://127.0.0.1/"; } + +define("_TRAVIS_WEBHOST", $host); + // The code below is based on the code in index.php //-------------------------------------------------- diff --git a/tests/test_install.php b/tests/test_install.php index 5f8144b4..dcc6fc3e 100644 --- a/tests/test_install.php +++ b/tests/test_install.php @@ -17,22 +17,28 @@ require_once('lib/simpletest/reporter.php'); error_reporting(E_ALL); // Get the command line option telling us what database to use. -$options = getopt("d:"); +$options = getopt("d:h::"); $db = $options["d"]; +$host = trim($options["h"], "'\""); if (empty($db)){ die("Error: need to specifiy a database for the test environment."); } +if (empty($host)){ $host = "http://127.0.0.1/"; } define("_TRAVIS_DATABASE", $db); +define("_TRAVIS_WEBHOST", $host); class ShimmieInstallerTest extends WebTestCase { function testInstallShimmie() { $db = constant("_TRAVIS_DATABASE"); + $host = constant("_TRAVIS_WEBHOST"); + // Make sure that we know where the host is. + $this->assertFalse(empty($host)); // Make sure that we know what database to use. $this->assertFalse(empty($db)); - $this->get('http://127.0.0.1/'); + $this->get($host); $this->assertResponse(200); $this->assertTitle("Shimmie Installation"); $this->assertText("Database Install");