2014-02-17 20:00:04 +00:00
|
|
|
<?php
|
2014-02-18 21:59:07 +00:00
|
|
|
/**
|
|
|
|
* SimpleTest integration with Travis CI for Shimmie
|
2014-02-22 20:36:52 +00:00
|
|
|
*
|
2014-02-18 21:59:07 +00:00
|
|
|
* @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
|
|
|
|
*/
|
2014-02-17 20:00:04 +00:00
|
|
|
|
2014-02-19 03:54:53 +00:00
|
|
|
require_once('lib/simpletest/unit_tester.php');
|
|
|
|
require_once('lib/simpletest/web_tester.php');
|
|
|
|
require_once('lib/simpletest/reporter.php');
|
|
|
|
|
|
|
|
// Enable all errors.
|
|
|
|
error_reporting(E_ALL);
|
|
|
|
|
|
|
|
// Get the command line option telling us what database to use.
|
2014-02-19 23:17:26 +00:00
|
|
|
$options = getopt("d:h:");
|
2014-02-19 03:54:53 +00:00
|
|
|
$db = $options["d"];
|
2014-02-19 23:26:01 +00:00
|
|
|
$host = rtrim(trim(trim($options["h"], '"')), "/");
|
2014-02-19 03:54:53 +00:00
|
|
|
|
|
|
|
if (empty($db)){ die("Error: need to specifiy a database for the test environment."); }
|
2014-02-19 23:17:26 +00:00
|
|
|
if (empty($host)){ $host = "http://127.0.0.1"; }
|
2014-02-19 03:54:53 +00:00
|
|
|
|
|
|
|
define("_TRAVIS_DATABASE", $db);
|
2014-02-19 08:29:12 +00:00
|
|
|
define("_TRAVIS_WEBHOST", $host);
|
2014-02-19 03:54:53 +00:00
|
|
|
|
2014-02-18 22:18:25 +00:00
|
|
|
class ShimmieInstallerTest extends WebTestCase {
|
2014-02-17 20:53:22 +00:00
|
|
|
function testInstallShimmie()
|
2014-02-17 20:00:04 +00:00
|
|
|
{
|
2014-02-18 21:28:43 +00:00
|
|
|
$db = constant("_TRAVIS_DATABASE");
|
2014-02-19 08:29:12 +00:00
|
|
|
$host = constant("_TRAVIS_WEBHOST");
|
2014-02-22 20:36:52 +00:00
|
|
|
|
2014-02-19 08:29:12 +00:00
|
|
|
// Make sure that we know where the host is.
|
|
|
|
$this->assertFalse(empty($host));
|
2014-02-18 20:41:42 +00:00
|
|
|
// Make sure that we know what database to use.
|
2014-02-18 21:28:43 +00:00
|
|
|
$this->assertFalse(empty($db));
|
2014-02-22 20:36:52 +00:00
|
|
|
|
2014-02-19 08:29:12 +00:00
|
|
|
$this->get($host);
|
2014-02-17 20:00:04 +00:00
|
|
|
$this->assertResponse(200);
|
2014-02-17 20:45:42 +00:00
|
|
|
$this->assertTitle("Shimmie Installation");
|
|
|
|
$this->assertText("Database Install");
|
2014-02-22 20:36:52 +00:00
|
|
|
|
2014-02-18 21:28:43 +00:00
|
|
|
$this->setField("database_type", $db);
|
2014-02-18 18:10:19 +00:00
|
|
|
$this->assertField("database_host", "localhost");
|
2014-02-22 20:36:52 +00:00
|
|
|
|
2014-02-18 21:28:43 +00:00
|
|
|
if ($db === "mysql") {
|
2014-02-18 18:10:19 +00:00
|
|
|
$this->setField("database_user", "root");
|
|
|
|
$this->setField("database_password", "");
|
2014-02-18 21:28:43 +00:00
|
|
|
} elseif ($db === "pgsql") {
|
2014-02-18 18:10:19 +00:00
|
|
|
$this->setField("database_user", "postgres");
|
|
|
|
$this->setField("database_password", "");
|
2014-02-22 01:36:19 +00:00
|
|
|
} else {
|
|
|
|
die("Unsupported Database Option");
|
|
|
|
}
|
2014-02-22 20:36:52 +00:00
|
|
|
|
2014-02-18 18:10:19 +00:00
|
|
|
$this->assertField("database_name", "shimmie");
|
2014-02-18 08:32:05 +00:00
|
|
|
$this->clickSubmit("Go!");
|
2014-02-22 20:36:52 +00:00
|
|
|
|
2014-02-18 21:58:31 +00:00
|
|
|
if (!$this->assertText("Installation Succeeded!")) {
|
2014-02-18 17:57:32 +00:00
|
|
|
$this->showSource();
|
|
|
|
}
|
2014-02-17 20:00:04 +00:00
|
|
|
}
|
|
|
|
}
|
2014-02-19 08:42:18 +00:00
|
|
|
|
|
|
|
$test = new TestSuite('Install Shimmie');
|
|
|
|
$test->add(new ShimmieInstallerTest());
|
|
|
|
exit ($test->run(new TextReporter()) ? 0 : 1);
|