From 3281db65cafe150fbe26606ce6b5bd63da87f8a4 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 31 May 2015 10:41:11 +0200 Subject: test: Add more \libraries\Image tests Signed-off-by: Florian Pritz --- application/test/tests/test_libraries_image.php | 30 ++++++++++++++++++++++++ data/tests/black_white.png | Bin 0 -> 238 bytes data/tests/simple.pdf | Bin 0 -> 9505 bytes 3 files changed, 30 insertions(+) create mode 100644 data/tests/black_white.png create mode 100644 data/tests/simple.pdf 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 Binary files /dev/null and b/data/tests/black_white.png differ diff --git a/data/tests/simple.pdf b/data/tests/simple.pdf new file mode 100644 index 000000000..85e541756 Binary files /dev/null and b/data/tests/simple.pdf differ -- cgit v1.2.3-24-g4f1b