diff options
Diffstat (limited to 'tests/Core/Controller/AvatarControllerTest.php')
-rw-r--r-- | tests/Core/Controller/AvatarControllerTest.php | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/tests/Core/Controller/AvatarControllerTest.php b/tests/Core/Controller/AvatarControllerTest.php index 41c16bc4c3f..3a1123c940b 100644 --- a/tests/Core/Controller/AvatarControllerTest.php +++ b/tests/Core/Controller/AvatarControllerTest.php @@ -128,7 +128,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Fetch an avatar if a user has no avatar */ - public function testGetAvatarNoAvatar() { + public function testGetAvatarNoAvatar(): void { $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock); $this->avatarMock->method('getFile')->will($this->throwException(new NotFoundException())); $response = $this->avatarController->getAvatar('userId', 32); @@ -140,7 +140,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Fetch the user's avatar */ - public function testGetAvatar() { + public function testGetAvatar(): void { $this->avatarMock->method('getFile')->willReturn($this->avatarFile); $this->avatarManager->method('getAvatar')->with('userId')->willReturn($this->avatarMock); $this->avatarMock->expects($this->once()) @@ -161,7 +161,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Fetch the user's avatar */ - public function testGetGeneratedAvatar() { + public function testGetGeneratedAvatar(): void { $this->avatarMock->method('getFile')->willReturn($this->avatarFile); $this->avatarManager->method('getAvatar')->with('userId')->willReturn($this->avatarMock); @@ -179,7 +179,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Fetch the avatar of a non-existing user */ - public function testGetAvatarNoUser() { + public function testGetAvatarNoUser(): void { $this->avatarManager ->method('getAvatar') ->with('userDoesNotExist') @@ -276,7 +276,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Remove an avatar */ - public function testDeleteAvatar() { + public function testDeleteAvatar(): void { $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock); $response = $this->avatarController->deleteAvatar(); @@ -286,7 +286,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Test what happens if the removing of the avatar fails */ - public function testDeleteAvatarException() { + public function testDeleteAvatarException(): void { $this->avatarMock->method('remove')->will($this->throwException(new \Exception('foo'))); $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock); @@ -300,7 +300,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Trying to get a tmp avatar when it is not available. 404 */ - public function testTmpAvatarNoTmp() { + public function testTmpAvatarNoTmp(): void { $response = $this->avatarController->getTmpAvatar(); $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus()); } @@ -308,7 +308,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Fetch tmp avatar */ - public function testTmpAvatarValid() { + public function testTmpAvatarValid(): void { $this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg')); $response = $this->avatarController->getTmpAvatar(); @@ -319,7 +319,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * When trying to post a new avatar a path or image should be posted. */ - public function testPostAvatarNoPathOrImage() { + public function testPostAvatarNoPathOrImage(): void { $response = $this->avatarController->postAvatar(null); $this->assertEquals(Http::STATUS_BAD_REQUEST, $response->getStatus()); @@ -328,7 +328,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Test a correct post of an avatar using POST */ - public function testPostAvatarFile() { + public function testPostAvatarFile(): void { //Create temp file $fileName = tempnam('', 'avatarTest'); $copyRes = copy(\OC::$SERVERROOT.'/tests/data/testimage.jpg', $fileName); @@ -353,7 +353,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Test invalid post os an avatar using POST */ - public function testPostAvatarInvalidFile() { + public function testPostAvatarInvalidFile(): void { //Create request return $reqRet = ['error' => [1], 'tmp_name' => ['foo']]; $this->request->method('getUploadedFile')->willReturn($reqRet); @@ -366,7 +366,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Check what happens when we upload a GIF */ - public function testPostAvatarFileGif() { + public function testPostAvatarFileGif(): void { //Create temp file $fileName = tempnam('', 'avatarTest'); $copyRes = copy(\OC::$SERVERROOT.'/tests/data/testimage.gif', $fileName); @@ -390,7 +390,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Test posting avatar from existing file */ - public function testPostAvatarFromFile() { + public function testPostAvatarFromFile(): void { //Mock node API call $file = $this->getMockBuilder('OCP\Files\File') ->disableOriginalConstructor()->getMock(); @@ -414,7 +414,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Test posting avatar from existing folder */ - public function testPostAvatarFromNoFile() { + public function testPostAvatarFromNoFile(): void { $file = $this->getMockBuilder('OCP\Files\Node')->getMock(); $userFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock(); $this->rootFolder->method('getUserFolder')->with('userid')->willReturn($userFolder); @@ -430,7 +430,7 @@ class AvatarControllerTest extends \Test\TestCase { $this->assertEquals(['data' => ['message' => 'Please select a file.']], $response->getData()); } - public function testPostAvatarInvalidType() { + public function testPostAvatarInvalidType(): void { $file = $this->getMockBuilder('OCP\Files\File') ->disableOriginalConstructor()->getMock(); $file->expects($this->never()) @@ -446,7 +446,7 @@ class AvatarControllerTest extends \Test\TestCase { $this->assertEquals($expectedResponse, $this->avatarController->postAvatar('avatar.jpg')); } - public function testPostAvatarNotPermittedException() { + public function testPostAvatarNotPermittedException(): void { $file = $this->getMockBuilder('OCP\Files\File') ->disableOriginalConstructor()->getMock(); $file->expects($this->once()) @@ -466,7 +466,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Test what happens if the upload of the avatar fails */ - public function testPostAvatarException() { + public function testPostAvatarException(): void { $this->cache->expects($this->once()) ->method('set') ->will($this->throwException(new \Exception('foo'))); @@ -493,7 +493,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Test invalid crop argument */ - public function testPostCroppedAvatarInvalidCrop() { + public function testPostCroppedAvatarInvalidCrop(): void { $response = $this->avatarController->postCroppedAvatar([]); $this->assertEquals(Http::STATUS_BAD_REQUEST, $response->getStatus()); @@ -502,7 +502,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Test no tmp avatar to crop */ - public function testPostCroppedAvatarNoTmpAvatar() { + public function testPostCroppedAvatarNoTmpAvatar(): void { $response = $this->avatarController->postCroppedAvatar(['x' => 0, 'y' => 0, 'w' => 10, 'h' => 10]); $this->assertEquals(Http::STATUS_BAD_REQUEST, $response->getStatus()); @@ -511,7 +511,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Test with non square crop */ - public function testPostCroppedAvatarNoSquareCrop() { + public function testPostCroppedAvatarNoSquareCrop(): void { $this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg')); $this->avatarMock->method('set')->will($this->throwException(new \OC\NotSquareException)); @@ -524,7 +524,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Check for proper reply on proper crop argument */ - public function testPostCroppedAvatarValidCrop() { + public function testPostCroppedAvatarValidCrop(): void { $this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg')); $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock); $response = $this->avatarController->postCroppedAvatar(['x' => 0, 'y' => 0, 'w' => 10, 'h' => 10]); @@ -536,7 +536,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Test what happens if the cropping of the avatar fails */ - public function testPostCroppedAvatarException() { + public function testPostCroppedAvatarException(): void { $this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg')); $this->avatarMock->method('set')->will($this->throwException(new \Exception('foo'))); @@ -553,7 +553,7 @@ class AvatarControllerTest extends \Test\TestCase { /** * Check for proper reply on proper crop argument */ - public function testFileTooBig() { + public function testFileTooBig(): void { $fileName = \OC::$SERVERROOT.'/tests/data/testimage.jpg'; //Create request return $reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => [21 * 1024 * 1024]]; |