logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); $this->request = $this->getMockBuilder(IRequest::class)->getMock(); $this->avatar = $this->getMockBuilder(IAvatar::class)->getMock(); $this->avatarManager = $this->getMockBuilder(IAvatarManager::class)->getMock(); $this->file = $this->getMockBuilder(ISimpleFile::class)->getMock(); $this->file->method('getName')->willReturn('my name'); $this->file->method('getMTime')->willReturn(42); $this->guestAvatarController = new GuestAvatarController( 'core', $this->request, $this->avatarManager, $this->logger ); } /** * Tests getAvatar returns the guest avatar. */ public function testGetAvatar(): void { $this->avatarManager->expects($this->once()) ->method('getGuestAvatar') ->with('Peter') ->willReturn($this->avatar); $this->avatar->expects($this->once()) ->method('getFile') ->with(512) ->willReturn($this->file); $this->file->method('getMimeType') ->willReturn('image/svg+xml'); $response = $this->guestAvatarController->getAvatar('Peter', 128); $this->assertGreaterThanOrEqual(201, $response->getStatus()); $this->assertInstanceOf(FileDisplayResponse::class, $response); } }