Fix unit test
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
decd196162
commit
38fffffe18
|
@ -34,7 +34,7 @@ namespace Tests\Core\Controller;
|
||||||
use OC\AppFramework\Utility\TimeFactory;
|
use OC\AppFramework\Utility\TimeFactory;
|
||||||
use OC\Core\Controller\AvatarController;
|
use OC\Core\Controller\AvatarController;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\Files\Cache\ICache;
|
use OCP\ICache;
|
||||||
use OCP\Files\File;
|
use OCP\Files\File;
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
use OCP\Files\NotFoundException;
|
use OCP\Files\NotFoundException;
|
||||||
|
@ -143,6 +143,9 @@ class AvatarControllerTest extends \Test\TestCase {
|
||||||
public function testGetAvatar() {
|
public function testGetAvatar() {
|
||||||
$this->avatarMock->method('getFile')->willReturn($this->avatarFile);
|
$this->avatarMock->method('getFile')->willReturn($this->avatarFile);
|
||||||
$this->avatarManager->method('getAvatar')->with('userId')->willReturn($this->avatarMock);
|
$this->avatarManager->method('getAvatar')->with('userId')->willReturn($this->avatarMock);
|
||||||
|
$this->avatarMock->expects($this->once())
|
||||||
|
->method('isCustomAvatar')
|
||||||
|
->willReturn(true);
|
||||||
|
|
||||||
$response = $this->avatarController->getAvatar('userId', 32);
|
$response = $this->avatarController->getAvatar('userId', 32);
|
||||||
|
|
||||||
|
@ -153,6 +156,22 @@ class AvatarControllerTest extends \Test\TestCase {
|
||||||
$this->assertEquals('my etag', $response->getETag());
|
$this->assertEquals('my etag', $response->getETag());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the user's avatar
|
||||||
|
*/
|
||||||
|
public function testGetGeneratedAvatar() {
|
||||||
|
$this->avatarMock->method('getFile')->willReturn($this->avatarFile);
|
||||||
|
$this->avatarManager->method('getAvatar')->with('userId')->willReturn($this->avatarMock);
|
||||||
|
|
||||||
|
$response = $this->avatarController->getAvatar('userId', 32);
|
||||||
|
|
||||||
|
$this->assertEquals(Http::STATUS_CREATED, $response->getStatus());
|
||||||
|
$this->assertArrayHasKey('Content-Type', $response->getHeaders());
|
||||||
|
$this->assertEquals('image type', $response->getHeaders()['Content-Type']);
|
||||||
|
|
||||||
|
$this->assertEquals('my etag', $response->getETag());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the avatar of a non-existing user
|
* Fetch the avatar of a non-existing user
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue