0
0
mirror of https://github.com/nextcloud/server.git synced 2024-12-29 00:18:42 +00:00
nextcloud_server/tests/lib/Avatar/GuestAvatarTest.php
Christoph Wurst 49dd79eabb
refactor: Add void return type to PHPUnit test methods
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2024-09-15 22:32:31 +02:00

66 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Avatar;
use OC\Avatar\GuestAvatar;
use OCP\Files\SimpleFS\InMemoryFile;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\TestCase;
/**
* This class provides test cases for the GuestAvatar class.
*
* @package Test\Avatar
*/
class GuestAvatarTest extends TestCase {
/**
* @var GuestAvatar
*/
private $guestAvatar;
/**
* Setups a guest avatar instance for tests.
*
* @before
* @return void
*/
public function setupGuestAvatar() {
/* @var MockObject|LoggerInterface $logger */
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
$this->guestAvatar = new GuestAvatar('einstein', $logger);
}
/**
* Asserts that testGet() returns the expected avatar.
*
* For the test a static name "einstein" is used and
* the generated image is compared with an expected one.
*/
public function testGet(): void {
$this->markTestSkipped('TODO: Disable because fails on drone');
$avatar = $this->guestAvatar->getFile(32);
self::assertInstanceOf(InMemoryFile::class, $avatar);
$expectedFile = file_get_contents(
__DIR__ . '/../../data/guest_avatar_einstein_32.png'
);
self::assertEquals(trim($expectedFile), trim($avatar->getContent()));
}
/**
* Asserts that "testIsCustomAvatar" returns false for guests.
*
* @return void
*/
public function testIsCustomAvatar(): void {
self::assertFalse($this->guestAvatar->isCustomAvatar());
}
}