Browse Source

Merge pull request #381 from qadan/7.x

added the fancy image assertion back in
pull/397/head
Jonathan Green 12 years ago
parent
commit
00959ff48e
  1. 31
      tests/islandora_web_test_case.inc

31
tests/islandora_web_test_case.inc

@ -168,7 +168,7 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
if (!is_object($object)) { if (!is_object($object)) {
$this->fail("Failed. Object passed in is invalid.", 'Islandora'); $this->fail("Failed. Object passed in is invalid.", 'Islandora');
} }
else {
foreach ($datastreams as $datastream) { foreach ($datastreams as $datastream) {
if (isset($object[$datastream])) { if (isset($object[$datastream])) {
$this->pass("Loaded datastream {$datastream} from PID {$object->id}.", 'Islandora'); $this->pass("Loaded datastream {$datastream} from PID {$object->id}.", 'Islandora');
@ -177,7 +177,36 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
$this->fail("Failed to load datastream {$datastream} from PID {$object->id}.", 'Islandora'); $this->fail("Failed to load datastream {$datastream} from PID {$object->id}.", 'Islandora');
} }
} }
}
}
/**
* Asserts that an object's given datastreams are common-type image files.
*
* Uses PHPGD to run the assertion check. This means that only certain kinds
* of image files can be checked. Please check the documentation for the PHPGD
* imagecreatefromstring() function to determine what filetypes are valid.
*
* @param AbstractObject $object
* The PID of the object.
* @param array $datastreams
* An array of datastreams to check.
*/
public function assertImageDatastreams($object, array $datastreams) {
if (!is_object($object)) {
$this->fail("Failed. Object passed in is invalid.", 'Islandora');
}
else {
foreach ($datastreams as $datastream) {
$datastream_string = $object[$datastream]->content;
if (!imagecreatefromstring($datastream_string)) {
$this->fail("Image datastream {$datastream} is either invalid or corrupt.", 'Islandora');
}
else {
$this->pass("Image datastream {$datastream} is valid.", 'Islandora');
}
}
}
} }
/** /**

Loading…
Cancel
Save