Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
266 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<?php | ||
// $Id$ | ||
|
||
/* | ||
* Tests the functions of the Fedora Repository module. | ||
*/ | ||
|
||
class FedoraBookTestCase extends DrupalWebTestCase { | ||
|
||
public static function getInfo() { | ||
return array( | ||
'name' => 'Fedora Book', | ||
'description' => t('The Fedora repository book content model.'), | ||
'group' => t('fedora repository'), | ||
); | ||
} | ||
|
||
function setUp() { | ||
parent::setUp('fedora_repository', 'fedora_ilives', 'tabs'); | ||
|
||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); | ||
|
||
// Create and login user. | ||
$repository_user = $this->drupalCreateFedoraUser(array('add fedora datastreams', | ||
'edit fedora meta data', | ||
'edit tags datastream', | ||
'ingest new fedora objects', | ||
'purge objects and datastreams', | ||
'view fedora collection', | ||
'view detailed list of content')); | ||
|
||
|
||
$this->drupalLogin($repository_user); | ||
|
||
} | ||
|
||
public function testBookCModel() { | ||
// First add a book collection | ||
|
||
$pid_list = array(); | ||
// Create a collection for ingesting book content model objects. | ||
|
||
$ingest_form = array(); | ||
$ingest_form['models'] = 'islandora:collectionCModel/ISLANDORACM'; | ||
|
||
$this->drupalPost('fedora/ingestObject/islandora:top/Islandora%20Top-Level%20Collection', $ingest_form, 'Next'); | ||
|
||
$ingest_title = $this->randomName(32); | ||
$ingest_form_step_2['dc:title'] = $ingest_title; | ||
$ingest_form_step_2['dc:description'] = $this->randomName(256); | ||
$ingest_form_step_2['files[ingest-file-location]'] = realpath(drupal_get_path('module', 'fedora_ilives') . '/xml/book_collection_policy.xml'); | ||
$this->drupalPost(NULL, $ingest_form_step_2, 'Ingest'); | ||
$this->assertPattern('/Item .* created successfully./', "Verified item created."); | ||
|
||
$pid = $this->getIngestedPid(); | ||
$this->drupalGet("fedora/repository/$pid"); | ||
$pid_list[] = $pid; | ||
|
||
// Now add a book into the new collection | ||
$this->pass("Create book collection $pid below top-level collection.", 'fedora book'); | ||
$ingest_book_form = array(); | ||
$ingest_book_form['models'] = 'ilives:bookCModel/ISLANDORACM'; | ||
$this->drupalPost("fedora/ingestObject/$pid/", $ingest_book_form, 'Next'); | ||
$ingest_book_form_step_2 = array(); | ||
|
||
$ingest_book_form_step_2['mods[mods_record]'] = file_get_contents(drupal_get_path('module', 'fedora_ilives') . '/tests/test_files/mods_record.xml'); | ||
$this->outputScreenContents(); | ||
$this->drupalPost(NULL, $ingest_book_form_step_2, 'Ingest'); | ||
$this->outputScreenContents(); | ||
$book_pid = $this->getIngestedPid(); | ||
$pid_list[] = $book_pid; | ||
if (!empty($book_pid)) { | ||
$this->pass("Successfully ingested book object $book_pid."); | ||
} | ||
$this->cleanUpRepository($pid_list); | ||
|
||
} | ||
|
||
private function cleanUpRepository($pid_list = array()) { | ||
$this->pass("This is the PID list to purge: ". implode(", ", $pid_list) ); | ||
foreach ($pid_list as $pid) { | ||
$this->drupalPost("fedora/repository/purgeObject/$pid", array(), 'Purge'); | ||
$this->drupalPost(NULL, array(), 'Delete'); | ||
} | ||
} | ||
|
||
private function getIngestedPid() { | ||
$subject = $this->drupalGetContent(); | ||
$pattern = '/">(.*)<\/a> created successfully./'; | ||
$matches = array(); | ||
$res = preg_match($pattern, $subject, $matches); | ||
return $matches[1]; | ||
} | ||
|
||
private function outputScreenContents($description = '', $basename = '') { | ||
// This is a hack to get a directory that won't be cleaned up by SimpleTest. | ||
$file_dir = file_directory_path() . '../simpletest_output_pages'; | ||
if (!is_dir($file_dir)) { | ||
mkdir($file_dir, 0777, TRUE); | ||
} | ||
$output_path = "$file_dir/$basename.". $this->randomName(10) . '.html'; | ||
$rv = file_put_contents($output_path, $this->drupalGetContent()); | ||
$this->pass("$description: Contents of result page are ". l('here', $output_path)); | ||
} | ||
|
||
protected function drupalCreateFedoraUser($permissions = array('access comments', 'access content', 'post comments', 'post comments without approval')) { | ||
// Create a role with the given permission set. | ||
if (!($rid = $this->drupalCreateRole($permissions))) { | ||
return FALSE; | ||
} | ||
|
||
// Create a user assigned to that role. | ||
$edit = array(); | ||
$edit['name'] = 'simpletestuser'; | ||
$edit['mail'] = $edit['name'] . '@example.com'; | ||
$edit['roles'] = array($rid => $rid); | ||
$edit['pass'] = 'simpletestpass'; | ||
$edit['status'] = 1; | ||
|
||
$account = user_save('', $edit); | ||
|
||
$this->assertTrue(!empty($account->uid), t('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass'])), t('User login')); | ||
if (empty($account->uid)) { | ||
return FALSE; | ||
} | ||
|
||
// Add the raw password so that we can log in as this user. | ||
$account->pass_raw = $edit['pass']; | ||
return $account; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?xml version="1.0"?> | ||
<mods:modsCollection xmlns:mods="http://www.loc.gov/mods/v3" version="3.0"> | ||
<mods:mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/mods/v3" version="3.0" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-0.xsd"> | ||
<titleInfo> | ||
<nonSort>The </nonSort> | ||
<title>amazing Maurice and his educated rodents</title> | ||
</titleInfo> | ||
<name type="personal"> | ||
<namePart>Pratchett, Terry.</namePart> | ||
<role> | ||
<roleTerm authority="marcrelator" type="text">creator</roleTerm> | ||
</role> | ||
</name> | ||
<typeOfResource>text</typeOfResource> | ||
<genre authority="marc">novel</genre> | ||
<originInfo> | ||
<place> | ||
<placeTerm type="code" authority="marccountry">enk</placeTerm> | ||
</place> | ||
<place> | ||
<placeTerm type="text">London</placeTerm> | ||
</place> | ||
<publisher>Corgi Books</publisher> | ||
<dateIssued>2002</dateIssued> | ||
<dateIssued encoding="marc">2001</dateIssued> | ||
<issuance>monographic</issuance> | ||
</originInfo> | ||
<language> | ||
<languageTerm authority="iso639-2b" type="code">eng</languageTerm> | ||
</language> | ||
<physicalDescription> | ||
<form authority="marcform">print</form> | ||
<extent>269 p. ; 22 cm.</extent> | ||
</physicalDescription> | ||
<abstract>A talking cat, intelligent rats, and a strange boy cooperate in a Pied Piper scam until they try to con the wrong town and are confronted by a deadly evil rat king.</abstract> | ||
<targetAudience authority="marctarget">juvenile</targetAudience> | ||
<note type="statement of responsibility">Terry Pratchett.</note> | ||
<note>Carnegie Medal winner.</note> | ||
<subject authority="lcsh"> | ||
<topic>Discworld (Imaginary place)</topic> | ||
<topic>Fiction</topic> | ||
</subject> | ||
<subject authority="lcsh"> | ||
<topic>Discworld (Imaginary place)</topic> | ||
<topic>Fiction</topic> | ||
</subject> | ||
<subject authority="lcsh"> | ||
<topic>Rats</topic> | ||
<topic>Fiction</topic> | ||
</subject> | ||
<subject authority="lcsh"> | ||
<topic>Cats</topic> | ||
<topic>Fiction</topic> | ||
</subject> | ||
<subject authority="lcsh"> | ||
<topic>Fantasy fiction</topic> | ||
</subject> | ||
<subject authority="lcsh"> | ||
<topic>Humorous stories</topic> | ||
</subject> | ||
<classification authority="lcc">PZ7.P8865 Am 2002</classification> | ||
<relatedItem> | ||
<titleInfo> | ||
<title>Discworld series</title> | ||
</titleInfo> | ||
<name type="personal"> | ||
<namePart>Pratchett, Terry.</namePart> | ||
</name> | ||
</relatedItem> | ||
<identifier type="isbn">006001234X (library binding)</identifier> | ||
<identifier type="isbn">0385601239</identifier> | ||
<identifier type="isbn">0552546933 (pbk.)</identifier> | ||
<recordInfo> | ||
<recordContentSource authority="marcorg">CaNWHRN</recordContentSource> | ||
<recordCreationDate encoding="marc">010730</recordCreationDate> | ||
<recordChangeDate encoding="iso8601">20020314 .0</recordChangeDate> | ||
<languageOfCataloging> | ||
<languageTerm authority="iso639-2b" type="code">eng</languageTerm> | ||
</languageOfCataloging> | ||
</recordInfo> | ||
</mods:mods> | ||
</mods:modsCollection> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<collection_policy xmlns="http://www.islandora.ca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="" xsi:schemaLocation="http://www.islandora.ca http://syn.lib.umanitoba.ca/collection_policy.xsd"> | ||
<content_models> | ||
<content_model dsid="ISLANDORACM" name="Book" namespace="islandora" pid="ilives:bookCModel"></content_model> | ||
</content_models> | ||
<search_terms> | ||
<term field="dc.title">dc.title</term> | ||
<term field="dc.creator">dc.creator</term> | ||
<term default="true" field="dc.description">dc.description</term> | ||
<term field="dc.date">dc.date</term> | ||
<term field="dc.identifier">dc.identifier</term> | ||
<term field="dc.language">dc.language</term> | ||
<term field="dc.publisher">dc.publisher</term> | ||
<term field="dc.rights">dc.rights</term> | ||
<term field="dc.subject">dc.subject</term> | ||
<term field="dc.relation">dc.relation</term> | ||
<term field="dcterms.temporal">dcterms.temporal</term> | ||
<term field="dcterms.spatial">dcterms.spatial</term> | ||
<term field="fgs.DS.first.text">Full Text</term> | ||
</search_terms> | ||
<relationship>isMemberOfCollection</relationship> | ||
</collection_policy> |