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 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'application/test') 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; + } + } + } } -- cgit v1.2.3-24-g4f1b