Browse Source

let's just do this right

pull/549/head
qadan 10 years ago
parent
commit
0bc26560fb
  1. 27
      islandora.module
  2. 29
      tests/includes/islandora_web_test_case.inc

27
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 = variable_get('islandora_simpletest_drupal_filter_path', $configuration['drupal_filter_file']);
$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. 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_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_path' => $filter_path,
));
}
@ -1808,6 +1808,9 @@ 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) {
$form['tests']['table'][$group][$class]['#disabled'] = TRUE;
}
}
}
@ -1831,26 +1834,6 @@ 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().
*/

29
tests/includes/islandora_web_test_case.inc

@ -57,6 +57,34 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
}
}
/**
* Run all tests in this class.
*
* Attempts to figure out if the Drupal filter is writable before running any
* tests.
*
* @see DrupalWebTestCase::run()
*/
public function run(array $methods = array()) {
$this->configuration = IslandoraTestUtilityClass::getTestConfiguration();
if (is_writable($this->configuration['drupal_filter_file'])) {
parent::run($methods);
}
else {
$method_info = new ReflectionMethod($this, 'run');
$class = get_class($this);
set_error_handler(array($this, 'errorHandler'));
$caller = array(
'file' => $method_info->getFileName(),
'line' => $method_info->getStartLine(),
'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();
}
}
/**
* Sets up the web test case.
*
@ -74,7 +102,6 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
module_load_include('inc', 'islandora', 'includes/tuque_wrapper');
module_load_include('inc', 'islandora', 'tests/includes/utilities');
$this->configuration = IslandoraTestUtilityClass::getTestConfiguration();
if ($this->configuration['use_drupal_filter']) {
$this->setUpDrupalFilter();
}

Loading…
Cancel
Save