Browse Source

forgot you can't just run the parent run()

pull/549/head
qadan 10 years ago
parent
commit
5ee6594307
  1. 26
      islandora.module
  2. 66
      tests/includes/islandora_web_test_case.inc

26
islandora.module

@ -1768,7 +1768,7 @@ function islandora_form_simpletest_test_form_alter(array &$form) {
module_load_include('inc', 'simpletest', 'simpletest.pages');
module_load_include('inc', 'islandora', 'tests/includes/test_utility_abstraction');
$configuration = IslandoraTestUtilityClass::getTestConfiguration();
$filter_path = $configuration['drupal_filter_file'];
$filter_path = variable_get('islandora_simpletest_drupal_filter_path', $configuration['drupal_filter_file']);
$filter_status = is_writable($filter_path);
if ($filter_status) {
$filter_status_message = theme_image(array('path' => 'misc/watchdog-ok.png', 'attributes' => array())) . " ";
@ -1778,7 +1778,7 @@ function islandora_form_simpletest_test_form_alter(array &$form) {
}
else {
$filter_status_message = theme_image(array('path' => 'misc/watchdog-error.png', 'attributes' => array())) . " ";
$filter_status_message .= t("Drupal filter at <b>!filter_path</b> is not writable by the server. Tests relying on the filter will be disabled. Please make sure your webserver has permission to write to the Drupal filter. If the path given is incorrect, you will need to change the drupal_filter_file entry in the Islandora module's tests/test_config.ini or tests/default.test_config.ini file.", array(
$filter_status_message .= t("Drupal filter at <b>!filter_path</b> is not writable by the server. Please make sure your webserver has permission to write to the Drupal filter. If the path given is incorrect, try setting the correct path in the test settings to see if this error is no longer present.", array(
'!filter_path' => $filter_path,
));
}
@ -1808,7 +1808,7 @@ function islandora_form_simpletest_test_form_alter(array &$form) {
'#title' => filter_xss($info['name']),
'#description' => filter_xss($info['description']),
);
if (is_subclass_of($class, 'IslandoraWebTestCase') && !$filter_status) {
if (get_parent_class($class) === 'IslandoraWebTestCase' && !$filter_path) {
$form['tests']['table'][$group][$class]['#disabled'] = TRUE;
}
}
@ -1834,6 +1834,26 @@ function islandora_form_simpletest_test_form_alter(array &$form) {
);
}
/**
* Implements hook_form_alter().
*/
function islandora_form_simpletest_settings_form_alter(&$form, &$form_state) {
module_load_include('inc', 'islandora', 'tests/includes/test_utility_abstraction');
$configuration = IslandoraTestUtilityClass::getTestConfiguration();
$form['islandora_drupal_filter'] = array(
'#type' => 'fieldset',
'#title' => t('Islandora Drupal Filter Location'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
);
$form['islandora_drupal_filter']['islandora_simpletest_drupal_filter_path'] = array(
'#type' => 'textfield',
'#title' => t('Path to the Drupal Filter'),
'#description' => t('The absolute path on the server to the Drupal filter XML file in the Fedora configuration. NOTE: This is simply used to populate the at-a-glance "is the Filter writeable" notice on the top of the list of tests, and DOES NOT actually have any bearing on its function within Islandora.'),
'#default_value' => variable_get('islandora_simpletest_drupal_filter_path', $configuration['drupal_filter_file']),
);
}
/**
* Submit handler for islandora_form_simpletest_test_form_alter().
*/

66
tests/includes/islandora_web_test_case.inc

@ -21,6 +21,17 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
*/
protected $deleteObjectsOnTeardown = TRUE;
/**
* Instantiates an IslandoraWebTestCase with a configuration.
*
* @throws Exception
* If the required test config file is not found.
*/
public function __construct($test_id = NULL) {
$this->configuration = IslandoraTestUtilityClass::getTestConfiguration();
parent::__construct($test_id);
}
/**
* Defers to IslandoraTestUtilities for missing methods.
*
@ -28,6 +39,9 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
* The method being called.
* @param array $args
* The arguments for that method.
*
* @return bool
* TRUE if the result was a pass, or FALSE otherwise.
*/
public function __call($method, $args) {
module_load_include('inc', 'islandora', 'tests/includes/utilities');
@ -66,10 +80,50 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
* @see DrupalWebTestCase::run()
*/
public function run(array $methods = array()) {
$this->configuration = IslandoraTestUtilityClass::getTestConfiguration();
// Determine if the Drupal filter is writable so we know if we can proceed.
if (is_writable($this->configuration['drupal_filter_file'])) {
parent::run($methods);
// Set up the SimpleTest environment.
simpletest_verbose(NULL, variable_get('file_public_path', conf_path() . '/files'), get_class($this));
$this->httpauth_method = variable_get('simpletest_httpauth_method', CURLAUTH_BASIC);
$username = variable_get('simpletest_httpauth_username', NULL);
$password = variable_get('simpletest_httpauth_password', NULL);
if ($username && $password) {
$this->httpauth_credentials = $username . ':' . $password;
}
set_error_handler(array($this, 'errorHandler'));
$class = get_class($this);
// Iterate through all the methods in this class, unless a specific list of
// methods to run was passed.
$class_methods = get_class_methods($class);
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);
try {
$this->setUp();
$this->$method();
}
catch (Exception $e) {
$this->exceptionHandler($e);
}
$this->tearDown();
// Remove the completion check record.
DrupalTestCase::deleteAssert($completion_check_id);
}
}
}
// If the Drupal filter is not writable, skip testing and error out.
else {
$method_info = new ReflectionMethod($this, 'run');
$class = get_class($this);
@ -80,9 +134,9 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
'function' => $class . '->run()',
);
$this->assert(FALSE, "Unable to proceed; the Drupal filter is not writable by the server.", "Completion check", $caller);
drupal_get_messages();
restore_error_handler();
}
drupal_get_messages();
restore_error_handler();
}
/**
@ -169,7 +223,6 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
islandora_repair_drupal_filter();
}
unset($this->admin);
unset($this->configuration);
parent::tearDown();
}
@ -205,6 +258,9 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
* The label of the first 'Delete' button
* @param bool $safety
* If TRUE, this will only delete objects owned by users in $this->users.
*
* @return bool
* If the deletion fails, return FALSE TRUE, this will only delete objects owned by users in $this->users.
*/
public function deleteObject($pid, $button = NULL, $safety = TRUE) {
$object = islandora_object_load($pid);

Loading…
Cancel
Save