2006-10-01 17:54:15 +04:00
|
|
|
<?php
|
|
|
|
ob_start();
|
|
|
|
|
2007-01-29 23:10:51 +03:00
|
|
|
ini_set('max_execution_time', 900);
|
2006-10-01 17:54:15 +04:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
function autoload($class) {
|
|
|
|
if(strpos($class, 'TestCase') === false)
|
|
|
|
return false;
|
2006-11-28 21:39:31 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
$e = explode('_', $class);
|
|
|
|
$count = count($e);
|
2006-10-01 17:54:15 +04:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
array_shift($e);
|
2006-11-28 01:49:13 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
$dir = array_shift($e);
|
2006-12-02 17:40:47 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
$file = $dir . '_' . substr(implode('_', $e), 0, -(strlen('_TestCase'))) . 'TestCase.php';
|
2006-12-02 17:40:47 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
if($count > 3) {
|
|
|
|
$file = str_replace('_', DIRECTORY_SEPARATOR, $file);
|
|
|
|
} else {
|
|
|
|
$file = str_replace('_', '', $file);
|
|
|
|
}
|
2006-12-28 00:30:25 +03:00
|
|
|
print $file ."<br \>";
|
2006-12-28 00:20:26 +03:00
|
|
|
// create a test case file if it doesn't exist
|
2006-12-02 17:40:47 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
if( ! file_exists($file)) {
|
|
|
|
$contents = file_get_contents('template.tpl');
|
|
|
|
$contents = sprintf($contents, $class, $class);
|
2006-12-02 23:51:26 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
if( ! file_exists($dir)) {
|
|
|
|
mkdir($dir, 0777);
|
|
|
|
}
|
2006-11-28 01:49:13 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
file_put_contents($file, $contents);
|
|
|
|
}
|
|
|
|
require_once($file);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2006-11-28 01:49:13 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
require_once dirname(__FILE__) . '/../lib/Doctrine.php';
|
2006-11-30 00:09:02 +03:00
|
|
|
|
2007-01-10 01:59:15 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
spl_autoload_register(array('Doctrine', 'autoload'));
|
|
|
|
spl_autoload_register('autoload');
|
2006-11-30 00:09:02 +03:00
|
|
|
|
2007-01-10 01:59:15 +03:00
|
|
|
require_once dirname(__FILE__) . '/../models/location.php';
|
2006-12-28 00:20:26 +03:00
|
|
|
require_once('classes.php');
|
|
|
|
require_once('simpletest/unit_tester.php');
|
|
|
|
require_once('simpletest/reporter.php');
|
|
|
|
require_once('UnitTestCase.php');
|
|
|
|
require_once('DriverTestCase.php');
|
2006-11-30 00:09:02 +03:00
|
|
|
|
2007-01-10 01:59:15 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
error_reporting(E_ALL);
|
|
|
|
print '<pre>';
|
2006-11-24 02:23:24 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
$test = new GroupTest('Doctrine Framework Unit Tests');
|
2006-11-24 02:23:24 +03:00
|
|
|
|
2007-01-10 02:11:32 +03:00
|
|
|
|
|
|
|
|
2006-11-24 02:23:24 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
// DATABASE ABSTRACTION tests
|
2007-01-30 00:37:51 +03:00
|
|
|
/**
|
2007-01-01 21:36:37 +03:00
|
|
|
// Connection drivers (not yet fully tested)
|
2006-12-28 00:20:26 +03:00
|
|
|
$test->addTestCase(new Doctrine_Connection_Pgsql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Connection_Oracle_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Connection_Sqlite_TestCase());
|
2007-01-01 21:36:37 +03:00
|
|
|
$test->addTestCase(new Doctrine_Connection_Mssql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Connection_Mysql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Connection_Firebird_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Connection_Informix_TestCase());
|
2007-01-06 01:13:44 +03:00
|
|
|
|
2007-01-01 21:36:37 +03:00
|
|
|
// Transaction module (FULLY TESTED)
|
|
|
|
$test->addTestCase(new Doctrine_Transaction_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Transaction_Firebird_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Transaction_Informix_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Transaction_Mysql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Transaction_Mssql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Transaction_Pgsql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Transaction_Oracle_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Transaction_Sqlite_TestCase());
|
2006-12-24 01:45:36 +03:00
|
|
|
|
2007-01-01 21:36:37 +03:00
|
|
|
// DataDict module (FULLY TESTED)
|
|
|
|
$test->addTestCase(new Doctrine_DataDict_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_DataDict_Firebird_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_DataDict_Informix_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_DataDict_Mysql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_DataDict_Mssql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_DataDict_Pgsql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_DataDict_Oracle_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_DataDict_Sqlite_TestCase());
|
|
|
|
|
2007-01-08 02:52:15 +03:00
|
|
|
// Sequence module (not yet fully tested)
|
|
|
|
$test->addTestCase(new Doctrine_Sequence_TestCase());
|
2007-01-10 02:14:22 +03:00
|
|
|
$test->addTestCase(new Doctrine_Sequence_Firebird_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Sequence_Informix_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Sequence_Mysql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Sequence_Mssql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Sequence_Pgsql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Sequence_Oracle_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Sequence_Sqlite_TestCase());
|
2007-01-08 02:52:15 +03:00
|
|
|
|
|
|
|
|
2007-01-01 21:36:37 +03:00
|
|
|
// Export module (not yet fully tested)
|
2006-12-28 00:20:26 +03:00
|
|
|
$test->addTestCase(new Doctrine_Export_TestCase());
|
2007-01-23 19:27:20 +03:00
|
|
|
//$test->addTestCase(new Doctrine_Export_Reporter_TestCase());
|
2006-12-28 00:20:26 +03:00
|
|
|
$test->addTestCase(new Doctrine_Export_Firebird_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Export_Informix_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Export_Mysql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Export_Mssql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Export_Pgsql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Export_Oracle_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Export_Sqlite_TestCase());
|
2006-12-22 01:06:08 +03:00
|
|
|
|
2007-01-01 21:36:37 +03:00
|
|
|
// Import module (not yet fully tested)
|
2006-12-28 00:20:26 +03:00
|
|
|
//$test->addTestCase(new Doctrine_Import_TestCase());
|
2007-01-27 13:08:06 +03:00
|
|
|
$test->addTestCase(new Doctrine_Import_Firebird_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Import_Informix_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Import_Mysql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Import_Mssql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Import_Pgsql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Import_Oracle_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Import_Sqlite_TestCase());
|
2007-01-25 01:50:49 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
|
2007-01-01 21:36:37 +03:00
|
|
|
// Expression module (not yet fully tested)
|
2006-12-28 00:20:26 +03:00
|
|
|
$test->addTestCase(new Doctrine_Expression_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Expression_Firebird_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Expression_Informix_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Expression_Mysql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Expression_Mssql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Expression_Pgsql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Expression_Oracle_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Expression_Sqlite_TestCase());
|
|
|
|
|
|
|
|
// Core
|
|
|
|
|
|
|
|
$test->addTestCase(new Doctrine_Access_TestCase());
|
|
|
|
//$test->addTestCase(new Doctrine_Configurable_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Manager_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Connection_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Table_TestCase());
|
2006-11-24 02:23:24 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
$test->addTestCase(new Doctrine_UnitOfWork_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Connection_Transaction_TestCase());
|
2006-11-24 02:23:24 +03:00
|
|
|
|
2007-01-01 21:36:37 +03:00
|
|
|
$test->addTestCase(new Doctrine_Collection_TestCase());
|
2006-12-02 17:40:47 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
// Relation handling
|
|
|
|
$test->addTestCase(new Doctrine_Relation_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Relation_Access_TestCase());
|
2006-12-02 23:51:26 +03:00
|
|
|
$test->addTestCase(new Doctrine_Relation_ManyToMany_TestCase());
|
2007-01-08 02:52:15 +03:00
|
|
|
$test->addTestCase(new Doctrine_Relation_OneToOne_TestCase());
|
|
|
|
|
2007-01-27 13:08:06 +03:00
|
|
|
$test->addTestCase(new Doctrine_TreeStructure_TestCase());
|
2006-11-30 00:09:02 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
// Datatypes
|
|
|
|
$test->addTestCase(new Doctrine_Enum_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Boolean_TestCase());
|
2006-12-02 17:40:47 +03:00
|
|
|
|
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
// Utility components
|
|
|
|
$test->addTestCase(new Doctrine_Hook_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_PessimisticLocking_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Validator_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_RawSql_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_View_TestCase());
|
2006-11-16 23:31:39 +03:00
|
|
|
|
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
// Db component
|
2006-11-08 02:12:05 +03:00
|
|
|
$test->addTestCase(new Doctrine_Db_TestCase());
|
2006-11-08 22:12:16 +03:00
|
|
|
$test->addTestCase(new Doctrine_Db_Profiler_TestCase());
|
|
|
|
|
2006-11-05 22:24:28 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
// Record
|
2006-10-31 02:00:09 +03:00
|
|
|
$test->addTestCase(new Doctrine_Record_TestCase());
|
2006-10-26 00:02:40 +04:00
|
|
|
$test->addTestCase(new Doctrine_Record_State_TestCase());
|
2006-12-28 00:20:26 +03:00
|
|
|
//$test->addTestCase(new Doctrine_Record_Filter_TestCase());
|
2006-10-20 22:21:42 +04:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
// Eventlisteners
|
|
|
|
$test->addTestCase(new Doctrine_EventListener_TestCase());
|
2006-10-01 17:54:15 +04:00
|
|
|
$test->addTestCase(new Doctrine_EventListener_Chain_TestCase());
|
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
// Old test cases (should be removed)
|
|
|
|
$test->addTestCase(new Doctrine_SchemaTestCase());
|
|
|
|
$test->addTestCase(new Doctrine_BatchIterator_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_CustomPrimaryKey_TestCase());
|
2006-10-01 17:54:15 +04:00
|
|
|
$test->addTestCase(new Doctrine_CustomResultSetOrderTestCase());
|
2006-12-28 00:20:26 +03:00
|
|
|
$test->addTestCase(new Doctrine_Filter_TestCase());
|
|
|
|
//$test->addTestCase(new Doctrine_Collection_Offset_TestCase());
|
2006-10-01 17:54:15 +04:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
// Query tests
|
2006-12-24 01:45:36 +03:00
|
|
|
$test->addTestCase(new Doctrine_Query_MultiJoin_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Query_ReferenceModel_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Query_Condition_TestCase());
|
2006-10-03 21:24:13 +04:00
|
|
|
$test->addTestCase(new Doctrine_Query_ComponentAlias_TestCase());
|
2007-01-29 23:10:51 +03:00
|
|
|
|
2006-10-18 21:37:20 +04:00
|
|
|
$test->addTestCase(new Doctrine_Query_TestCase());
|
2006-11-11 02:15:34 +03:00
|
|
|
$test->addTestCase(new Doctrine_Query_ShortAliases_TestCase());
|
2006-10-18 21:37:20 +04:00
|
|
|
$test->addTestCase(new Doctrine_Query_Delete_TestCase());
|
2006-11-08 22:12:16 +03:00
|
|
|
$test->addTestCase(new Doctrine_Query_Where_TestCase());
|
2006-10-27 02:12:58 +04:00
|
|
|
$test->addTestCase(new Doctrine_Query_Limit_TestCase());
|
2006-12-03 23:05:09 +03:00
|
|
|
$test->addTestCase(new Doctrine_Query_IdentifierQuoting_TestCase());
|
2006-12-22 01:06:08 +03:00
|
|
|
$test->addTestCase(new Doctrine_Query_Update_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Query_AggregateValue_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Query_Select_TestCase());
|
2007-01-01 21:36:37 +03:00
|
|
|
$test->addTestCase(new Doctrine_Query_Expression_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Query_Having_TestCase());
|
2007-01-10 02:11:32 +03:00
|
|
|
$test->addTestCase(new Doctrine_Query_Join_TestCase());
|
2007-01-27 13:08:06 +03:00
|
|
|
$test->addTestCase(new Doctrine_Query_From_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Query_JoinCondition_TestCase());
|
2007-01-23 19:27:20 +03:00
|
|
|
$test->addTestCase(new Doctrine_ColumnAlias_TestCase());
|
2007-01-29 23:10:51 +03:00
|
|
|
$test->addTestCase(new Doctrine_Query_Subquery_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Query_Orderby_TestCase());
|
2007-01-30 00:37:51 +03:00
|
|
|
*/
|
|
|
|
$test->addTestCase(new Doctrine_Cache_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Cache_Apc_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Cache_Memcache_TestCase());
|
|
|
|
$test->addTestCase(new Doctrine_Cache_Sqlite_TestCase());
|
2007-01-27 13:08:06 +03:00
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
// Cache tests
|
2006-11-16 15:45:34 +03:00
|
|
|
//$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
|
2006-10-01 17:54:15 +04:00
|
|
|
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
|
|
|
|
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
|
|
|
|
|
|
|
|
class MyReporter extends HtmlReporter {
|
|
|
|
public function paintHeader() {}
|
|
|
|
public function paintFooter()
|
|
|
|
{
|
|
|
|
$colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green");
|
|
|
|
print "<div style=\"";
|
|
|
|
print "padding: 8px; margin-top: 1em; background-color: $colour; color: white;";
|
|
|
|
print "\">";
|
|
|
|
print $this->getTestCaseProgress() . "/" . $this->getTestCaseCount();
|
|
|
|
print " test cases complete:\n";
|
|
|
|
print "<strong>" . $this->getPassCount() . "</strong> passes, ";
|
|
|
|
print "<strong>" . $this->getFailCount() . "</strong> fails and ";
|
|
|
|
print "<strong>" . $this->getExceptionCount() . "</strong> exceptions.";
|
|
|
|
print "</div>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TextReporter::inCli()) {
|
|
|
|
if ($argc == 4)
|
|
|
|
{
|
|
|
|
$dsn = $argv[1];
|
|
|
|
$username = $argv[2];
|
|
|
|
$password = $argv[3];
|
|
|
|
}
|
|
|
|
exit ($test->run(new TextReporter()) ? 0 : 1);
|
|
|
|
} else {
|
|
|
|
if (isset($_POST))
|
|
|
|
{
|
2006-10-26 01:12:30 +04:00
|
|
|
$dsn = isset($_POST["dsn"])?$_POST["dsn"]:null;
|
|
|
|
$username = isset($_POST["username"])?$_POST["username"]:null;
|
|
|
|
$password = isset($_POST["password"])?$_POST["password"]:null;
|
2006-10-01 17:54:15 +04:00
|
|
|
}
|
|
|
|
$test->run(new MyReporter());
|
|
|
|
$output = ob_get_clean();
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
$cache = Doctrine_Manager::getInstance()->getCurrentConnection()->getCacheHandler();
|
|
|
|
if(isset($cache)) {
|
|
|
|
$a = $cache->getQueries();
|
|
|
|
print "Executed cache queries: ".count($a)."\n";
|
|
|
|
|
|
|
|
foreach($a as $query) {
|
|
|
|
print $query."\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
?>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
|
|
|
|
<title>Doctrine Unit Tests</title>
|
|
|
|
<style>
|
|
|
|
.fail { color: red; } pre { background-color: lightgray; }
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<h1>Doctrine Unit Tests</h1>
|
|
|
|
<h3>DSN Settings</h3>
|
|
|
|
<form method="post">
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<th>DSN</th>
|
|
|
|
<td><input type="text" name="dsn" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>Username</th>
|
|
|
|
<td><input type="text" name="username" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>Password</th>
|
|
|
|
<td><input type="text" name="password" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td> </td>
|
|
|
|
<td><input type="submit" name="submit" /></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
<h3>Tests</h3>
|
|
|
|
<pre>
|
|
|
|
<?php echo $output; ?>
|
|
|
|
</pre>
|
|
|
|
<h3>Queries</h3>
|
|
|
|
<pre>
|
|
|
|
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|