chore: setting test metadata in annotations is deprecated (use attributes)

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/55870/head
Ferdinand Thiessen 2025-10-28 00:53:56 +07:00
parent b2ffff385a
commit 6336eac6a5
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
5 changed files with 14 additions and 32 deletions

@ -36,9 +36,7 @@ use Sabre\VObject\Component\VEvent;
use Sabre\VObject\Reader;
use Test\TestCase;
/**
* @covers \OCA\DAV\Listener\OutOfOfficeListener
*/
#[\PHPUnit\Framework\Attributes\CoversClass(OutOfOfficeListener::class)]
class OutOfOfficeListenerTest extends TestCase {
private ServerFactory&MockObject $serverFactory;

@ -10,12 +10,14 @@ namespace OCA\Settings\Tests\SetupChecks;
use OCA\Settings\SetupChecks\AppDirsWithDifferentOwner;
use OCP\IL10N;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class AppDirsWithDifferentOwnerTest extends TestCase {
private IL10N $l10n;
private AppDirsWithDifferentOwner $check;
private IL10N&MockObject $l10n;
/**
* Holds a list of directories created during tests.
*
@ -42,8 +44,6 @@ class AppDirsWithDifferentOwnerTest extends TestCase {
* Then calls the 'getAppDirsWithDifferentOwner' method.
* The result is expected to be empty since
* there are no directories with different owners than the current user.
*
* @return void
*/
public function testAppDirectoryOwnersOk(): void {
$tempDir = tempnam(sys_get_temp_dir(), 'apps') . 'dir';
@ -69,8 +69,6 @@ class AppDirsWithDifferentOwnerTest extends TestCase {
/**
* Calls the check for a none existing app root that is marked as not writable.
* It's expected that no error happens since the check shouldn't apply.
*
* @return void
*/
public function testAppDirectoryOwnersNotWritable(): void {
$tempDir = tempnam(sys_get_temp_dir(), 'apps') . 'dir';
@ -89,11 +87,9 @@ class AppDirsWithDifferentOwnerTest extends TestCase {
/**
* Removes directories created during tests.
*
* @after
* @return void
*/
public function removeTestDirectories() {
#[\PHPUnit\Framework\Attributes\After()]
public function removeTestDirectories(): void {
foreach ($this->dirsToRemove as $dirToRemove) {
rmdir($dirToRemove);
}

@ -29,11 +29,9 @@ class GuestAvatarTest extends TestCase {
/**
* Setups a guest avatar instance for tests.
*
* @before
* @return void
*/
public function setupGuestAvatar() {
#[\PHPUnit\Framework\Attributes\Before()]
public function setupGuestAvatar(): void {
/* @var MockObject|LoggerInterface $logger */
$logger = $this->createMock(LoggerInterface::class);
$config = $this->createMock(IConfig::class);

@ -21,18 +21,14 @@ use Test\TestCase;
class InMemoryFileTest extends TestCase {
/**
* Holds a pdf file with know attributes for tests.
*
* @var InMemoryFile
*/
private $testPdf;
private InMemoryFile $testPdf;
/**
* Sets the test file from "./resources/test.pdf".
*
* @before
* @return void
*/
public function setupTestPdf() {
#[\PHPUnit\Framework\Attributes\Before()]
public function setupTestPdf(): void {
$fileContents = file_get_contents(
__DIR__ . '/../../../data/test.pdf'
);

@ -18,21 +18,15 @@ use PHPUnit\Framework\MockObject\MockObject;
class MemoryInfoTest extends TestCase {
/**
* The "memory_limit" value before tests.
*
* @var string
*/
private $iniSettingBeforeTest;
private string $iniSettingBeforeTest;
/**
* @beforeClass
*/
#[\PHPUnit\Framework\Attributes\BeforeClass()]
public function backupMemoryInfoIniSetting() {
$this->iniSettingBeforeTest = ini_get('memory_limit');
}
/**
* @afterClass
*/
#[\PHPUnit\Framework\Attributes\AfterClass()]
public function restoreMemoryInfoIniSetting() {
ini_set('memory_limit', $this->iniSettingBeforeTest);
}