diff --git a/src/SemanticScuttle/constants.php b/src/SemanticScuttle/constants.php index 4940af8..e37f41c 100644 --- a/src/SemanticScuttle/constants.php +++ b/src/SemanticScuttle/constants.php @@ -11,11 +11,14 @@ if(isset($GLOBALS['debugMode'])) { } // Determine the base URL as ROOT -if (!isset($GLOBALS['root'])) { +if (!isset($_SERVER['HTTP_HOST'])) { + //not set in unit tests + define('ROOT', 'http://localhost/'); +} else if (!isset($GLOBALS['root'])) { $pieces = explode('/', $_SERVER['SCRIPT_NAME']); $rootTmp = '/'; - foreach($pieces as $piece) { + foreach ($pieces as $piece) { //we eliminate possible sscuttle subfolders (like gsearch for example) if ($piece != '' && !strstr($piece, '.php') && $piece != 'gsearch') { $rootTmp .= $piece .'/'; diff --git a/tests/AllTests.php b/tests/AllTests.php new file mode 100644 index 0000000..1526da8 --- /dev/null +++ b/tests/AllTests.php @@ -0,0 +1,58 @@ +addTestFile($tdir . '/BookmarksTest.php'); + $suite->addTestFile($tdir . '/Tag2TagTest.php'); + $suite->addTestFile($tdir . '/TagsCacheTest.php'); + $suite->addTestFile($tdir . '/CommonDescriptionTest.php'); + $suite->addTestFile($tdir . '/SearchTest.php'); + $suite->addTestFile($tdir . '/TagsTest.php'); + return $suite; + } + + protected function setUp() + { + global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, + $tableprefix, $TEMPLATES_DIR, $filetypes, $debugMode; + require_once dirname(__FILE__) . '/../src/SemanticScuttle/header.php'; + } + + protected function tearDown() + { + } +} + +if (PHPUnit_MAIN_METHOD == 'AllTests::main') { + AllTests::main(); +} + +?> \ No newline at end of file diff --git a/tests/bookmarksTest.php b/tests/BookmarksTest.php similarity index 94% rename from tests/bookmarksTest.php rename to tests/BookmarksTest.php index 3bff35d..fd9ed76 100644 --- a/tests/bookmarksTest.php +++ b/tests/BookmarksTest.php @@ -16,8 +16,9 @@ class BookmarksTest extends PHPUnit_Framework_TestCase protected function setUp() { - global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, $tableprefix, $TEMPLATES_DIR, $filetypes, $debugMode; - require_once('./header.inc.php'); + global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, + $tableprefix, $TEMPLATES_DIR, $filetypes, $debugMode; + require_once dirname(__FILE__) . '/../src/SemanticScuttle/header.php'; $this->us =SemanticScuttle_Service_Factory::getServiceInstance('User'); $this->bs =SemanticScuttle_Service_Factory::getServiceInstance('Bookmark'); diff --git a/tests/commonDescriptionTest.php b/tests/CommonDescriptionTest.php similarity index 97% rename from tests/commonDescriptionTest.php rename to tests/CommonDescriptionTest.php index f73b646..87d09d1 100644 --- a/tests/commonDescriptionTest.php +++ b/tests/CommonDescriptionTest.php @@ -19,7 +19,7 @@ class CommonDescriptionTest extends PHPUnit_Framework_TestCase protected function setUp() { global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, $tableprefix; - require_once('./header.inc.php'); + require_once dirname(__FILE__) . '/../src/SemanticScuttle/header.php'; $this->us =SemanticScuttle_Service_Factory::getServiceInstance('User'); $this->bs =SemanticScuttle_Service_Factory::getServiceInstance('Bookmark'); diff --git a/tests/searchTest.php b/tests/SearchTest.php similarity index 97% rename from tests/searchTest.php rename to tests/SearchTest.php index 1dce7dc..e03b4d9 100644 --- a/tests/searchTest.php +++ b/tests/SearchTest.php @@ -18,7 +18,7 @@ class SearchTest extends PHPUnit_Framework_TestCase protected function setUp() { global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, $tableprefix; - require_once('./header.inc.php'); + require_once dirname(__FILE__) . '/../src/SemanticScuttle/header.php'; $this->us =SemanticScuttle_Service_Factory::getServiceInstance('User'); $this->bs =SemanticScuttle_Service_Factory::getServiceInstance('Bookmark'); diff --git a/tests/tag2TagTest.php b/tests/Tag2TagTest.php similarity index 99% rename from tests/tag2TagTest.php rename to tests/Tag2TagTest.php index ab3114c..24c0ae1 100644 --- a/tests/tag2TagTest.php +++ b/tests/Tag2TagTest.php @@ -17,7 +17,7 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase protected function setUp() { global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, $tableprefix; - require_once('./header.inc.php'); + require_once dirname(__FILE__) . '/../src/SemanticScuttle/header.php'; $this->us =SemanticScuttle_Service_Factory::getServiceInstance('User'); $this->bs =SemanticScuttle_Service_Factory::getServiceInstance('Bookmark'); diff --git a/tests/tagsCacheTest.php b/tests/TagsCacheTest.php similarity index 98% rename from tests/tagsCacheTest.php rename to tests/TagsCacheTest.php index 7673565..f401ab6 100644 --- a/tests/tagsCacheTest.php +++ b/tests/TagsCacheTest.php @@ -17,7 +17,7 @@ class TagsCacheTest extends PHPUnit_Framework_TestCase protected function setUp() { global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, $tableprefix, $TEMPLATES_DIR, $debugMode; - require_once('./header.inc.php'); + require_once dirname(__FILE__) . '/../src/SemanticScuttle/header.php'; $this->us =SemanticScuttle_Service_Factory::getServiceInstance('User'); $this->bs =SemanticScuttle_Service_Factory::getServiceInstance('Bookmark'); diff --git a/tests/tagsTest.php b/tests/TagsTest.php similarity index 97% rename from tests/tagsTest.php rename to tests/TagsTest.php index d4957c9..bb904e1 100644 --- a/tests/tagsTest.php +++ b/tests/TagsTest.php @@ -14,7 +14,7 @@ class TagsTest extends PHPUnit_Framework_TestCase protected function setUp() { global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, $tableprefix; - require_once('./header.inc.php'); + require_once dirname(__FILE__) . '/../src/SemanticScuttle/header.php'; $this->ts =SemanticScuttle_Service_Factory::getServiceInstance('Tag'); $this->ts->deleteAll(); diff --git a/tests/allTests.php b/tests/allTests.php deleted file mode 100644 index 843911c..0000000 --- a/tests/allTests.php +++ /dev/null @@ -1,39 +0,0 @@ -addTestFile('tests/bookmarksTest.php'); - $suite->addTestFile('tests/tag2TagTest.php'); - $suite->addTestFile('tests/tagsCacheTest.php'); - $suite->addTestFile('tests/commonDescriptionTest.php'); - $suite->addTestFile('tests/searchTest.php'); - $suite->addTestFile('tests/tagsTest.php'); - return $suite; - } - - protected function setUp() - { - global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, $tableprefix, $TEMPLATES_DIR, $filetypes, $debugMode; - require_once('./header.inc.php'); - } - - protected function tearDown() - { - } -} -?> \ No newline at end of file