diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-07-22 13:13:39 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-07-30 18:05:32 +0200 |
commit | e184157684ad923d5d4107b76d6421e6ae28799d (patch) | |
tree | 41ac7f0569caf96c75657e8dd6858222db2f37b1 /tests | |
parent | a07254856ce532bfe5c49c1b53247daf88dbdd4a (diff) | |
download | nextcloud-server-e184157684ad923d5d4107b76d6421e6ae28799d.tar.gz nextcloud-server-e184157684ad923d5d4107b76d6421e6ae28799d.zip |
[avatar] add error handlers for avatar setup
add colon to translated string
use placeholder in t()
Adding a size limitation for avatar upload
Unit test for file size
Fix typo & display server side error message
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/avatar/avatarcontrollertest.php | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/tests/core/avatar/avatarcontrollertest.php b/tests/core/avatar/avatarcontrollertest.php index 0a85fbb27f1..952e013bb8f 100644 --- a/tests/core/avatar/avatarcontrollertest.php +++ b/tests/core/avatar/avatarcontrollertest.php @@ -23,7 +23,6 @@ namespace OC\Core\Avatar; use OC; use OC\Core\Application; use OCP\AppFramework\IAppContainer; -use OCP\Security\ISecureRandom; use OC\Files\Filesystem; use OCP\AppFramework\Http; use OCP\Image; @@ -264,7 +263,7 @@ class AvatarControllerTest extends \Test\TestCase { $view->file_put_contents('avatar_upload', file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg')); //Create request return - $reqRet = ['error' => [0], 'tmp_name' => [$fileName]]; + $reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => [filesize(OC::$SERVERROOT.'/tests/data/testimage.jpg')]]; $this->container['Request']->method('getUploadedFile')->willReturn($reqRet); $response = $this->avatarController->postAvatar(null); @@ -303,7 +302,7 @@ class AvatarControllerTest extends \Test\TestCase { $view->file_put_contents('avatar_upload', file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif')); //Create request return - $reqRet = ['error' => [0], 'tmp_name' => [$fileName]]; + $reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => filesize(OC::$SERVERROOT.'/tests/data/testimage.gif')]; $this->container['Request']->method('getUploadedFile')->willReturn($reqRet); $response = $this->avatarController->postAvatar(null); @@ -330,7 +329,7 @@ class AvatarControllerTest extends \Test\TestCase { } /** - * Test invalid crop argment + * Test invalid crop argument */ public function testPostCroppedAvatarInvalidCrop() { $response = $this->avatarController->postCroppedAvatar([]); @@ -372,4 +371,18 @@ class AvatarControllerTest extends \Test\TestCase { $this->assertEquals('success', $response->getData()['status']); } + /** + * Check for proper reply on proper crop argument + */ + public function testFileTooBig() { + $fileName = OC::$SERVERROOT.'/tests/data/testimage.jpg'; + //Create request return + $reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => [21*1024*1024]]; + $this->container['Request']->method('getUploadedFile')->willReturn($reqRet); + + $response = $this->avatarController->postAvatar(null); + + $this->assertEquals('File is too big', $response->getData()['data']['message']); + } + } |