/[drupal]/contributions/modules/simpletest/simpletest.module
ViewVC logotype

Diff of /contributions/modules/simpletest/simpletest.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.51.2.4, Tue Nov 10 02:30:08 2009 UTC revision 1.51.2.5, Tue Nov 10 03:15:50 2009 UTC
# Line 1  Line 1 
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
# Line 336  function simpletest_test_get_all() { Line 336  function simpletest_test_get_all() {
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')) {
# Line 382  function simpletest_test_get_all() { Line 373  function simpletest_test_get_all() {
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
# Line 410  function simpletest_test_get_all_api_che Line 380  function simpletest_test_get_all_api_che
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);
# Line 422  function simpletest_registry_files_alter Line 397  function simpletest_registry_files_alter
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    

Legend:
Removed from v.1.51.2.4  
changed lines
  Added in v.1.51.2.5

  ViewVC Help
Powered by ViewVC 1.1.2