Browse Source

moving around some stuffs

pull/507/head
qadan 11 years ago
parent
commit
1c0fa96099
  1. 1
      islandora.info
  2. 10
      islandora.module
  3. 2
      tests/includes/islandora_unit_test_case.inc
  4. 2
      tests/includes/islandora_web_test_case.inc
  5. 153
      tests/includes/test_utility_abstraction.inc
  6. 144
      tests/includes/utilities.inc
  7. 1
      tests/scripts/travis_setup.sh

1
islandora.info

@ -17,6 +17,7 @@ files[] = tests/includes/datastream_validators.inc
files[] = tests/includes/islandora_web_test_case.inc
files[] = tests/includes/islandora_unit_test_case.inc
files[] = tests/includes/utilities.inc
files[] = tests/includes/test_utility_abstraction.inc
files[] = tests/authtokens.test
files[] = tests/hooks.test
files[] = tests/ingest.test

10
islandora.module

@ -1813,13 +1813,15 @@ function islandora_form_simpletest_test_form_alter(array &$form) {
* Submit handler for islandora_form_simpletest_test_form_alter().
*/
function islandora_repair_drupal_filter() {
module_load_include('inc', 'islandora', 'tests/includes/utilities');
// Grab the config.
module_load_include('inc', 'islandora', 'tests/utilities/test_utility_abstraction');
try {
$configuration = islandora_get_test_configuration();
IslandoraTestUtilityClass::getTestConfiguration();
}
catch (Exception $e) {
drupal_set_message(t("Unable to get the test configuration: %e", array('%e' => $e)), 'error');
return;
drupal_set_message(t("Error parsing test configuration: $e"), 'error');
return FALSE;
}
// Xpath to the filter 'sql' elements.

2
tests/includes/islandora_unit_test_case.inc

@ -58,7 +58,7 @@ class IslandoraUnitTestCase extends DrupalUnitTestCase {
module_load_include('inc', 'islandora', 'includes/tuque');
module_load_include('inc', 'islandora', 'includes/tuque_wrapper');
$this->configuration = islandora_get_test_configuration();
$this->configuration = IslandoraTestUtilityClass::getTestConfiguration();
$this->connection = new RepositoryConnection($this->configuration['fedora_url'], $this->configuration['admin_user'], $this->configuration['admin_pass']);
$api = new FedoraApi($this->connection);
$this->repository = new FedoraRepository($api, new SimpleCache());

2
tests/includes/islandora_web_test_case.inc

@ -74,7 +74,7 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
module_load_include('inc', 'islandora', 'includes/tuque_wrapper');
module_load_include('inc', 'islandora', 'tests/includes/utilities');
$this->configuration = islandora_get_test_configuration();
$this->configuration = IslandoraTestUtilityClass::getTestConfiguration();
if ($this->configuration['use_drupal_filter']) {
$this->setUpDrupalFilter();
}

153
tests/includes/test_utility_abstraction.inc

@ -0,0 +1,153 @@
<?php
/**
* @file
* Abstraction n' stuff for the test utilities and results.
*/
/**
* A result from a utility method; $type defines TRUE/FALSE as pass/fail.
*/
class IslandoraTestUtilityResult {
/**
* The message for this result.
*
* @var string
*/
protected $message;
/**
* The caller for this result.
*
* @var array
*/
protected $caller;
/**
* The type of result this is - TRUE for pass, FALSE for fail.
*
* @var bool
*/
protected $type;
/**
* Constructs an IslandoraTestUtilityResult.
*
* @param bool $type
* Whether this result should indicate a pass (TRUE) or fail (FALSE).
* @param string $message
* The message that will be used by this result.
* @param array $caller
* The caller for this result.
*/
public function __construct($type, $message, array $caller) {
$this->message = $message;
$this->caller = $caller;
$this->type = $type;
}
/**
* Get the message for this result.
*
* @return string
* The message for this result.
*/
public function getMessage() {
return $this->message;
}
/**
* Get the caller for this result.
*
* @return string
* The caller for this result.
*/
public function getCaller() {
return $this->caller;
}
/**
* Get the type of result.
*
* @return bool
* The type of pass (TRUE for pass, FALSE for fail).
*/
public function getType() {
return $this->type;
}
}
/**
* Abstraction for test utility classes.
*
* This is to be implemented in any class that wants to have test utility
* functionality (i.e. that wants to pass back results to tests). Check out the
* datastream validator class for a good example of how this is implemented.
*
* Test utility classes should store per-installation configuration options in
* a test_config.ini file, contained in the islandora/tests folder. A function
* is included with the abstraction to parse the configuration file.
*/
abstract class IslandoraTestUtilityClass {
/**
* An array of IslandoraTestUtilityResults.
*
* These should be generated using $this->addResult.
*
* @var IslandoraTestUtilityResult[]
*/
public $results = array();
/**
* Parses and returns the settings from the test configuration file.
*
* If no install specific test_config.ini file is found, it will use the
* assumed default configs found in default.test_config.ini.
*
* @return array
* The test configuration.
*
* @see parse_ini_file()
*/
public static function getTestConfiguration() {
$path = drupal_get_path('module', 'islandora');
if (file_exists("$path/tests/test_config.ini")) {
return parse_ini_file("$path/tests/test_config.ini");
}
elseif (file_exists("$path/tests/default.test_config.ini")) {
return parse_ini_file("$path/tests/default.test_config.ini");
}
throw new Exception('Required default.test_config.ini/test_config.ini file not found');
}
/**
* Returns an array of IslandoraTestUtilityResults.
*
* The particular testing implementation you are using should use this to
* parse results from utilities and pass them through.
*
* @return IslandoraTestUtilityResult[]
* The results.
*/
abstract public function getResults();
/**
* Adds a result to $this->results.
*
* @param bool $type
* The type of result (TRUE for pass, FALSE for fail).
* @param string $message
* The message to put in the result.
*/
abstract public function addResult($type, $message);
/**
* Gets the caller of the method that passed a result.
*
* @return array
* Array representing the true caller.
*/
abstract public function getAssertionCall();
}

144
tests/includes/utilities.inc

@ -13,150 +13,6 @@
* breaking existing implementations.
*/
/**
* Parses and returns the settings from the test configuration file.
*
* If no install specific test_config.ini file is found, it will use the
* assumed default configs found in default.test_config.ini.
*
* @return array
* The test configuration.
*
* @see parse_ini_file()
*/
function islandora_get_test_configuration() {
$path = drupal_get_path('module', 'islandora');
if (file_exists("$path/tests/test_config.ini")) {
return parse_ini_file("$path/tests/test_config.ini");
}
elseif (file_exists("$path/tests/default.test_config.ini")) {
return parse_ini_file("$path/tests/default.test_config.ini");
}
throw new Exception('Required default.test_config.ini/test_config.ini file not found');
}
/**
* A result from a utility method; $type defines TRUE/FALSE as pass/fail.
*/
class IslandoraTestUtilityResult {
/**
* The message for this result.
*
* @var string
*/
protected $message;
/**
* The caller for this result.
*
* @var array
*/
protected $caller;
/**
* The type of result this is - TRUE for pass, FALSE for fail.
*
* @var bool
*/
protected $type;
/**
* Constructs an IslandoraTestUtilityResult.
*
* @param bool $type
* Whether this result should indicate a pass (TRUE) or fail (FALSE).
* @param string $message
* The message that will be used by this result.
* @param array $caller
* The caller for this result.
*/
public function __construct($type, $message, array $caller) {
$this->message = $message;
$this->caller = $caller;
$this->type = $type;
}
/**
* Get the message for this result.
*
* @return string
* The message for this result.
*/
public function getMessage() {
return $this->message;
}
/**
* Get the caller for this result.
*
* @return string
* The caller for this result.
*/
public function getCaller() {
return $this->caller;
}
/**
* Get the type of result.
*
* @return bool
* The type of pass (TRUE for pass, FALSE for fail).
*/
public function getType() {
return $this->type;
}
}
/**
* Abstraction for test utility classes.
*
* This is to be implemented in any class that wants to have test utility
* functionality (i.e. that wants to pass back results to tests). Check out the
* datastream validator class for a good example of how this is implemented.
*/
abstract class IslandoraTestUtilityClass {
/**
* An array of IslandoraTestUtilityResults.
*
* These should be generated using $this->addResult.
*
* @var IslandoraTestUtilityResult[]
*/
public $results = array();
/**
* Returns an array of IslandoraTestUtilityResults.
*
* The particular testing implementation you are using should use this to
* parse results from utilities and pass them through.
*
* @return IslandoraTestUtilityResult[]
* The results.
*/
abstract public function getResults();
/**
* Adds a result to $this->results.
*
* @param bool $type
* The type of result (TRUE for pass, FALSE for fail).
* @param string $message
* The message to put in the result.
*/
abstract public function addResult($type, $message);
/**
* Gets the caller of the method that passed a result.
*
* @return array
* Array representing the true caller.
*/
abstract public function getAssertionCall();
}
class IslandoraTestUtilities extends IslandoraTestUtilityClass {
protected $configuration;

1
tests/scripts/travis_setup.sh

@ -8,6 +8,7 @@ cd $HOME
git clone git://github.com/Islandora/tuque.git
git clone -b $FEDORA_VERSION git://github.com/Islandora/islandora_tomcat.git
cd islandora_tomcat
git fsck --full --verbose
export CATALINA_HOME='.'
export JAVA_OPTS="-Xms1024m -Xmx1024m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -Djavax.net.ssl.trustStore=$CATALINA_HOME/fedora/server/truststore -Djavax.net.ssl.trustStorePassword=tomcat"
./bin/startup.sh

Loading…
Cancel
Save