diff options
author | Olivier Paroz <github@oparoz.com> | 2015-08-23 05:27:37 +0300 |
---|---|---|
committer | Olivier Paroz <github@oparoz.com> | 2015-08-23 05:27:37 +0300 |
commit | 56cc5fd801a449820d1a93d57ba5e3b9c45bc224 (patch) | |
tree | 2594b3700addc129f7b27fcd202e6316cd16c76e /tests/unit | |
parent | 468f17a74a127ae7e2a4f9e2f1d0e57337595569 (diff) |
Some unit tests for the ImageResponse class
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/http/ImageResponseTest.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/unit/http/ImageResponseTest.php b/tests/unit/http/ImageResponseTest.php new file mode 100644 index 00000000..62b3d99c --- /dev/null +++ b/tests/unit/http/ImageResponseTest.php @@ -0,0 +1,57 @@ +<?php +/** + * ownCloud - gallery + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Olivier Paroz <owncloud@interfasys.ch> + * + * @copyright Olivier Paroz 2015 + */ +namespace OCA\Gallery\Controller; + +use OCP\AppFramework\Http; + +use OCA\Gallery\Http\ImageResponse; + + +/** + * Class ImageResponseTest + * + * @package OCA\Gallery\Controller + */ +class ImageResponseTest extends \Test\TestCase { + + public function testRenderWithOcImageInstance() { + $resource = file_get_contents(\OC::$SERVERROOT . '/tests/data/testimage.jpg'); + $preview = new \OC_Image($resource); + + $data = [ + 'name' => 'testimage.jpg', + 'mimetype' => 'image/jpeg', + 'preview' => $preview, + ]; + + $imageResponse = new ImageResponse ($data); + $response = $imageResponse->render(); + + $this->assertSame($preview->data(), $response); + } + + public function testRenderWithString() { + $preview = file_get_contents(\OC::$SERVERROOT . '/tests/data/testimage.jpg'); + + $data = [ + 'name' => 'testimage.jpg', + 'mimetype' => 'image/jpeg', + 'preview' => $preview, + ]; + + $imageResponse = new ImageResponse ($data); + $response = $imageResponse->render(); + + $this->assertSame($preview, $response); + } + +} |