Exemplo n.º 1
0
 /**
  * Check for proper reply on proper crop argument
  */
 public function testPostCroppedAvatarValidCrop()
 {
     $this->container['Cache']->method('get')->willReturn(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.jpg'));
     $this->container['AvatarManager']->method('getAvatar')->willReturn($this->avatarMock);
     $response = $this->avatarController->postCroppedAvatar(['x' => 0, 'y' => 0, 'w' => 10, 'h' => 10]);
     $this->assertEquals(Http::STATUS_OK, $response->getStatus());
     $this->assertEquals('success', $response->getData()['status']);
 }
Exemplo n.º 2
0
 /**
  * Test what happens if the cropping of the avatar fails
  */
 public function testPostCroppedAvatarException()
 {
     $this->container['Cache']->method('get')->willReturn(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.jpg'));
     $this->avatarMock->method('set')->will($this->throwException(new \Exception('foo')));
     $this->container['AvatarManager']->method('getAvatar')->willReturn($this->avatarMock);
     $this->container['Logger']->expects($this->once())->method('logException')->with(new \Exception('foo'));
     $expectedResponse = new Http\DataResponse(['data' => ['message' => 'An error occurred. Please contact your admin.']], Http::STATUS_BAD_REQUEST);
     $this->assertEquals($expectedResponse, $this->avatarController->postCroppedAvatar(['x' => 0, 'y' => 0, 'w' => 10, 'h' => 11]));
 }