2014-02-18 22:18:25 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* SimpleTest integration with Travis CI for Shimmie
|
|
|
|
*
|
|
|
|
* @package Shimmie
|
|
|
|
* @author jgen <jeffgenovy@gmail.com>
|
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
|
|
|
* @copyright Copyright (c) 2014, jgen
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once('lib/simpletest/unit_tester.php');
|
|
|
|
require_once('lib/simpletest/web_tester.php');
|
|
|
|
require_once('lib/simpletest/reporter.php');
|
|
|
|
|
2014-02-19 03:21:14 +00:00
|
|
|
// Enable all errors.
|
|
|
|
error_reporting(E_ALL);
|
2014-02-19 21:40:28 +00:00
|
|
|
define("CLI_LOG_LEVEL", -100); // output everything.
|
2014-02-19 03:21:14 +00:00
|
|
|
|
2014-02-19 08:29:12 +00:00
|
|
|
// Get the command line option telling us where the webserver is.
|
2014-02-19 23:17:26 +00:00
|
|
|
$options = getopt("h:");
|
2014-02-19 23:26:01 +00:00
|
|
|
$host = rtrim(trim(trim($options["h"], '"')), "/");
|
2014-02-19 08:29:12 +00:00
|
|
|
|
2014-02-19 23:17:26 +00:00
|
|
|
if (empty($host)){ $host = "http://127.0.0.1"; }
|
2014-02-19 08:29:12 +00:00
|
|
|
|
|
|
|
define("_TRAVIS_WEBHOST", $host);
|
|
|
|
|
2014-02-19 05:40:16 +00:00
|
|
|
// The code below is based on the code in index.php
|
|
|
|
//--------------------------------------------------
|
2014-02-19 03:35:25 +00:00
|
|
|
|
2014-02-19 03:54:53 +00:00
|
|
|
require_once "core/sys_config.inc.php";
|
|
|
|
require_once "core/util.inc.php";
|
|
|
|
|
2014-02-19 00:24:10 +00:00
|
|
|
// set up and purify the environment
|
|
|
|
_version_check();
|
|
|
|
_sanitise_environment();
|
|
|
|
|
|
|
|
// load base files
|
|
|
|
$files = array_merge(zglob("core/*.php"), zglob("ext/{".ENABLED_EXTS."}/main.php"));
|
|
|
|
foreach($files as $filename) {
|
|
|
|
require_once $filename;
|
|
|
|
}
|
2014-02-19 01:08:23 +00:00
|
|
|
|
2014-02-19 05:40:16 +00:00
|
|
|
// We also need to pull in the SimpleTest extension.
|
|
|
|
require_once('ext/simpletest/main.php');
|
|
|
|
|
2014-02-19 00:24:10 +00:00
|
|
|
// connect to the database
|
|
|
|
$database = new Database();
|
|
|
|
$config = new DatabaseConfig($database);
|
|
|
|
|
|
|
|
// load the theme parts
|
|
|
|
foreach(_get_themelet_files(get_theme()) as $themelet) {
|
|
|
|
require_once $themelet;
|
|
|
|
}
|
|
|
|
|
|
|
|
_load_extensions();
|
|
|
|
|
2014-02-22 06:22:14 +00:00
|
|
|
// Fire off the InitExtEvent()
|
|
|
|
$page = class_exists("CustomPage") ? new CustomPage() : new Page();
|
|
|
|
$user = _get_user();
|
|
|
|
send_event(new InitExtEvent());
|
|
|
|
|
|
|
|
// Put the database into autocommit mode for making the users.
|
2014-02-19 09:19:17 +00:00
|
|
|
$database->commit();
|
|
|
|
|
2014-02-19 05:00:18 +00:00
|
|
|
// Create the necessary users for the tests.
|
2014-02-19 07:39:13 +00:00
|
|
|
$userPage = new UserPage();
|
|
|
|
$userPage->onUserCreation(new UserCreationEvent("demo", "demo", ""));
|
|
|
|
$userPage->onUserCreation(new UserCreationEvent("test", "test", ""));
|
|
|
|
|
2014-02-22 06:22:14 +00:00
|
|
|
// Fire off the InitExtEvent() again after we have made the users.
|
2014-02-19 07:39:13 +00:00
|
|
|
$page = class_exists("CustomPage") ? new CustomPage() : new Page();
|
|
|
|
$user = _get_user();
|
|
|
|
send_event(new InitExtEvent());
|
|
|
|
|
2014-02-19 21:16:01 +00:00
|
|
|
// Now we can actually run all the tests.
|
2014-02-19 06:24:53 +00:00
|
|
|
$all = new TestFinder("");
|
2014-02-19 06:32:51 +00:00
|
|
|
$results = $all->run(new TextReporter());
|
2014-02-18 22:36:21 +00:00
|
|
|
|
2014-02-19 21:16:01 +00:00
|
|
|
// Travis-CI needs to know the results of the tests.
|
2014-02-19 06:32:51 +00:00
|
|
|
exit ($results ? 0 : 1);
|