summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2018-01-17 13:46:18 +0100
committerGitHub <noreply@github.com>2018-01-17 13:46:18 +0100
commitf8756d96bc7821a1082dd19cb8aea6d0b933505a (patch)
tree7fc39b205b0f38948fb6965eae8b693ecb4d0055 /apps/dav
parent73cc4ac1f688cb181e3072490699f054b8c91e8c (diff)
parent8614eb91db754eec7904841e44fbbbc63ffb013a (diff)
downloadnextcloud-server-f8756d96bc7821a1082dd19cb8aea6d0b933505a.tar.gz
nextcloud-server-f8756d96bc7821a1082dd19cb8aea6d0b933505a.zip
Merge pull request #7847 from nextcloud/avatarmanager_strict
Fixes for avatarmanager
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/Avatars/AvatarHome.php2
-rw-r--r--apps/dav/tests/unit/Avatars/AvatarHomeTest.php17
2 files changed, 8 insertions, 11 deletions
diff --git a/apps/dav/lib/Avatars/AvatarHome.php b/apps/dav/lib/Avatars/AvatarHome.php
index ee654f2aaa2..2047c5894e4 100644
--- a/apps/dav/lib/Avatars/AvatarHome.php
+++ b/apps/dav/lib/Avatars/AvatarHome.php
@@ -70,7 +70,7 @@ class AvatarHome implements ICollection {
throw new MethodNotAllowed('Invalid image size');
}
$avatar = $this->avatarManager->getAvatar($this->getName());
- if ($avatar === null || !$avatar->exists()) {
+ if (!$avatar->exists()) {
throw new NotFound();
}
return new AvatarNode($size, $ext, $avatar);
diff --git a/apps/dav/tests/unit/Avatars/AvatarHomeTest.php b/apps/dav/tests/unit/Avatars/AvatarHomeTest.php
index aa5c4bf3049..2dffa8b7424 100644
--- a/apps/dav/tests/unit/Avatars/AvatarHomeTest.php
+++ b/apps/dav/tests/unit/Avatars/AvatarHomeTest.php
@@ -86,11 +86,10 @@ class AvatarHomeTest extends TestCase {
if ($expectedException !== null) {
$this->expectException($expectedException);
}
- $avatar = null;
- if ($hasAvatar) {
- $avatar = $this->createMock(IAvatar::class);
- $avatar->expects($this->once())->method('exists')->willReturn(true);
- }
+
+ $avatar = $this->createMock(IAvatar::class);
+ $avatar->method('exists')->willReturn($hasAvatar);
+
$this->avatarManager->expects($this->any())->method('getAvatar')->with('admin')->willReturn($avatar);
$avatarNode = $this->home->getChild($path);
$this->assertInstanceOf(AvatarNode::class, $avatarNode);
@@ -111,11 +110,9 @@ class AvatarHomeTest extends TestCase {
* @dataProvider providesTestGetChild
*/
public function testChildExists($expectedException, $hasAvatar, $path) {
- $avatar = null;
- if ($hasAvatar) {
- $avatar = $this->createMock(IAvatar::class);
- $avatar->expects($this->once())->method('exists')->willReturn(true);
- }
+ $avatar = $this->createMock(IAvatar::class);
+ $avatar->method('exists')->willReturn($hasAvatar);
+
$this->avatarManager->expects($this->any())->method('getAvatar')->with('admin')->willReturn($avatar);
$childExists = $this->home->childExists($path);
$this->assertEquals($hasAvatar, $childExists);