|
@@ 377-385 (lines=9) @@
|
| 374 |
|
/** |
| 375 |
|
* Test with non square crop |
| 376 |
|
*/ |
| 377 |
|
public function testPostCroppedAvatarNoSquareCrop() { |
| 378 |
|
$this->container['Cache']->method('get')->willReturn(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg')); |
| 379 |
|
|
| 380 |
|
$this->avatarMock->method('set')->will($this->throwException(new \OC\NotSquareException)); |
| 381 |
|
$this->container['AvatarManager']->method('getAvatar')->willReturn($this->avatarMock); |
| 382 |
|
$response = $this->avatarController->postCroppedAvatar(['x' => 0, 'y' => 0, 'w' => 10, 'h' => 11]); |
| 383 |
|
|
| 384 |
|
$this->assertEquals(Http::STATUS_BAD_REQUEST, $response->getStatus()); |
| 385 |
|
} |
| 386 |
|
|
| 387 |
|
/** |
| 388 |
|
* Check for proper reply on proper crop argument |
|
@@ 390-397 (lines=8) @@
|
| 387 |
|
/** |
| 388 |
|
* Check for proper reply on proper crop argument |
| 389 |
|
*/ |
| 390 |
|
public function testPostCroppedAvatarValidCrop() { |
| 391 |
|
$this->container['Cache']->method('get')->willReturn(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg')); |
| 392 |
|
$this->container['AvatarManager']->method('getAvatar')->willReturn($this->avatarMock); |
| 393 |
|
$response = $this->avatarController->postCroppedAvatar(['x' => 0, 'y' => 0, 'w' => 10, 'h' => 10]); |
| 394 |
|
|
| 395 |
|
$this->assertEquals(Http::STATUS_OK, $response->getStatus()); |
| 396 |
|
$this->assertEquals('success', $response->getData()['status']); |
| 397 |
|
} |
| 398 |
|
|
| 399 |
|
/** |
| 400 |
|
* Test what happens if the cropping of the avatar fails |