AvatarControllerTest.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OC\Core\Controller;
  8. /**
  9. * Overwrite is_uploaded_file in the OC\Core\Controller namespace to allow
  10. * proper unit testing of the postAvatar call.
  11. */
  12. function is_uploaded_file($filename) {
  13. return file_exists($filename);
  14. }
  15. namespace Tests\Core\Controller;
  16. use OC\AppFramework\Utility\TimeFactory;
  17. use OC\Core\Controller\AvatarController;
  18. use OC\Core\Controller\GuestAvatarController;
  19. use OCP\AppFramework\Http;
  20. use OCP\Files\File;
  21. use OCP\Files\IRootFolder;
  22. use OCP\Files\NotFoundException;
  23. use OCP\Files\NotPermittedException;
  24. use OCP\Files\SimpleFS\ISimpleFile;
  25. use OCP\IAvatar;
  26. use OCP\IAvatarManager;
  27. use OCP\ICache;
  28. use OCP\IL10N;
  29. use OCP\IRequest;
  30. use OCP\IUser;
  31. use OCP\IUserManager;
  32. use Psr\Log\LoggerInterface;
  33. /**
  34. * Class AvatarControllerTest
  35. *
  36. * @package OC\Core\Controller
  37. */
  38. class AvatarControllerTest extends \Test\TestCase {
  39. /** @var AvatarController */
  40. private $avatarController;
  41. /** @var GuestAvatarController */
  42. private $guestAvatarController;
  43. /** @var IAvatar|\PHPUnit\Framework\MockObject\MockObject */
  44. private $avatarMock;
  45. /** @var IUser|\PHPUnit\Framework\MockObject\MockObject */
  46. private $userMock;
  47. /** @var ISimpleFile|\PHPUnit\Framework\MockObject\MockObject */
  48. private $avatarFile;
  49. /** @var IAvatarManager|\PHPUnit\Framework\MockObject\MockObject */
  50. private $avatarManager;
  51. /** @var ICache|\PHPUnit\Framework\MockObject\MockObject */
  52. private $cache;
  53. /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
  54. private $l;
  55. /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
  56. private $userManager;
  57. /** @var IRootFolder|\PHPUnit\Framework\MockObject\MockObject */
  58. private $rootFolder;
  59. /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
  60. private $logger;
  61. /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
  62. private $request;
  63. /** @var TimeFactory|\PHPUnit\Framework\MockObject\MockObject */
  64. private $timeFactory;
  65. protected function setUp(): void {
  66. parent::setUp();
  67. $this->avatarManager = $this->getMockBuilder('OCP\IAvatarManager')->getMock();
  68. $this->cache = $this->getMockBuilder('OCP\ICache')
  69. ->disableOriginalConstructor()->getMock();
  70. $this->l = $this->getMockBuilder(IL10N::class)->getMock();
  71. $this->l->method('t')->willReturnArgument(0);
  72. $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock();
  73. $this->request = $this->getMockBuilder(IRequest::class)->getMock();
  74. $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock();
  75. $this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
  76. $this->timeFactory = $this->getMockBuilder('OC\AppFramework\Utility\TimeFactory')->getMock();
  77. $this->avatarMock = $this->getMockBuilder('OCP\IAvatar')->getMock();
  78. $this->userMock = $this->getMockBuilder(IUser::class)->getMock();
  79. $this->guestAvatarController = new GuestAvatarController(
  80. 'core',
  81. $this->request,
  82. $this->avatarManager,
  83. $this->logger
  84. );
  85. $this->avatarController = new AvatarController(
  86. 'core',
  87. $this->request,
  88. $this->avatarManager,
  89. $this->cache,
  90. $this->l,
  91. $this->userManager,
  92. $this->rootFolder,
  93. $this->logger,
  94. 'userid',
  95. $this->timeFactory,
  96. $this->guestAvatarController,
  97. );
  98. // Configure userMock
  99. $this->userMock->method('getDisplayName')->willReturn('displayName');
  100. $this->userMock->method('getUID')->willReturn('userId');
  101. $this->userManager->method('get')
  102. ->willReturnMap([['userId', $this->userMock]]);
  103. $this->avatarFile = $this->getMockBuilder(ISimpleFile::class)->getMock();
  104. $this->avatarFile->method('getContent')->willReturn('image data');
  105. $this->avatarFile->method('getMimeType')->willReturn('image type');
  106. $this->avatarFile->method('getEtag')->willReturn('my etag');
  107. $this->avatarFile->method('getName')->willReturn('my name');
  108. $this->avatarFile->method('getMTime')->willReturn(42);
  109. }
  110. protected function tearDown(): void {
  111. parent::tearDown();
  112. }
  113. /**
  114. * Fetch an avatar if a user has no avatar
  115. */
  116. public function testGetAvatarNoAvatar(): void {
  117. $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock);
  118. $this->avatarMock->method('getFile')->will($this->throwException(new NotFoundException()));
  119. $response = $this->avatarController->getAvatar('userId', 32);
  120. //Comment out until JS is fixed
  121. $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus());
  122. }
  123. /**
  124. * Fetch the user's avatar
  125. */
  126. public function testGetAvatar(): void {
  127. $this->avatarMock->method('getFile')->willReturn($this->avatarFile);
  128. $this->avatarManager->method('getAvatar')->with('userId')->willReturn($this->avatarMock);
  129. $this->avatarMock->expects($this->once())
  130. ->method('isCustomAvatar')
  131. ->willReturn(true);
  132. $response = $this->avatarController->getAvatar('userId', 32);
  133. $this->assertEquals(Http::STATUS_OK, $response->getStatus());
  134. $this->assertArrayHasKey('Content-Type', $response->getHeaders());
  135. $this->assertEquals('image type', $response->getHeaders()['Content-Type']);
  136. $this->assertArrayHasKey('X-NC-IsCustomAvatar', $response->getHeaders());
  137. $this->assertEquals('1', $response->getHeaders()['X-NC-IsCustomAvatar']);
  138. $this->assertEquals('my etag', $response->getETag());
  139. }
  140. /**
  141. * Fetch the user's avatar
  142. */
  143. public function testGetGeneratedAvatar(): void {
  144. $this->avatarMock->method('getFile')->willReturn($this->avatarFile);
  145. $this->avatarManager->method('getAvatar')->with('userId')->willReturn($this->avatarMock);
  146. $response = $this->avatarController->getAvatar('userId', 32);
  147. $this->assertEquals(Http::STATUS_OK, $response->getStatus());
  148. $this->assertArrayHasKey('Content-Type', $response->getHeaders());
  149. $this->assertEquals('image type', $response->getHeaders()['Content-Type']);
  150. $this->assertArrayHasKey('X-NC-IsCustomAvatar', $response->getHeaders());
  151. $this->assertEquals('0', $response->getHeaders()['X-NC-IsCustomAvatar']);
  152. $this->assertEquals('my etag', $response->getETag());
  153. }
  154. /**
  155. * Fetch the avatar of a non-existing user
  156. */
  157. public function testGetAvatarNoUser(): void {
  158. $this->avatarManager
  159. ->method('getAvatar')
  160. ->with('userDoesNotExist')
  161. ->will($this->throwException(new \Exception('user does not exist')));
  162. $response = $this->avatarController->getAvatar('userDoesNotExist', 32);
  163. //Comment out until JS is fixed
  164. $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus());
  165. }
  166. public function testGetAvatarSize64(): void {
  167. $this->avatarMock->expects($this->once())
  168. ->method('getFile')
  169. ->with($this->equalTo(64))
  170. ->willReturn($this->avatarFile);
  171. $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock);
  172. $this->logger->expects($this->never())
  173. ->method('debug');
  174. $this->avatarController->getAvatar('userId', 64);
  175. }
  176. public function testGetAvatarSize512(): void {
  177. $this->avatarMock->expects($this->once())
  178. ->method('getFile')
  179. ->with($this->equalTo(512))
  180. ->willReturn($this->avatarFile);
  181. $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock);
  182. $this->logger->expects($this->never())
  183. ->method('debug');
  184. $this->avatarController->getAvatar('userId', 512);
  185. }
  186. /**
  187. * Small sizes return 64 and generate a log
  188. */
  189. public function testGetAvatarSizeTooSmall(): void {
  190. $this->avatarMock->expects($this->once())
  191. ->method('getFile')
  192. ->with($this->equalTo(64))
  193. ->willReturn($this->avatarFile);
  194. $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock);
  195. $this->logger->expects($this->once())
  196. ->method('debug')
  197. ->with('Avatar requested in deprecated size 32');
  198. $this->avatarController->getAvatar('userId', 32);
  199. }
  200. /**
  201. * Avatars between 64 and 512 are upgraded to 512
  202. */
  203. public function testGetAvatarSizeBetween(): void {
  204. $this->avatarMock->expects($this->once())
  205. ->method('getFile')
  206. ->with($this->equalTo(512))
  207. ->willReturn($this->avatarFile);
  208. $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock);
  209. $this->logger->expects($this->once())
  210. ->method('debug')
  211. ->with('Avatar requested in deprecated size 65');
  212. $this->avatarController->getAvatar('userId', 65);
  213. }
  214. /**
  215. * We do not support avatars larger than 512
  216. */
  217. public function testGetAvatarSizeTooBig(): void {
  218. $this->avatarMock->expects($this->once())
  219. ->method('getFile')
  220. ->with($this->equalTo(512))
  221. ->willReturn($this->avatarFile);
  222. $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock);
  223. $this->logger->expects($this->once())
  224. ->method('debug')
  225. ->with('Avatar requested in deprecated size 513');
  226. $this->avatarController->getAvatar('userId', 513);
  227. }
  228. /**
  229. * Remove an avatar
  230. */
  231. public function testDeleteAvatar(): void {
  232. $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock);
  233. $response = $this->avatarController->deleteAvatar();
  234. $this->assertEquals(Http::STATUS_OK, $response->getStatus());
  235. }
  236. /**
  237. * Test what happens if the removing of the avatar fails
  238. */
  239. public function testDeleteAvatarException(): void {
  240. $this->avatarMock->method('remove')->will($this->throwException(new \Exception('foo')));
  241. $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock);
  242. $this->logger->expects($this->once())
  243. ->method('error')
  244. ->with('foo', ['exception' => new \Exception('foo'), 'app' => 'core']);
  245. $expectedResponse = new Http\JSONResponse(['data' => ['message' => 'An error occurred. Please contact your admin.']], Http::STATUS_BAD_REQUEST);
  246. $this->assertEquals($expectedResponse, $this->avatarController->deleteAvatar());
  247. }
  248. /**
  249. * Trying to get a tmp avatar when it is not available. 404
  250. */
  251. public function testTmpAvatarNoTmp(): void {
  252. $response = $this->avatarController->getTmpAvatar();
  253. $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus());
  254. }
  255. /**
  256. * Fetch tmp avatar
  257. */
  258. public function testTmpAvatarValid(): void {
  259. $this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg'));
  260. $response = $this->avatarController->getTmpAvatar();
  261. $this->assertEquals(Http::STATUS_OK, $response->getStatus());
  262. }
  263. /**
  264. * When trying to post a new avatar a path or image should be posted.
  265. */
  266. public function testPostAvatarNoPathOrImage(): void {
  267. $response = $this->avatarController->postAvatar(null);
  268. $this->assertEquals(Http::STATUS_BAD_REQUEST, $response->getStatus());
  269. }
  270. /**
  271. * Test a correct post of an avatar using POST
  272. */
  273. public function testPostAvatarFile(): void {
  274. //Create temp file
  275. $fileName = tempnam('', 'avatarTest');
  276. $copyRes = copy(\OC::$SERVERROOT.'/tests/data/testimage.jpg', $fileName);
  277. $this->assertTrue($copyRes);
  278. //Create file in cache
  279. $this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg'));
  280. //Create request return
  281. $reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => [filesize(\OC::$SERVERROOT.'/tests/data/testimage.jpg')]];
  282. $this->request->method('getUploadedFile')->willReturn($reqRet);
  283. $response = $this->avatarController->postAvatar(null);
  284. //On correct upload always respond with the notsquare message
  285. $this->assertEquals('notsquare', $response->getData()['data']);
  286. //File should be deleted
  287. $this->assertFalse(file_exists($fileName));
  288. }
  289. /**
  290. * Test invalid post os an avatar using POST
  291. */
  292. public function testPostAvatarInvalidFile(): void {
  293. //Create request return
  294. $reqRet = ['error' => [1], 'tmp_name' => ['foo']];
  295. $this->request->method('getUploadedFile')->willReturn($reqRet);
  296. $response = $this->avatarController->postAvatar(null);
  297. $this->assertEquals(Http::STATUS_BAD_REQUEST, $response->getStatus());
  298. }
  299. /**
  300. * Check what happens when we upload a GIF
  301. */
  302. public function testPostAvatarFileGif(): void {
  303. //Create temp file
  304. $fileName = tempnam('', 'avatarTest');
  305. $copyRes = copy(\OC::$SERVERROOT.'/tests/data/testimage.gif', $fileName);
  306. $this->assertTrue($copyRes);
  307. //Create file in cache
  308. $this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.gif'));
  309. //Create request return
  310. $reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => [filesize(\OC::$SERVERROOT.'/tests/data/testimage.gif')]];
  311. $this->request->method('getUploadedFile')->willReturn($reqRet);
  312. $response = $this->avatarController->postAvatar(null);
  313. $this->assertEquals('Unknown filetype', $response->getData()['data']['message']);
  314. //File should be deleted
  315. $this->assertFalse(file_exists($fileName));
  316. }
  317. /**
  318. * Test posting avatar from existing file
  319. */
  320. public function testPostAvatarFromFile(): void {
  321. //Mock node API call
  322. $file = $this->getMockBuilder('OCP\Files\File')
  323. ->disableOriginalConstructor()->getMock();
  324. $file->expects($this->once())
  325. ->method('getContent')
  326. ->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg'));
  327. $file->expects($this->once())
  328. ->method('getMimeType')
  329. ->willReturn('image/jpeg');
  330. $userFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
  331. $this->rootFolder->method('getUserFolder')->with('userid')->willReturn($userFolder);
  332. $userFolder->method('get')->willReturn($file);
  333. //Create request return
  334. $response = $this->avatarController->postAvatar('avatar.jpg');
  335. //On correct upload always respond with the notsquare message
  336. $this->assertEquals('notsquare', $response->getData()['data']);
  337. }
  338. /**
  339. * Test posting avatar from existing folder
  340. */
  341. public function testPostAvatarFromNoFile(): void {
  342. $file = $this->getMockBuilder('OCP\Files\Node')->getMock();
  343. $userFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
  344. $this->rootFolder->method('getUserFolder')->with('userid')->willReturn($userFolder);
  345. $userFolder
  346. ->method('get')
  347. ->with('folder')
  348. ->willReturn($file);
  349. //Create request return
  350. $response = $this->avatarController->postAvatar('folder');
  351. //On correct upload always respond with the notsquare message
  352. $this->assertEquals(['data' => ['message' => 'Please select a file.']], $response->getData());
  353. }
  354. public function testPostAvatarInvalidType(): void {
  355. $file = $this->getMockBuilder('OCP\Files\File')
  356. ->disableOriginalConstructor()->getMock();
  357. $file->expects($this->never())
  358. ->method('getContent');
  359. $file->expects($this->exactly(2))
  360. ->method('getMimeType')
  361. ->willReturn('text/plain');
  362. $userFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
  363. $this->rootFolder->method('getUserFolder')->with('userid')->willReturn($userFolder);
  364. $userFolder->method('get')->willReturn($file);
  365. $expectedResponse = new Http\JSONResponse(['data' => ['message' => 'The selected file is not an image.']], Http::STATUS_BAD_REQUEST);
  366. $this->assertEquals($expectedResponse, $this->avatarController->postAvatar('avatar.jpg'));
  367. }
  368. public function testPostAvatarNotPermittedException(): void {
  369. $file = $this->getMockBuilder('OCP\Files\File')
  370. ->disableOriginalConstructor()->getMock();
  371. $file->expects($this->once())
  372. ->method('getContent')
  373. ->willThrowException(new NotPermittedException());
  374. $file->expects($this->once())
  375. ->method('getMimeType')
  376. ->willReturn('image/jpeg');
  377. $userFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
  378. $this->rootFolder->method('getUserFolder')->with('userid')->willReturn($userFolder);
  379. $userFolder->method('get')->willReturn($file);
  380. $expectedResponse = new Http\JSONResponse(['data' => ['message' => 'The selected file cannot be read.']], Http::STATUS_BAD_REQUEST);
  381. $this->assertEquals($expectedResponse, $this->avatarController->postAvatar('avatar.jpg'));
  382. }
  383. /**
  384. * Test what happens if the upload of the avatar fails
  385. */
  386. public function testPostAvatarException(): void {
  387. $this->cache->expects($this->once())
  388. ->method('set')
  389. ->will($this->throwException(new \Exception('foo')));
  390. $file = $this->getMockBuilder('OCP\Files\File')
  391. ->disableOriginalConstructor()->getMock();
  392. $file->expects($this->once())
  393. ->method('getContent')
  394. ->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg'));
  395. $file->expects($this->once())
  396. ->method('getMimeType')
  397. ->willReturn('image/jpeg');
  398. $userFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
  399. $this->rootFolder->method('getUserFolder')->with('userid')->willReturn($userFolder);
  400. $userFolder->method('get')->willReturn($file);
  401. $this->logger->expects($this->once())
  402. ->method('error')
  403. ->with('foo', ['exception' => new \Exception('foo'), 'app' => 'core']);
  404. $expectedResponse = new Http\JSONResponse(['data' => ['message' => 'An error occurred. Please contact your admin.']], Http::STATUS_OK);
  405. $this->assertEquals($expectedResponse, $this->avatarController->postAvatar('avatar.jpg'));
  406. }
  407. /**
  408. * Test invalid crop argument
  409. */
  410. public function testPostCroppedAvatarInvalidCrop(): void {
  411. $response = $this->avatarController->postCroppedAvatar([]);
  412. $this->assertEquals(Http::STATUS_BAD_REQUEST, $response->getStatus());
  413. }
  414. /**
  415. * Test no tmp avatar to crop
  416. */
  417. public function testPostCroppedAvatarNoTmpAvatar(): void {
  418. $response = $this->avatarController->postCroppedAvatar(['x' => 0, 'y' => 0, 'w' => 10, 'h' => 10]);
  419. $this->assertEquals(Http::STATUS_BAD_REQUEST, $response->getStatus());
  420. }
  421. /**
  422. * Test with non square crop
  423. */
  424. public function testPostCroppedAvatarNoSquareCrop(): void {
  425. $this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg'));
  426. $this->avatarMock->method('set')->will($this->throwException(new \OC\NotSquareException));
  427. $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock);
  428. $response = $this->avatarController->postCroppedAvatar(['x' => 0, 'y' => 0, 'w' => 10, 'h' => 11]);
  429. $this->assertEquals(Http::STATUS_BAD_REQUEST, $response->getStatus());
  430. }
  431. /**
  432. * Check for proper reply on proper crop argument
  433. */
  434. public function testPostCroppedAvatarValidCrop(): void {
  435. $this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg'));
  436. $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock);
  437. $response = $this->avatarController->postCroppedAvatar(['x' => 0, 'y' => 0, 'w' => 10, 'h' => 10]);
  438. $this->assertEquals(Http::STATUS_OK, $response->getStatus());
  439. $this->assertEquals('success', $response->getData()['status']);
  440. }
  441. /**
  442. * Test what happens if the cropping of the avatar fails
  443. */
  444. public function testPostCroppedAvatarException(): void {
  445. $this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg'));
  446. $this->avatarMock->method('set')->will($this->throwException(new \Exception('foo')));
  447. $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock);
  448. $this->logger->expects($this->once())
  449. ->method('error')
  450. ->with('foo', ['exception' => new \Exception('foo'), 'app' => 'core']);
  451. $expectedResponse = new Http\JSONResponse(['data' => ['message' => 'An error occurred. Please contact your admin.']], Http::STATUS_BAD_REQUEST);
  452. $this->assertEquals($expectedResponse, $this->avatarController->postCroppedAvatar(['x' => 0, 'y' => 0, 'w' => 10, 'h' => 11]));
  453. }
  454. /**
  455. * Check for proper reply on proper crop argument
  456. */
  457. public function testFileTooBig(): void {
  458. $fileName = \OC::$SERVERROOT.'/tests/data/testimage.jpg';
  459. //Create request return
  460. $reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => [21 * 1024 * 1024]];
  461. $this->request->method('getUploadedFile')->willReturn($reqRet);
  462. $response = $this->avatarController->postAvatar(null);
  463. $this->assertEquals('File is too big', $response->getData()['data']['message']);
  464. }
  465. }