Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
- index 5c39cfc..6617ae4 100644
- --- a/modules/simpletest/drupal_web_test_case.php
- +++ b/modules/simpletest/drupal_web_test_case.php
- @@ -82,6 +82,29 @@ abstract class DrupalTestCase {
- public function __construct($test_id = NULL) {
- $this->testId = $test_id;
- }
- +
- + /**
- + * Check for access to the test.
- + */
- + public function checkRequirements() {
- + $class = get_class($this);
- + $errors = array();
- + if (method_exists($class, 'getInfo')) {
- + $info = call_user_func(array($class, 'getInfo'));
- + // If this test class requires a non-existing module, skip it.
- + if (!empty($info['dependencies'])) {
- + foreach ($info['dependencies'] as $module) {
- + if (!drupal_get_filename('module', $module)) {
- + $errors[] = t('Missing dependency: '. $module);
- + }
- + }
- + }
- + }
- + if (count($errors) > 0) {
- + return array('errors' => $errors);
- + }
- + return TRUE;
- + }
- /**
- * Internal helper: stores the assert.
- @@ -461,29 +484,43 @@ abstract class DrupalTestCase {
- if ($methods) {
- $class_methods = array_intersect($class_methods, $methods);
- }
- - foreach ($class_methods as $method) {
- - // If the current method starts with "test", run it - it's a test.
- - if (strtolower(substr($method, 0, 4)) == 'test') {
- - // Insert a fail record. This will be deleted on completion to ensure
- - // that testing completed.
- - $method_info = new ReflectionMethod($class, $method);
- - $caller = array(
- - 'file' => $method_info->getFileName(),
- - 'line' => $method_info->getStartLine(),
- - 'function' => $class . '->' . $method . '()',
- - );
- - $completion_check_id = DrupalTestCase::insertAssert($this->testId, $class, FALSE, t('The test did not complete due to a fatal error.'), 'Completion check', $caller);
- - $this->setUp();
- - try {
- - $this->$method();
- - // Finish up.
- - }
- - catch (Exception $e) {
- - $this->exceptionHandler($e);
- + $access = $this->checkRequirements();
- + if ($access !== TRUE && isset($access['errors']) && count($access['errors']) > 0) {
- + $error_object = new ReflectionObject($this);
- + $caller = array(
- + 'file' => $error_object->getFileName(),
- + 'line' => 0,
- + 'function' => 'n/a',
- + );
- + foreach ($access['errors'] as $error) {
- + DrupalTestCase::insertAssert($this->testId, $class, FALSE, $error, 'Requirements check', $caller);
- + }
- + }
- + else {
- + foreach ($class_methods as $method) {
- + // If the current method starts with "test", run it - it's a test.
- + if (strtolower(substr($method, 0, 4)) == 'test') {
- + // Insert a fail record. This will be deleted on completion to ensure
- + // that testing completed.
- + $method_info = new ReflectionMethod($class, $method);
- + $caller = array(
- + 'file' => $method_info->getFileName(),
- + 'line' => $method_info->getStartLine(),
- + 'function' => $class . '->' . $method . '()',
- + );
- + $completion_check_id = DrupalTestCase::insertAssert($this->testId, $class, FALSE, t('The test did not complete due to a fatal error.'), 'Completion check', $caller);
- + $this->setUp();
- + try {
- + $this->$method();
- + // Finish up.
- + }
- + catch (Exception $e) {
- + $this->exceptionHandler($e);
- + }
- + $this->tearDown();
- + // Remove the completion check record.
- + DrupalTestCase::deleteAssert($completion_check_id);
- }
- - $this->tearDown();
- - // Remove the completion check record.
- - DrupalTestCase::deleteAssert($completion_check_id);
- }
- }
- // Clear out the error messages and restore error handler.
- diff --git a/modules/simpletest/simpletest.module b/modules/simpletest/simpletest.module
- index ede9ac6..ce93ab4 100644
- --- a/modules/simpletest/simpletest.module
- +++ b/modules/simpletest/simpletest.module
- @@ -326,15 +326,6 @@ function simpletest_test_get_all() {
- if (class_exists($class) && method_exists($class, 'getInfo')) {
- $info = call_user_func(array($class, 'getInfo'));
- - // If this test class requires a non-existing module, skip it.
- - if (!empty($info['dependencies'])) {
- - foreach ($info['dependencies'] as $module) {
- - if (!drupal_get_filename('module', $module)) {
- - continue 2;
- - }
- - }
- - }
- -
- $groups[$info['group']][$class] = $info;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement