diff --git a/apps/dav/lib/Avatars/AvatarHome.php b/apps/dav/lib/Avatars/AvatarHome.php
index ee654f2aaa2b2d7bda3afa458d6663a3fce02e0a..2047c5894e49dcb6d20a82896a7c71a4048e255d 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 aa5c4bf304950e6f2b0661bf1722d3237313532a..2dffa8b7424ebfbf16ef62f22641e71988cdfaa2 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);