run.php 11.1 KB
Newer Older
1 2
<?php

zYne's avatar
zYne committed
3
ini_set('max_execution_time', 900);
4

zYne's avatar
zYne committed
5 6 7
function autoload($class) {
    if(strpos($class, 'TestCase') === false)
        return false;
8

zYne's avatar
zYne committed
9 10
    $e      = explode('_', $class);
    $count  = count($e);
11

zYne's avatar
zYne committed
12
    array_shift($e);
13

zYne's avatar
zYne committed
14
    $dir    = array_shift($e);
15

zYne's avatar
zYne committed
16
    $file   = $dir . '_' . substr(implode('_', $e), 0, -(strlen('_TestCase'))) . 'TestCase.php';
17

zYne's avatar
zYne committed
18 19 20 21 22
    if($count > 3) {
        $file   = str_replace('_', DIRECTORY_SEPARATOR, $file);
    } else {
        $file   = str_replace('_', '', $file);
    }
zYne's avatar
zYne committed
23

zYne's avatar
zYne committed
24
    // create a test case file if it doesn't exist
25

zYne's avatar
zYne committed
26 27 28
    if( ! file_exists($file)) {
        $contents = file_get_contents('template.tpl');
        $contents = sprintf($contents, $class, $class);
zYne's avatar
zYne committed
29

zYne's avatar
zYne committed
30 31 32
        if( ! file_exists($dir)) {
            mkdir($dir, 0777);
        }
33

zYne's avatar
zYne committed
34 35 36
        file_put_contents($file, $contents);
    }
    require_once($file);
pookey's avatar
pookey committed
37

zYne's avatar
zYne committed
38 39
    return true;
}
40

pookey's avatar
pookey committed
41
// include doctrine, and register it's autoloader
zYne's avatar
zYne committed
42 43
require_once dirname(__FILE__) . '/../lib/Doctrine.php';
spl_autoload_register(array('Doctrine', 'autoload'));
pookey's avatar
pookey committed
44 45

// register the autoloader function above
zYne's avatar
zYne committed
46
spl_autoload_register('autoload');
47

zYne's avatar
zYne committed
48
require_once dirname(__FILE__) . '/../models/location.php';
pookey's avatar
pookey committed
49
require_once dirname(__FILE__) . '/classes.php';
zYne's avatar
zYne committed
50 51 52
require_once dirname(__FILE__) . '/../vendor/simpletest/unit_tester.php';
require_once dirname(__FILE__) . '/../vendor/simpletest/reporter.php';

pookey's avatar
pookey committed
53 54
require_once dirname(__FILE__) . '/UnitTestCase.php';
require_once dirname(__FILE__) . '/DriverTestCase.php';
zYne's avatar
zYne committed
55

zYne's avatar
zYne committed
56
error_reporting(E_ALL);
zYne's avatar
zYne committed
57

zYne's avatar
zYne committed
58
$test = new GroupTest('Doctrine Framework Unit Tests');
zYne's avatar
zYne committed
59

zYne's avatar
zYne committed
60 61


zYne's avatar
zYne committed
62
// DATABASE ABSTRACTION tests
zYne's avatar
zYne committed
63

zYne's avatar
zYne committed
64
// Connection drivers (not yet fully tested)
zYne's avatar
zYne committed
65 66 67
$test->addTestCase(new Doctrine_Connection_Pgsql_TestCase());
$test->addTestCase(new Doctrine_Connection_Oracle_TestCase());
$test->addTestCase(new Doctrine_Connection_Sqlite_TestCase());
zYne's avatar
zYne committed
68 69 70 71
$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());
zYne's avatar
zYne committed
72

zYne's avatar
zYne committed
73 74 75 76 77 78 79 80 81
// 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());
82

zYne's avatar
zYne committed
83 84 85 86 87 88 89 90 91 92
// 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());

zYne's avatar
zYne committed
93 94
// Sequence module (not yet fully tested)
$test->addTestCase(new Doctrine_Sequence_TestCase());
zYne's avatar
zYne committed
95 96 97 98 99 100 101
$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());
zYne's avatar
zYne committed
102

zYne's avatar
zYne committed
103
// Export module (not yet fully tested)
zYne's avatar
zYne committed
104

zYne's avatar
zYne committed
105

zYne's avatar
zYne committed
106
//$test->addTestCase(new Doctrine_Export_Reporter_TestCase());
zYne's avatar
zYne committed
107 108
$test->addTestCase(new Doctrine_Export_Firebird_TestCase());
$test->addTestCase(new Doctrine_Export_Informix_TestCase());
zYne's avatar
zYne committed
109
$test->addTestCase(new Doctrine_Export_TestCase());
zYne's avatar
zYne committed
110 111 112 113
$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());
zYne's avatar
zYne committed
114

zYne's avatar
zYne committed
115
$test->addTestCase(new Doctrine_Export_Mysql_TestCase());
zYne's avatar
zYne committed
116

zYne's avatar
zYne committed
117 118
$test->addTestCase(new Doctrine_CascadingDelete_TestCase());

zYne's avatar
zYne committed
119
// Import module (not yet fully tested)
zYne's avatar
zYne committed
120
//$test->addTestCase(new Doctrine_Import_TestCase());
121 122 123 124 125 126 127
$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());
zYne's avatar
zYne committed
128

zYne's avatar
zYne committed
129

zYne's avatar
zYne committed
130
// Expression module (not yet fully tested)
zYne's avatar
zYne committed
131 132 133 134 135 136 137 138 139 140 141 142 143
$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());
zYne's avatar
zYne committed
144

zYne's avatar
zYne committed
145 146 147
$test->addTestCase(new Doctrine_Manager_TestCase());
$test->addTestCase(new Doctrine_Connection_TestCase());
$test->addTestCase(new Doctrine_Table_TestCase());
zYne's avatar
zYne committed
148

zYne's avatar
zYne committed
149

zYne's avatar
zYne committed
150 151
$test->addTestCase(new Doctrine_UnitOfWork_TestCase());
$test->addTestCase(new Doctrine_Connection_Transaction_TestCase());
zYne's avatar
zYne committed
152

zYne's avatar
zYne committed
153
$test->addTestCase(new Doctrine_Collection_TestCase());
zYne's avatar
zYne committed
154
// Relation handling
zYne's avatar
zYne committed
155 156

$test->addTestCase(new Doctrine_TreeStructure_TestCase());
zYne's avatar
zYne committed
157
$test->addTestCase(new Doctrine_Relation_TestCase());
zYne's avatar
zYne committed
158

zYne's avatar
zYne committed
159
$test->addTestCase(new Doctrine_Relation_Access_TestCase());
zYne's avatar
zYne committed
160
$test->addTestCase(new Doctrine_Relation_ManyToMany_TestCase());
zYne's avatar
zYne committed
161 162
$test->addTestCase(new Doctrine_Relation_OneToOne_TestCase());

zYne's avatar
zYne committed
163 164 165
// Datatypes
$test->addTestCase(new Doctrine_Enum_TestCase());
$test->addTestCase(new Doctrine_Boolean_TestCase());
166 167


zYne's avatar
zYne committed
168
// Utility components
zYne's avatar
zYne committed
169

zYne's avatar
zYne committed
170
$test->addTestCase(new Doctrine_PessimisticLocking_TestCase());
zYne's avatar
zYne committed
171

zYne's avatar
zYne committed
172 173
$test->addTestCase(new Doctrine_RawSql_TestCase());
$test->addTestCase(new Doctrine_View_TestCase());
zYne's avatar
zYne committed
174

zYne's avatar
zYne committed
175
$test->addTestCase(new Doctrine_Validator_TestCase());
176

zYne's avatar
zYne committed
177
$test->addTestCase(new Doctrine_Hook_TestCase());
178

zYne's avatar
zYne committed
179
// Db component
zYne's avatar
zYne committed
180
$test->addTestCase(new Doctrine_Db_TestCase());
181 182
$test->addTestCase(new Doctrine_Db_Profiler_TestCase());

183

zYne's avatar
zYne committed
184 185 186 187
// Eventlisteners
$test->addTestCase(new Doctrine_EventListener_TestCase());
$test->addTestCase(new Doctrine_EventListener_Chain_TestCase());

zYne's avatar
zYne committed
188
// Record
189
$test->addTestCase(new Doctrine_Record_TestCase());
190
$test->addTestCase(new Doctrine_Record_State_TestCase());
zYne's avatar
zYne committed
191
//$test->addTestCase(new Doctrine_Record_Filter_TestCase());
zYne's avatar
zYne committed
192

zYne's avatar
zYne committed
193
// Old test cases (should be removed)
zYne's avatar
zYne committed
194

zYne's avatar
zYne committed
195 196
$test->addTestCase(new Doctrine_SchemaTestCase());
$test->addTestCase(new Doctrine_BatchIterator_TestCase());
zYne's avatar
zYne committed
197 198
$test->addTestCase(new Doctrine_Query_Condition_TestCase());

zYne's avatar
zYne committed
199
$test->addTestCase(new Doctrine_CustomPrimaryKey_TestCase());
200
$test->addTestCase(new Doctrine_CustomResultSetOrderTestCase());
zYne's avatar
zYne committed
201
//$test->addTestCase(new Doctrine_Collection_Offset_TestCase());
202

zYne's avatar
zYne committed
203

zYne's avatar
zYne committed
204
// Query tests
205
$test->addTestCase(new Doctrine_Query_MultiJoin_TestCase());
zYne's avatar
zYne committed
206

207
$test->addTestCase(new Doctrine_Query_ReferenceModel_TestCase());
zYne's avatar
zYne committed
208

209
$test->addTestCase(new Doctrine_Query_ComponentAlias_TestCase());
zYne's avatar
zYne committed
210

zYne's avatar
zYne committed
211
$test->addTestCase(new Doctrine_Query_TestCase());
zYne's avatar
zYne committed
212
$test->addTestCase(new Doctrine_Query_ShortAliases_TestCase());
zYne's avatar
zYne committed
213
$test->addTestCase(new Doctrine_Query_Delete_TestCase());
214
$test->addTestCase(new Doctrine_Query_Where_TestCase());
215
$test->addTestCase(new Doctrine_Query_Limit_TestCase());
216
$test->addTestCase(new Doctrine_Query_IdentifierQuoting_TestCase());
zYne's avatar
zYne committed
217 218 219
$test->addTestCase(new Doctrine_Query_Update_TestCase());
$test->addTestCase(new Doctrine_Query_AggregateValue_TestCase());
$test->addTestCase(new Doctrine_Query_Select_TestCase());
zYne's avatar
zYne committed
220 221
$test->addTestCase(new Doctrine_Query_Expression_TestCase());
$test->addTestCase(new Doctrine_Query_Having_TestCase());
zYne's avatar
zYne committed
222

223 224
$test->addTestCase(new Doctrine_Query_From_TestCase());
$test->addTestCase(new Doctrine_Query_JoinCondition_TestCase());
zYne's avatar
zYne committed
225
$test->addTestCase(new Doctrine_ColumnAlias_TestCase());
226
$test->addTestCase(new Doctrine_ColumnAggregationInheritance_TestCase());
zYne's avatar
zYne committed
227 228


zYne's avatar
zYne committed
229 230 231

$test->addTestCase(new Doctrine_Query_Join_TestCase());

zYne's avatar
zYne committed
232
$test->addTestCase(new Doctrine_Query_Orderby_TestCase());
zYne's avatar
zYne committed
233

zYne's avatar
zYne committed
234 235 236 237
$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());
zYne's avatar
zYne committed
238

zYne's avatar
zYne committed
239
$test->addTestCase(new Doctrine_Query_Check_TestCase());
240

zYne's avatar
zYne committed
241 242 243
$test->addTestCase(new Doctrine_Query_Subquery_TestCase());


zYne's avatar
zYne committed
244
// Cache tests
245
//$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
246 247 248
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase());

249

250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
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);
}

?>
<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>&nbsp;</td>
  <td><input type="submit" name="submit" /></td>
</tr>
</table>
</form>
<h3>Tests</h3>
<pre>
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
<?php

    ob_start();
    if (isset($_POST))
    {
        $dsn        = isset($_POST["dsn"])?$_POST["dsn"]:null;
        $username   = isset($_POST["username"])?$_POST["username"]:null;
        $password   = isset($_POST["password"])?$_POST["password"]:null;
    }
    $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";
    }

}
*/
?>
338 339 340 341 342 343 344 345 346
<?php echo $output; ?>
</pre>
<h3>Queries</h3>
<pre>

</pre>
</body>
</html>