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 b2a7bf1..1c8b45f 100644
- --- a/modules/simpletest/drupal_web_test_case.php
- +++ b/modules/simpletest/drupal_web_test_case.php
- @@ -84,6 +84,13 @@ abstract class DrupalTestCase {
- }
- /**
- + * Check for access to the test.
- + */
- + public function checkRequirements() {
- + return TRUE;
- + }
- +
- + /**
- * Internal helper: stores the assert.
- *
- * @param $status
- @@ -461,29 +468,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.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement