From 1c0fa96099467e1cd157e25f0c61fd1b85b8d5eb Mon Sep 17 00:00:00 2001 From: qadan Date: Fri, 6 Jun 2014 17:37:09 +0000 Subject: [PATCH] moving around some stuffs --- islandora.info | 1 + islandora.module | 10 +- tests/includes/islandora_unit_test_case.inc | 2 +- tests/includes/islandora_web_test_case.inc | 2 +- tests/includes/test_utility_abstraction.inc | 153 ++++++++++++++++++++ tests/includes/utilities.inc | 144 ------------------ tests/scripts/travis_setup.sh | 1 + 7 files changed, 163 insertions(+), 150 deletions(-) create mode 100644 tests/includes/test_utility_abstraction.inc diff --git a/islandora.info b/islandora.info index e19f4937..55c50359 100644 --- a/islandora.info +++ b/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 diff --git a/islandora.module b/islandora.module index dbca8844..aeb2c059 100644 --- a/islandora.module +++ b/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. diff --git a/tests/includes/islandora_unit_test_case.inc b/tests/includes/islandora_unit_test_case.inc index 4cdf30bd..baffc62e 100644 --- a/tests/includes/islandora_unit_test_case.inc +++ b/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()); diff --git a/tests/includes/islandora_web_test_case.inc b/tests/includes/islandora_web_test_case.inc index 211f0df0..56645f83 100644 --- a/tests/includes/islandora_web_test_case.inc +++ b/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(); } diff --git a/tests/includes/test_utility_abstraction.inc b/tests/includes/test_utility_abstraction.inc new file mode 100644 index 00000000..aa09004b --- /dev/null +++ b/tests/includes/test_utility_abstraction.inc @@ -0,0 +1,153 @@ +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(); + +} diff --git a/tests/includes/utilities.inc b/tests/includes/utilities.inc index 28179c05..81758880 100644 --- a/tests/includes/utilities.inc +++ b/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; diff --git a/tests/scripts/travis_setup.sh b/tests/scripts/travis_setup.sh index 66061c72..56c651ab 100755 --- a/tests/scripts/travis_setup.sh +++ b/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