From f1a47a6d4334317c1d42f22dc569d8c6a8fd0878 Mon Sep 17 00:00:00 2001 From: qadan Date: Mon, 12 Aug 2013 18:18:16 +0000 Subject: [PATCH 1/2] added the fancy image assertion back in --- tests/islandora_web_test_case.inc | 43 ++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/tests/islandora_web_test_case.inc b/tests/islandora_web_test_case.inc index baf7a8ee..722bdc7b 100644 --- a/tests/islandora_web_test_case.inc +++ b/tests/islandora_web_test_case.inc @@ -168,16 +168,45 @@ class IslandoraWebTestCase extends DrupalWebTestCase { if (!is_object($object)) { $this->fail("Failed. Object passed in is invalid.", 'Islandora'); } - - foreach ($datastreams as $datastream) { - if (isset($object[$datastream])) { - $this->pass("Loaded datastream {$datastream} from PID {$object->id}.", 'Islandora'); - } - else { - $this->fail("Failed to load datastream {$datastream} from PID {$object->id}.", 'Islandora'); + else { + foreach ($datastreams as $datastream) { + if (isset($object[$datastream])) { + $this->pass("Loaded datastream {$datastream} from PID {$object->id}.", 'Islandora'); + } + else { + $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'); + } + } + } } /** From 926fd23f554d7c3995d432de4ed18d9c8b565618 Mon Sep 17 00:00:00 2001 From: qadan Date: Mon, 12 Aug 2013 18:27:46 +0000 Subject: [PATCH 2/2] peace offering for Travis --- tests/islandora_web_test_case.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/islandora_web_test_case.inc b/tests/islandora_web_test_case.inc index 722bdc7b..be3b3b7e 100644 --- a/tests/islandora_web_test_case.inc +++ b/tests/islandora_web_test_case.inc @@ -188,9 +188,9 @@ class IslandoraWebTestCase extends DrupalWebTestCase { * imagecreatefromstring() function to determine what filetypes are valid. * * @param AbstractObject $object - * The PID of the object. + * The PID of the object. * @param array $datastreams - * An array of datastreams to check. + * An array of datastreams to check. */ public function assertImageDatastreams($object, array $datastreams) { if (!is_object($object)) {