]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
get rid of headers-already-sent-errors when running unit tests on cli
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Sat, 3 Oct 2009 23:25:07 +0000 (23:25 +0000)
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Sat, 3 Oct 2009 23:25:07 +0000 (23:25 +0000)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@390 b3834d28-1941-0410-a4f8-b48e95affb8f

src/SemanticScuttle/constants.php
src/SemanticScuttle/header.php
tests/AllTests.php
tests/prepare.php [new file with mode: 0644]

index e37f41c30d34df37d7738b1b2d45f0996cfe1731..95c4384379ff151c0fb8ea398db02b1cd05c1e24 100644 (file)
@@ -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 = '/';
index b01679c4a0fc8d43922a244d39183401c4d36a82..53dcad6ecaaf142eb269003f8bb90eca90ad20ef 100644 (file)
@@ -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');
+}
 ?>
index 1526da8fe5f70156613b9bbe442438f3df8c29f1..db3ebfe041b94309d5c73f4c079cc231fdf65da6 100644 (file)
@@ -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 (file)
index 0000000..50304c2
--- /dev/null
@@ -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