diff --git a/islandora.info b/islandora.info index 732143b5..0142f1ce 100644 --- a/islandora.info +++ b/islandora.info @@ -22,4 +22,5 @@ files[] = tests/islandora_manage_permissions.test files[] = tests/datastream_versions.test files[] = tests/datastream_cache.test files[] = tests/derivatives.test +files[] = tests/datastream_validator_tests.test php = 5.3 diff --git a/tests/README.md b/tests/README.md index c4a0ae1a..d68c4b82 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,4 +1,30 @@ -You can define your own configurations specific to your enviroment by copying +OVERVIEW +******** + +You can define your own configurations specific to your environment by copying default.test_config.ini to test_config.ini, making your changes in the copied file. These test need write access to the system's $FEDORA_HOME/server/config directory as well as the filter-drupal.xml file. + +DATASTREAM VALIDATION TESTS +*************************** + +The datastream validator included in the Islandora testing suite is able to +generate tests procedurally based on the files in the folder +'fixtures/datastream_validator_files'. By default, this folder is empty. +The unit tests for the validator pull the name of the file (before the +extension) and use that to instantiate the correct ______DatastreamValidator +class to test that file against (e.g. Image.jpg spins up an instance of the +ImageDatastreamValidator class and checks the results). + +You can test against multiple different encodings of the same filetype by giving +each file a different set of extensions, e.g. MP3.vbr.mp3 and MP3.sbr.mp3 both +test against the MP3 datastream validator, even though both are encoded +differently. + +For classes that require the third parameter (e.g. the TextDatastreamValidator), +place an additional name.extension.ini file in the datastream_validator_files +folder (e.g. the existing Text.txt in that folder is paired with Text.txt.ini). +This .ini file should be structured like a PHP .ini file (e.g. according to the +format used by http://http://ca1.php.net/parse_ini_file).The generated test will +parse the .ini file as an array and pass it on to the third parameter. \ No newline at end of file diff --git a/tests/datastream_validators.inc b/tests/datastream_validators.inc index b9063992..854f6db5 100644 --- a/tests/datastream_validators.inc +++ b/tests/datastream_validators.inc @@ -186,12 +186,20 @@ abstract class DatastreamValidator { * @param array $params * An extra array of parameters the validator might need. */ - public function __construct($object, $datastream, array $params = array()) { + public function __construct(IslandoraFedoraObject $object, $datastream, array $params = array()) { $this->object = $object; $this->datastream = $datastream; $this->params = $params; - $this->datastreamContent = $object[$datastream]->content; - $this->runValidators(); + if ($object[$datastream]) { + $this->datastreamContent = $object[$datastream]->content; + $this->runValidators(); + } + else { + drupal_set_message(t("Error grabbing content from datastream %datastream in object %id", 'error'), array( + '%datastream' => $datastream, + '%id' => $object->id, + )); + } } /**