|
|
@ -112,10 +112,7 @@ class IslandoraTestUtilities extends IslandoraTestUtilityClass { |
|
|
|
* TRUE on success, FALSE on fail. |
|
|
|
* TRUE on success, FALSE on fail. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function assertDatastreams($object, array $datastreams) { |
|
|
|
public function assertDatastreams($object, array $datastreams) { |
|
|
|
if (!self::assertFedoraObject($object)) { |
|
|
|
if (self::assertFedoraObject($object)) { |
|
|
|
$this->addResult(FALSE, "Failed. Object passed in is invalid.", 'Islandora'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
$missing_datastreams = array_diff_key(array_flip($datastreams), $object->repository->api->a->listDatastreams($object->id)); |
|
|
|
$missing_datastreams = array_diff_key(array_flip($datastreams), $object->repository->api->a->listDatastreams($object->id)); |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($missing_datastreams)) { |
|
|
|
if (!empty($missing_datastreams)) { |
|
|
@ -137,8 +134,8 @@ class IslandoraTestUtilities extends IslandoraTestUtilityClass { |
|
|
|
* An array of datastreams to confirm not present. |
|
|
|
* An array of datastreams to confirm not present. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function assertNoDatastreams($object, array $datastreams) { |
|
|
|
public function assertNoDatastreams($object, array $datastreams) { |
|
|
|
if (!self::assertFedoraObject($object)) { |
|
|
|
if (self::assertFedoraObject($object, FALSE)) { |
|
|
|
$this->addResult(FALSE, "Failed. Object passed in is invalid.", 'Islandora'); |
|
|
|
$this->addResult("Failed to check the datastreams on the object; the object could not be loaded."); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
$found_datastreams = array_intersect_key(array_flip($datastreams), $object->repository->api->a->listDatastreams($object->id)); |
|
|
|
$found_datastreams = array_intersect_key(array_flip($datastreams), $object->repository->api->a->listDatastreams($object->id)); |
|
|
@ -169,8 +166,7 @@ class IslandoraTestUtilities extends IslandoraTestUtilityClass { |
|
|
|
* for examples. |
|
|
|
* for examples. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function validateDatastreams($object, array $datastreams) { |
|
|
|
public function validateDatastreams($object, array $datastreams) { |
|
|
|
|
|
|
|
if (self::assertFedoraObject($object, FALSE)) { |
|
|
|
if (!self::assertFedoraObject($object)) { |
|
|
|
|
|
|
|
$this->addResult(FALSE, "Datastream validation failed; Object passed in is invalid.", 'Islandora'); |
|
|
|
$this->addResult(FALSE, "Datastream validation failed; Object passed in is invalid.", 'Islandora'); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -347,48 +343,33 @@ QUERY; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Asserts that an object is a FedoraObject or an IslandoraFedoraObject. |
|
|
|
* Asserts a Fedora object from an object or PID, and loads it if possible. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param object $object |
|
|
|
* @param FedoraObject|string $object |
|
|
|
* The object to assess. |
|
|
|
* The object to assess, or a string to use as a PID. |
|
|
|
|
|
|
|
* @param bool $exists |
|
|
|
|
|
|
|
* Whether or not the object should exist in the repository, according to |
|
|
|
|
|
|
|
* our assertion. Defaults to TRUE. |
|
|
|
* |
|
|
|
* |
|
|
|
* @return bool |
|
|
|
* @return FedoraObject|bool |
|
|
|
* TRUE if it is either of those object types, or FALSE otherwise. |
|
|
|
* The object in question if it was a FedoraObject or loaded into one, or |
|
|
|
|
|
|
|
* FALSE otherwise. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static function assertFedoraObject($object) { |
|
|
|
public static function assertFedoraObject($object, $exists = TRUE) { |
|
|
|
return ($object instanceof FedoraObject); |
|
|
|
if ($object instanceof FedoraObject) { |
|
|
|
|
|
|
|
$this->addResult($exists, "Object loaded from $object->id is a Fedora repository object."); |
|
|
|
|
|
|
|
return $object; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
elseif (is_string($object)) { |
|
|
|
/** |
|
|
|
$loaded_object = islandora_object_load($object); |
|
|
|
* Asserts that the given PID represents a Fedora object. |
|
|
|
if ($loaded_object instanceof FedoraObject) { |
|
|
|
* |
|
|
|
$this->addResult($exists, "Successfully loaded object $object from the Fedora repository."); |
|
|
|
* @param string $pid |
|
|
|
return $loaded_object; |
|
|
|
* The PID of the object. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return bool |
|
|
|
|
|
|
|
* TRUE if the object exists in the repository; FALSE otherwise. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function assertObjectExists($pid) { |
|
|
|
|
|
|
|
$object = islandora_object_load($pid); |
|
|
|
|
|
|
|
$exists = $this->assertFedoraObject($object); |
|
|
|
|
|
|
|
$this->addResult($exists, "Object $pid exists in the repository."); |
|
|
|
|
|
|
|
return $exists; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$this->addResult($exists, "Object identified by $object was not found in the repository."); |
|
|
|
/** |
|
|
|
return FALSE; |
|
|
|
* Asserts that the given PID does not represent a Fedora object. |
|
|
|
} |
|
|
|
* |
|
|
|
$this->addResult($exists, "Object passed in was not found in the repository."); |
|
|
|
* @param string $pid |
|
|
|
return FALSE; |
|
|
|
* The PID of the object. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return bool |
|
|
|
|
|
|
|
* TRUE if the object does not exist in the repository, or FALSE otherwise. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function assertNoObjectExists($pid) { |
|
|
|
|
|
|
|
$object = islandora_object_load($pid); |
|
|
|
|
|
|
|
$exists = $this->assertFedoraObject($object); |
|
|
|
|
|
|
|
$this->addResult(!$exists, "Object $pid does not exist in the repository."); |
|
|
|
|
|
|
|
return !$exists; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|