Browse Source

Finalized schema to test for in the required_fedora_objects test.

pull/192/head
Daniel Lamb 12 years ago
parent
commit
6e4c1e2a3b
  1. 32
      fedora_repository.solutionpacks.inc
  2. 3
      fedora_repository.test.inc

32
fedora_repository.solutionpacks.inc

@ -267,17 +267,43 @@ module_load_include('inc', 'fedora_repository', 'fedora_repository.test');
abstract class SolutionPackTestCase extends IslandoraTestCase {
/**
* Tests the fedora_repository_required_fedora_objects hook.
* Tests the fedora_repository_required_fedora_objects hook.
*
* Validates the schema of the array returned by the hook. The array should
* be roughly of the form:
* [
* module_name =>
* [
* 'module' => module_name,
* 'title' => module_title,
* 'objects' =>
* [
* ...
* ]
* ]
* ]
*
* Where each entry of the 'objects' sub-array should be arrays themselves,
* each containing the information needed for drupal_get_form().
*
* Note that the root key of the array is the actual module name (e.g.
* islandora_audio_sp, islandora_image_sp, etc...), not 'module_name'
*/
public function testFedoraRepositoryRequiredFedoraObjects() {
// Invoke the hook
$results = module_invoke($this->getModuleShortFormName(), 'fedora_repository_required_fedora_objects');
// Validate the schema of the returned data structure
$this->assertNotNull($results, 'A non-null result was returned from the fedora_repository_required_fedora_objects hook.');
$this->assertTrue(is_array($results), 'An array was returned from the fedora_repository_required_fedora_objects hook.');
$this->assertTrue(array_key_exists($this->getModuleShortFormName(), $results), "Returned array has top level key that is equal to the module's short form name");
$this->assertTrue(is_array($results[$this->getModuleShortFormName()]), "Value associated with top level key that is eqal to the module's short form name is an array");
$this->assertTrue(is_array($results[$this->getModuleShortFormName()]), "Value associated with top level key that is equal to the module's short form name is an array");
$this->assertTrue(array_key_exists('module', $results[$this->getModuleShortFormName()]), "Top level array has 'module' key");
$this->assertEqual($results[$this->getModuleShortFormName()]['module'], $this->getModuleShortFormName(), "Value associated with 'module' key is equal to the module's short form name");
$this->assertTrue(array_key_exists('title', $results[$this->getModuleShortFormName()]), "Top level array has 'title' key");
$this->assertTrue($results[$this->getModuleShortFormName()]['title'], "Title string is not empty");
$this->assertTrue(array_key_exists('objects', $results[$this->getModuleShortFormName()]), "Returned array has second level key equal to 'object'");
$this->assertTrue(is_array($results[$this->getModuleShortFormName()]['objects']), "Value associated with second level 'object' key is an array");
}
}

3
fedora_repository.test.inc

@ -4,8 +4,7 @@
* @file
* Generic test case to be extended to implement Islandora testing.
*/
abstract class IslandoraTestCase extends DrupalWebTestCase
{
abstract class IslandoraTestCase extends DrupalWebTestCase {
/**
* User with the rights required to perform the test

Loading…
Cancel
Save