|
|
|
@ -126,4 +126,84 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
|
|
|
|
|
unset($this->configuration); |
|
|
|
|
parent::tearDown(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Asserts that the given datastreams exist on the object. |
|
|
|
|
* |
|
|
|
|
* @param AbstractObject $object |
|
|
|
|
* The PID of the object |
|
|
|
|
* @param array $datastreams |
|
|
|
|
* An array of strings containing datastream names |
|
|
|
|
*/ |
|
|
|
|
public function assertDatastreams($object, array $datastreams) { |
|
|
|
|
if (!is_object($object)) { |
|
|
|
|
$this->fail("Failed. Object passed in is invalid."); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach ($datastreams as $datastream) { |
|
|
|
|
if (isset($object[$datastream])) { |
|
|
|
|
$this->pass("Loaded datastream {$datastream} from PID {$object->id}"); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
$this->fail("Failed to load datastream {$datastream} from PID {$object->id}"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets a tuque object from a path. |
|
|
|
|
* |
|
|
|
|
* @param string $path |
|
|
|
|
* A full or partial path to an islandora object. |
|
|
|
|
* |
|
|
|
|
* @return AbstractObject |
|
|
|
|
* The pid of the object or FALSE if a PID is not found. |
|
|
|
|
*/ |
|
|
|
|
public function getPidFromPath($path) { |
|
|
|
|
$path_parts = explode('/', $path); |
|
|
|
|
$array_length = count($path_parts); |
|
|
|
|
for ($i = 0; $i < $array_length; $i++) { |
|
|
|
|
if ($path_parts[$i] == 'islandora' && isset($path_parts[$i + 1]) && $path_parts[$i + 1] == 'object') { |
|
|
|
|
if (isset($path_parts[$i + 2])) { |
|
|
|
|
return islandora_object_load(urldecode($path_parts[$i + 2])); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$this->fail("Failed to parse path : $path."); |
|
|
|
|
return FALSE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Deletes an object using the PID. This does the deletion using the UI. |
|
|
|
|
* |
|
|
|
|
* @param string $pid |
|
|
|
|
* The PID of the collection to be deleted |
|
|
|
|
*/ |
|
|
|
|
public function deleteObject($pid) { |
|
|
|
|
$current_user = $this->loggedInUser; |
|
|
|
|
$user = $this->drupalCreateUser(array( |
|
|
|
|
'manage object properties', |
|
|
|
|
'delete fedora objects and datastreams', |
|
|
|
|
'view fedora repository objects', |
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
$this->drupalLogin($user); |
|
|
|
|
|
|
|
|
|
$path = 'islandora/object/' . $pid . '/manage/properties'; |
|
|
|
|
$edit = array(); |
|
|
|
|
$this->drupalPost($path, $edit, t('Delete')); |
|
|
|
|
$this->drupalPost($this->url, $edit, t('Delete')); |
|
|
|
|
$object = islandora_object_load($pid); |
|
|
|
|
|
|
|
|
|
$this->drupalGet("islandora/object/$pid"); |
|
|
|
|
$this->assertResponse(404, "Object $pid successfully deleted."); |
|
|
|
|
|
|
|
|
|
if ($current_user) { |
|
|
|
|
$this->drupalLogin($current_user); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
$this->drupalLogout(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |