From 141be8768ff27cb235fc329972ed60f04047f58c Mon Sep 17 00:00:00 2001
From: jgen <jeffgenovy@gmail.com>
Date: Wed, 19 Feb 2014 18:10:40 -0500
Subject: [PATCH] Better detection of running on the command line.

---
 ext/alias_editor/test.php |  2 +-
 ext/simpletest/main.php   | 14 +++++---------
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/ext/alias_editor/test.php b/ext/alias_editor/test.php
index 3433edde..a69e5706 100644
--- a/ext/alias_editor/test.php
+++ b/ext/alias_editor/test.php
@@ -8,7 +8,7 @@ class AliasEditorTest extends ShimmieWebTestCase {
 		$this->log_in_as_user();
 		$this->get_page('alias/list');
 		$this->assert_title("Alias List");
-		$this->assertFalse($this->assertFieldByName('oldtag', ''));		
+		$this->assert_no_text("Add");		
 		$this->log_out();
 		
 		$this->log_in_as_admin();
diff --git a/ext/simpletest/main.php b/ext/simpletest/main.php
index 9d6bf18f..afd3b372 100644
--- a/ext/simpletest/main.php
+++ b/ext/simpletest/main.php
@@ -110,15 +110,11 @@ class SCoreWebTestCase extends WebTestCase {
 	 * the right thing; no need for http:// or any such
 	 */
 	protected function get_page($page) {
-		if($_SERVER['HTTP_HOST'] == "<cli command>") {
-			
-			//print "http://127.0.0.1/2.Xm/index.php?q=$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));
+		// Check if we are running on the command line
+		if(php_sapi_name() === 'cli' || $_SERVER['HTTP_HOST'] == "<cli command>") {
+			$host = rtrim(trim(constant("_TRAVIS_WEBHOST")), "/");
+			$this->assertFalse(empty($host)); // Make sure that we know the host address.
+			$raw = $this->get($host."/index.php?q=".str_replace("?", "&", $page));
 		}
 		else {
 			$raw = $this->get(make_http(make_link($page)));