/** * Test what happens if the removing of the avatar fails */ public function testDeleteAvatarException() { $this->avatarMock->method('remove')->will($this->throwException(new \Exception("foo"))); $this->container['AvatarManager']->method('getAvatar')->willReturn($this->avatarMock); $response = $this->avatarController->deleteAvatar(); $this->assertEquals(Http::STATUS_BAD_REQUEST, $response->getStatus()); }
/** * Test what happens if the removing of the avatar fails */ public function testDeleteAvatarException() { $this->avatarMock->method('remove')->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->deleteAvatar()); }