Browse Source

Added test for add datastream form.

pull/6/head^2
Alexander O'Neill 14 years ago
parent
commit
ddf9d821c3
  1. 12
      ConnectionHelper.inc
  2. 1
      plugins/ShowStreamsInFieldSets.inc
  3. 34
      tests/fedora_repository.test

12
ConnectionHelper.inc

@ -15,15 +15,10 @@ class ConnectionHelper {
}
function _fixURL($url, $_name, $_pass) {
if ($url == NULL) {
if (empty($url)) {
$url=variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl');
}
if ($_name == '' || $_pass == '') {
drupal_set_message(t('No credentials provided.'));
return NULL;
}
$creds = urlencode($_name) . ':'. urlencode($_pass);
if (strpos($url, 'http://') == 0) {
@ -36,14 +31,15 @@ class ConnectionHelper {
drupal_set_message(t('Invalid URL: !url', array('!url' => $url)));
return NULL;
}
return $new_url;
}
function getSoapClient($url = NULL, $exceptions = TRUE) {
if ($url == NULL) {
if (empty($url)) {
$url=variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl');
}
global $user;
if ($user->uid == 0) {
//anonymous user. We will need an entry in the fedora users.xml file

1
plugins/ShowStreamsInFieldSets.inc

@ -57,7 +57,6 @@ class ShowStreamsInFieldSets {
*/
function showPDFPreview() {
global $base_url;
$tabset = array();
$tabset['my_tabset'] = array(

34
tests/fedora_repository.test

@ -16,7 +16,7 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase {
}
function setUp() {
parent::setUp('fedora_repository');
parent::setUp('fedora_repository', 'tabs');
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
@ -26,13 +26,41 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase {
'edit tags datastream',
'ingest new fedora objects',
'purge objects and datastreams',
'view fedora collection'));
'view fedora collection',
'view detailed list of content'));
$this->drupalLogin($repository_user);
}
public function testDatastreams() {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$pid_list = array();
// Test Add datastream form
$cm_item = fedora_item::ingest_new_item();
$cm_item->add_relationship('hasModel', 'fedora-system:ContentModel-3.0', FEDORA_MODEL_URI);
$cm_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository').'/content_models/STRICT_PDFCM.xml', 'ISLANDORACM');
$pids_list[] = $cm_item->pid;
// Ingest a new PDF object
$pdf_item = fedora_item::ingest_new_item();
$pdf_item->add_relationship('hasModel', $cm_item->pid, FEDORA_MODEL_URI);
$pids_list[] = $pdf_item->pid;
// Submit the add datastream form.
$add_stream_form = array();
$add_stream_form['pid'] = $pdf_item->pid;
$add_stream_form['stream_label'] = $this->randomName(20);
$rpath = realpath(drupal_get_path('module', 'fedora_repository') . '/tests/test_files/lorem_ipsum.pdf');
$add_stream_form['files[add-stream-file-location]'] = $rpath;
$this->drupalPost('fedora/repository/' . $pdf_item->pid, $add_stream_form, 'Add Datastream');
$this->outputScreenContents();
// Test replace datastream form
}
/**
* Add an item based on a content model. Initially we will assume that the repository
* will be populated with the default content models and collections that are
@ -115,7 +143,7 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase {
return $matches[1];
}
private function outputScreenContents($description, $basename) {
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)) {

Loading…
Cancel
Save