| 1 |
<?php |
<?php |
| 2 |
// $Id: simpletest.module,v 1.51.2.3 2009/11/09 22:51:35 boombatower Exp $ |
// $Id: simpletest.module,v 1.51.2.4 2009/11/10 02:30:08 boombatower Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 336 |
} |
} |
| 337 |
else { |
else { |
| 338 |
// Select all clases in files ending with .test. |
// Select all clases in files ending with .test. |
| 339 |
$classes = db_query("SELECT r.name, r.module, s.info |
$classes = db_query("SELECT name FROM {registry} WHERE type = :type AND filename LIKE :name", array(':type' => 'class', ':name' => '%.test')); |
|
FROM {registry} r |
|
|
JOIN {system} s |
|
|
ON r.module = s.name |
|
|
WHERE r.type = :type |
|
|
AND r.filename LIKE :name", array(':type' => 'class', ':name' => '%.test')); |
|
| 340 |
|
|
| 341 |
// Check that each class has a getInfo() method and store the information |
// Check that each class has a getInfo() method and store the information |
| 342 |
// in an array keyed with the group specified in the test information. |
// in an array keyed with the group specified in the test information. |
| 343 |
$groups = array(); |
$groups = array(); |
| 344 |
foreach ($classes as $class) { |
foreach ($classes as $class) { |
|
if (!simpletest_test_get_all_api_check($class->module, $class->info)) { |
|
|
continue; |
|
|
} |
|
|
|
|
| 345 |
$class = $class->name; |
$class = $class->name; |
| 346 |
// Test classes need to implement getInfo() to be valid. |
// Test classes need to implement getInfo() to be valid. |
| 347 |
if (class_exists($class) && method_exists($class, 'getInfo')) { |
if (class_exists($class) && method_exists($class, 'getInfo')) { |
| 373 |
} |
} |
| 374 |
|
|
| 375 |
/** |
/** |
|
* Ensure that tests provided by this module follow the 2.x testing API. |
|
|
* |
|
|
* @param $module |
|
|
* Module name. |
|
|
* @param $info |
|
|
* Serialized module info. |
|
|
* @return |
|
|
* TRUE if module provided 2.x compatible tests, otherwise FALSE. |
|
|
*/ |
|
|
function simpletest_test_get_all_api_check($module, $info) { |
|
|
static $modules = array(); |
|
|
|
|
|
if (!isset($modules[$module])) { |
|
|
$info = unserialize($info); |
|
|
$modules[$module] = !empty($info['testing_api']) && $info['testing_api'] == '2.x'; |
|
|
} |
|
|
|
|
|
return $modules[$module]; |
|
|
} |
|
|
|
|
|
/** |
|
| 376 |
* Implementation of hook_registry_files_alter(). |
* Implementation of hook_registry_files_alter(). |
| 377 |
* |
* |
| 378 |
* Add the test files for disabled modules so that we get a list containing |
* Add the test files for disabled modules so that we get a list containing |
| 380 |
*/ |
*/ |
| 381 |
function simpletest_registry_files_alter(&$files, $modules) { |
function simpletest_registry_files_alter(&$files, $modules) { |
| 382 |
foreach ($modules as $module) { |
foreach ($modules as $module) { |
| 383 |
|
if (empty($module->info['files'])) { |
| 384 |
|
continue; |
| 385 |
|
} |
| 386 |
|
|
| 387 |
|
$dir = $module->dir; |
| 388 |
|
|
| 389 |
// Only add test files for disabled modules, as enabled modules should |
// Only add test files for disabled modules, as enabled modules should |
| 390 |
// already include any test files they provide. |
// already include any test files they provide. |
| 391 |
if (!$module->status) { |
if (!empty($module->info['testing_api']) && $module->info['testing_api'] == '2.x') { |
| 392 |
$dir = $module->dir; |
if (!$module->status) { |
|
if (!empty($module->info['files'])) { |
|
| 393 |
foreach ($module->info['files'] as $file) { |
foreach ($module->info['files'] as $file) { |
| 394 |
if (substr($file, -5) == '.test') { |
if (substr($file, -5) == '.test') { |
| 395 |
$files["$dir/$file"] = array('module' => $module->name, 'weight' => $module->weight); |
$files["$dir/$file"] = array('module' => $module->name, 'weight' => $module->weight); |
| 397 |
} |
} |
| 398 |
} |
} |
| 399 |
} |
} |
| 400 |
|
else { |
| 401 |
|
// Remove non 2.x compatible test. |
| 402 |
|
foreach ($module->info['files'] as $file) { |
| 403 |
|
if (substr($file, -5) == '.test') { |
| 404 |
|
unset($files["$dir/$file"]); |
| 405 |
|
} |
| 406 |
|
} |
| 407 |
|
} |
| 408 |
} |
} |
| 409 |
} |
} |
| 410 |
|
|