Browse Source

Added simple tests

pull/105/head
Alan Stanley 14 years ago
parent
commit
0c6e56485b
  1. 61
      tests/fedora_repository.test

61
tests/fedora_repository.test

@ -1,9 +1,10 @@
<?php
// $Id$
/*
* Tests the functions of the Fedora Repository module.
*/
* Tests the functions of the Fedora Repository module.
*/
class FedoraRepositoryTestCase extends DrupalWebTestCase {
@ -28,9 +29,8 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase {
'purge objects and datastreams',
'view fedora collection'));
$this->repository_user = $repository_user;
$this->drupalLogin($repository_user);
}
/**
@ -45,7 +45,6 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase {
$pid_list = array();
// Create a collection for ingesting PDF content model objects.
//$this->drupalGet('fedora/ingestObject/islandora:top/Islandora%20Top-Level%20Collection');
$ingest_form = array();
$ingest_form['models'] = 'islandora:collectionCModel/ISLANDORACM';
@ -99,8 +98,29 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase {
$this->cleanUpRepository($pid_list);
}
public function testPidSpaceRestriction() {
// give user full permissions
$admin_tester = $this->drupalCreateUser(array('administer site configuration', 'view fedora collection'));
$this->drupalLogin($admin_tester);
//$adminRole = $this->drupalCreateRole(array('administer site configuration','view fedora collection'));
$inVal['fedora_namespace_restriction_enforced'] = TRUE;
$inVal['fedora_pids_allowed'] = 'simpletest:';
$this->drupalPost('admin/settings/fedora_repository', $inVal, 'Save configuration');
$this->assertPattern('/The configuration options have been saved./', 'The configuration options have been saved.');
$this->drupalGet('fedora/repository/demo:SmileyStuff/');
$this->assertPattern('/Access denied/', 'No access to SmileyStuff Collection');
$inVal['fedora_namespace_restriction_enforced'] = 0;
$this->drupalPost('admin/settings/fedora_repository', $inVal, 'Save configuration');
$this->assertPattern('/The configuration options have been saved./', 'The configuration options have been saved.');
$this->drupalLogin($this->repository_user);
$this->drupalGet('fedora/repository/demo:SmileyStuff/');
$this->assertPattern('/Collection of Smiley Stuff/', 'Access to SmileyStuff Collection');
}
private function cleanUpRepository($pid_list = array()) {
$this->pass("This is the PID list to purge: ". implode(", ", $pid_list) );
$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');
}
@ -120,9 +140,9 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase {
if (!is_dir($file_dir)) {
mkdir($file_dir, 0777, TRUE);
}
$output_path = "$file_dir/$basename.". $this->randomName(10) . '.html';
$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));
$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')) {
@ -150,4 +170,29 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase {
$account->pass_raw = $edit['pass'];
return $account;
}
}
class FedoraRepositoryClosedNameSpaceTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Fedora Repository with closed name space',
'description' => t('Fails if allow_open_namespace has been set to TRUE in settings.php.'),
'group' => t('fedora repository'),
);
}
function setUp() {
parent::setUp('fedora_repository');
}
function testRestrictedNamePage() {
$admin_tester = $this->drupalCreateUser(array('administer site configuration', 'view fedora collection'));
$this->drupalLogin($admin_tester);
$this->drupalGet('admin/settings/fedora_repository');
$this->assertNoText('Enforce namespace restrictions:');
}
}
Loading…
Cancel
Save