aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-03 23:25:07 +0000
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-03 23:25:07 +0000
commitdfeeae38a9feaa30f5dec50a09476c03f431a196 (patch)
tree6fe9c5a052c2d08b62a9e4dfc7832b4bdf95c9bd
parentde031f043f9918424b26534d233df90b7d5c42f9 (diff)
downloadsemanticscuttle-dfeeae38a9feaa30f5dec50a09476c03f431a196.tar.gz
semanticscuttle-dfeeae38a9feaa30f5dec50a09476c03f431a196.tar.bz2
get rid of headers-already-sent-errors when running unit tests on cli
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@390 b3834d28-1941-0410-a4f8-b48e95affb8f
-rw-r--r--src/SemanticScuttle/constants.php5
-rw-r--r--src/SemanticScuttle/header.php8
-rw-r--r--tests/AllTests.php1
-rw-r--r--tests/prepare.php7
4 files changed, 15 insertions, 6 deletions
diff --git a/src/SemanticScuttle/constants.php b/src/SemanticScuttle/constants.php
index e37f41c..95c4384 100644
--- a/src/SemanticScuttle/constants.php
+++ b/src/SemanticScuttle/constants.php
@@ -11,10 +11,7 @@ if(isset($GLOBALS['debugMode'])) {
}
// Determine the base URL as ROOT
-if (!isset($_SERVER['HTTP_HOST'])) {
- //not set in unit tests
- define('ROOT', 'http://localhost/');
-} else if (!isset($GLOBALS['root'])) {
+if (!isset($GLOBALS['root'])) {
$pieces = explode('/', $_SERVER['SCRIPT_NAME']);
$rootTmp = '/';
diff --git a/src/SemanticScuttle/header.php b/src/SemanticScuttle/header.php
index b01679c..53dcad6 100644
--- a/src/SemanticScuttle/header.php
+++ b/src/SemanticScuttle/header.php
@@ -45,7 +45,9 @@ T_bind_textdomain_codeset($domain, 'UTF-8');
T_textdomain($domain);
// 4 // Session
-session_start();
+if (!defined('UNIT_TEST_MODE')) {
+ session_start();
+}
// 5 // Create mandatory services and objects
$userservice =SemanticScuttle_Service_Factory::getServiceInstance('User');
@@ -57,5 +59,7 @@ $tplVars['currentUser'] = $currentUser;
$tplVars['userservice'] = $userservice;
// 6 // Force UTF-8 behaviour for server (cannot be move into top.inc.php which is not included into every file)
-header('Content-Type: text/html; charset=utf-8');
+if (!defined('UNIT_TEST_MODE')) {
+ header('Content-Type: text/html; charset=utf-8');
+}
?>
diff --git a/tests/AllTests.php b/tests/AllTests.php
index 1526da8..db3ebfe 100644
--- a/tests/AllTests.php
+++ b/tests/AllTests.php
@@ -15,6 +15,7 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'AllTests::main');
}
+require_once 'prepare.php';
require_once 'PHPUnit/Framework/TestSuite.php';
class AllTests extends PHPUnit_Framework_TestSuite
diff --git a/tests/prepare.php b/tests/prepare.php
new file mode 100644
index 0000000..50304c2
--- /dev/null
+++ b/tests/prepare.php
@@ -0,0 +1,7 @@
+<?php
+/**
+ * Prepare the application for unit testing
+ */
+$_SERVER['HTTP_HOST'] = 'http://localhost/';
+define('UNIT_TEST_MODE', true);
+?> \ No newline at end of file