From c81566f5d8c6149e87432b158331fd724e7e35e5 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 6 Apr 2011 08:42:26 +0200 Subject: cherry-pick: add new feature: allow unit test mode enabling via HTTP GET parameter --- src/SemanticScuttle/header.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/SemanticScuttle/header.php b/src/SemanticScuttle/header.php index d1a5c29..5d1ec80 100644 --- a/src/SemanticScuttle/header.php +++ b/src/SemanticScuttle/header.php @@ -39,6 +39,20 @@ set_include_path( require_once $datadir . '/config.default.php'; require_once $datadir . '/config.php'; +if (isset($_GET['unittestMode']) && $_GET['unittestMode'] == 1 +) { + if ($allowUnittestMode !== true) { + header('HTTP/1.0 400 Bad Request'); + die("Unittestmode is not allowed\n"); + } + + $unittestConfigFile = $datadir . '/config.unittest.php'; + if (file_exists($unittestConfigFile)) { + require_once $unittestConfigFile; + } + define('HTTP_UNIT_TEST_MODE', true); + define('UNIT_TEST_MODE', true); +} if (defined('UNIT_TEST_MODE')) { //make local config vars global - needed for unit tests //run with phpunit @@ -117,7 +131,7 @@ $tplVars['currentUser'] = $currentUser; $tplVars['userservice'] = $userservice; // 6 // Force UTF-8 behaviour for server (cannot be moved into top.inc.php which is not included into every file) -if (!defined('UNIT_TEST_MODE')) { +if (!defined('UNIT_TEST_MODE') || defined('HTTP_UNIT_TEST_MODE')) { //API files define that, so we need a way to support both of them if (!isset($httpContentType)) { $httpContentType = 'text/html'; -- cgit v1.2.3 From f3fdb6ca14691c91201a4febfe43982f81bd7ce4 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 18 Apr 2011 19:16:18 +0200 Subject: start the session when we are in http unittest mode --- src/SemanticScuttle/header.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/SemanticScuttle/header.php b/src/SemanticScuttle/header.php index 5d1ec80..8668bbb 100644 --- a/src/SemanticScuttle/header.php +++ b/src/SemanticScuttle/header.php @@ -104,7 +104,7 @@ T_bind_textdomain_codeset($domain, 'UTF-8'); T_textdomain($domain); // 4 // Session -if (!defined('UNIT_TEST_MODE')) { +if (!defined('UNIT_TEST_MODE') || defined('HTTP_UNIT_TEST_MODE')) { session_start(); if ($GLOBALS['enableVoting']) { if (isset($_SESSION['lastUrl'])) { -- cgit v1.2.3 From da36ba7b7e9e56d7dbf9f516f9b2674b78e10ef9 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 26 Apr 2011 06:48:26 +0200 Subject: replace deprecated split --- src/SemanticScuttle/Service/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php index 091ea4d..7f0624e 100644 --- a/src/SemanticScuttle/Service/User.php +++ b/src/SemanticScuttle/Service/User.php @@ -359,7 +359,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService return (int)$_SESSION[$this->getSessionKey()]; } else if (isset($_COOKIE[$this->getCookieKey()])) { - $cook = split(':', $_COOKIE[$this->getCookieKey()]); + $cook = explode(':', $_COOKIE[$this->getCookieKey()]); //cookie looks like this: 'id:md5(username+password)' $query = 'SELECT * FROM '. $this->getTableName() . ' WHERE MD5(CONCAT('.$this->getFieldName('username') . -- cgit v1.2.3