summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2015-05-31 10:41:11 +0200
committerFlorian Pritz <bluewind@xinu.at>2015-05-31 10:41:11 +0200
commit3281db65cafe150fbe26606ce6b5bd63da87f8a4 (patch)
treee08f1df14d9e2a9195a33374f08d59f127fdf981
parent2937bf1a47778ad1b804fee65ff3c9fe5c35ab61 (diff)
test: Add more \libraries\Image tests
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--application/test/tests/test_libraries_image.php30
-rw-r--r--data/tests/black_white.pngbin0 -> 238 bytes
-rw-r--r--data/tests/simple.pdfbin0 -> 9505 bytes
3 files changed, 30 insertions, 0 deletions
diff --git a/application/test/tests/test_libraries_image.php b/application/test/tests/test_libraries_image.php
index 13c9e67b9..cd9098ccc 100644
--- a/application/test/tests/test_libraries_image.php
+++ b/application/test/tests/test_libraries_image.php
@@ -34,5 +34,35 @@ class test_libraries_image extends \test\Test {
$this->t->is(\libraries\Image::type_supported('text/plain'), false, 'text/plain should not be supported');
}
+ public function test_makeThumb_PNG()
+ {
+ $img = new \libraries\Image(FCPATH."/data/tests/black_white.png");
+ $img->makeThumb(150, 150);
+ $thumb = $img->get(IMAGETYPE_PNG);
+
+ $this->t->ok($thumb !== "", "Got thumbnail");
+ }
+
+ public function test_makeThumb_PDF()
+ {
+ $img = new \libraries\Image(FCPATH."/data/tests/simple.pdf");
+ $img->makeThumb(150, 150);
+ $thumb = $img->get(IMAGETYPE_JPEG);
+
+ $this->t->ok($thumb !== "", "Got thumbnail");
+ }
+
+ public function test_makeThumb_binaryFile()
+ {
+ try {
+ $img = new \libraries\Image(FCPATH."/data/tests/message1.bin");
+ } catch (\exceptions\PublicApiException $e) {
+ $correct_error = $e->get_error_id() == "libraries/Image/unsupported-image-type";
+ $this->t->ok($correct_error, "Should get exception");
+ if (!$correct_error) {
+ throw $e;
+ }
+ }
+ }
}
diff --git a/data/tests/black_white.png b/data/tests/black_white.png
new file mode 100644
index 000000000..f15dfc646
--- /dev/null
+++ b/data/tests/black_white.png
Binary files differ
diff --git a/data/tests/simple.pdf b/data/tests/simple.pdf
new file mode 100644
index 000000000..85e541756
--- /dev/null
+++ b/data/tests/simple.pdf
Binary files differ