Fix avatarHome
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
48ea7251d7
commit
8614eb91db
|
@ -70,7 +70,7 @@ class AvatarHome implements ICollection {
|
||||||
throw new MethodNotAllowed('Invalid image size');
|
throw new MethodNotAllowed('Invalid image size');
|
||||||
}
|
}
|
||||||
$avatar = $this->avatarManager->getAvatar($this->getName());
|
$avatar = $this->avatarManager->getAvatar($this->getName());
|
||||||
if ($avatar === null || !$avatar->exists()) {
|
if (!$avatar->exists()) {
|
||||||
throw new NotFound();
|
throw new NotFound();
|
||||||
}
|
}
|
||||||
return new AvatarNode($size, $ext, $avatar);
|
return new AvatarNode($size, $ext, $avatar);
|
||||||
|
|
|
@ -86,11 +86,10 @@ class AvatarHomeTest extends TestCase {
|
||||||
if ($expectedException !== null) {
|
if ($expectedException !== null) {
|
||||||
$this->expectException($expectedException);
|
$this->expectException($expectedException);
|
||||||
}
|
}
|
||||||
$avatar = null;
|
|
||||||
if ($hasAvatar) {
|
$avatar = $this->createMock(IAvatar::class);
|
||||||
$avatar = $this->createMock(IAvatar::class);
|
$avatar->method('exists')->willReturn($hasAvatar);
|
||||||
$avatar->expects($this->once())->method('exists')->willReturn(true);
|
|
||||||
}
|
|
||||||
$this->avatarManager->expects($this->any())->method('getAvatar')->with('admin')->willReturn($avatar);
|
$this->avatarManager->expects($this->any())->method('getAvatar')->with('admin')->willReturn($avatar);
|
||||||
$avatarNode = $this->home->getChild($path);
|
$avatarNode = $this->home->getChild($path);
|
||||||
$this->assertInstanceOf(AvatarNode::class, $avatarNode);
|
$this->assertInstanceOf(AvatarNode::class, $avatarNode);
|
||||||
|
@ -111,11 +110,9 @@ class AvatarHomeTest extends TestCase {
|
||||||
* @dataProvider providesTestGetChild
|
* @dataProvider providesTestGetChild
|
||||||
*/
|
*/
|
||||||
public function testChildExists($expectedException, $hasAvatar, $path) {
|
public function testChildExists($expectedException, $hasAvatar, $path) {
|
||||||
$avatar = null;
|
$avatar = $this->createMock(IAvatar::class);
|
||||||
if ($hasAvatar) {
|
$avatar->method('exists')->willReturn($hasAvatar);
|
||||||
$avatar = $this->createMock(IAvatar::class);
|
|
||||||
$avatar->expects($this->once())->method('exists')->willReturn(true);
|
|
||||||
}
|
|
||||||
$this->avatarManager->expects($this->any())->method('getAvatar')->with('admin')->willReturn($avatar);
|
$this->avatarManager->expects($this->any())->method('getAvatar')->with('admin')->willReturn($avatar);
|
||||||
$childExists = $this->home->childExists($path);
|
$childExists = $this->home->childExists($path);
|
||||||
$this->assertEquals($hasAvatar, $childExists);
|
$this->assertEquals($hasAvatar, $childExists);
|
||||||
|
|
Loading…
Reference in New Issue