Browse Source

last bit of bugfixes and cleanup

pull/507/head
qadan 10 years ago
parent
commit
fc357e6f7d
  1. 16
      includes/derivatives.inc
  2. 16
      tests/includes/datastream_validators.inc
  3. 36
      tests/includes/utilities.inc

16
includes/derivatives.inc

@ -21,6 +21,13 @@ function islandora_run_derivatives(AbstractObject $object, $dsid) {
islandora_derivative_logging($logging_results);
}
else {
$operations = islandora_do_batch_derivatives(
$object,
array(
'source_dsid' => $dsid,
)
);
if ($operations) {
batch_set(
// Title won't show for batch in a batch.
array(
@ -32,16 +39,13 @@ function islandora_run_derivatives(AbstractObject $object, $dsid) {
array('@label' => $object->label)
),
'file' => drupal_get_path('module', 'islandora') . '/includes/regenerate_derivatives.form.inc',
'operations' => islandora_do_batch_derivatives(
$object,
array(
'source_dsid' => $dsid,
)
),
'operations' => $operations,
'finished' => 'islandora_regenerate_derivative_batch_finished',
)
);
}
}
}
/**
* Kicks off derivative functions based upon hooks and conditions.

16
tests/includes/datastream_validators.inc

@ -48,7 +48,7 @@ function islandora_hex2int($hex) {
* Abstraction for datastream validators.
*
* Classes extended from DatastreamValidator don't require much to be useful.
* They accept an IslandoraFedoraObject and a DSID to perform assertions on;
* They accept a Fedora object and a DSID to perform assertions on;
* all you have to do is place a series of functions inside the extended class
* using the naming convention assertThing(); each of these functions should
* ideally assert one thing and one thing only (for simplicity's sake), and
@ -67,9 +67,9 @@ function islandora_hex2int($hex) {
abstract class DatastreamValidator extends IslandoraTestUtilityClass {
/**
* The IslandoraFedoraObject containing the datastream to test.
* The Fedora object containing the datastream to test.
*
* @var IslandoraFedoraObject
* @var IslandoraFedoraObject|FedoraObject
*/
public $object;
@ -97,14 +97,14 @@ abstract class DatastreamValidator extends IslandoraTestUtilityClass {
/**
* Constructs a DatastreamValidator.
*
* @param IslandoraFedoraObject $object
* @param IslandoraFedoraObject|FedoraObject $object
* The object to grab the datastream from.
* @param string $datastream
* The DSID of the datastream itself.
* @param array $params
* An extra array of parameters the validator might need.
*/
public function __construct(IslandoraFedoraObject $object, $datastream, array $params = array()) {
public function __construct($object, $datastream, array $params = array()) {
$this->object = $object;
$this->datastream = $datastream;
$this->params = $params;
@ -343,7 +343,7 @@ class TextDatastreamValidator extends DatastreamValidator {
/**
* Constructor override; blow up if we don't have our two values.
*/
public function __construct(IslandoraFedoraObject $object, $datastream, array $params = array()) {
public function __construct($object, $datastream, array $params = array()) {
if (count($params) < 2) {
throw new InvalidArgumentException('$params must contain at least two values to instantiate a TextDatastreamValidator.');
}
@ -386,14 +386,14 @@ class WAVDatastreamValidator extends DatastreamValidator {
/**
* We need a special constructor here to get the hex datastream content.
*
* @param IslandoraFedoraObject $object
* @param IslandoraFedoraObject|FedoraObject $object
* The object to grab the datastream from.
* @param string $datastream
* The DSID of the datastream itself.
* @param array $params
* An extra array of parameters the validator might need.
*/
public function __construct(IslandoraFedoraObject $object, $datastream, array $params = array()) {
public function __construct($object, $datastream, array $params = array()) {
parent::__construct($object, $datastream, $params);
$this->datastreamContent = bin2hex($this->datastreamContent);
}

36
tests/includes/utilities.inc

@ -261,18 +261,10 @@ class IslandoraTestUtilities extends IslandoraTestUtilityClass {
public function __construct($configuration, array $params = array()) {
$this->configuration = $configuration;
$this->params = $params;
// If we have DB access, we want to use the Islandora Tuque wrappers.
if ($params['db_access']) {
$connection = islandora_get_tuque_connection();
$this->repository = $connection->repository;
}
// Otherwise, get a generic Tuque repository.
else {
$connection = new RepositoryConnection($this->configuration['fedora_url'], $this->configuration['admin_user'], $this->configuration['admin_pass']);
$api = new FedoraApi($connection);
$this->repository = new FedoraRepository($api, new SimpleCache());
}
}
/**
* Returns an array of IslandoraTestUtilityResults.
@ -317,9 +309,9 @@ class IslandoraTestUtilities extends IslandoraTestUtilityClass {
* Asserts that the given datastreams exist correctly on the object.
*
* @param AbstractObject $object
* The PID of the object
* The object to check.
* @param array $datastreams
* An array of strings containing datastream names
* An array of strings containing datastream names.
*
* @return bool
* TRUE on success, FALSE on fail.
@ -341,6 +333,30 @@ class IslandoraTestUtilities extends IslandoraTestUtilityClass {
}
}
/**
* Asserts that the given datastreams do not exist on the object.
*
* @param AbstractObject $object
* The object to check.
* @param array $datastreams
* An array of datastreams to confirm not present.
*/
public function assertNoDatastreams($object, array $datastreams) {
if (!is_object($object)) {
$this->addResult(FALSE, "Failed. Object passed in is invalid.", 'Islandora');
return;
}
$found_datastreams = array_intersect_key(array_flip($datastreams), $object->repository->api->a->listDatastreams($object->id));
if (!empty($found_datastreams)) {
$this->addResult(FALSE, "Found unwanted datastream(s)" . implode(', ', array_flip($found_datastreams)) . " in object {$object->id}.");
return FALSE;
}
$this->addResult(TRUE, "Unwanted datastream(s) not found in object {$object->id}");
return TRUE;
}
/**
* Attempts to validate an array of datastreams, generally via binary checks.
*

Loading…
Cancel
Save