Skip to content

Commit 6336eac

Browse files
committed
chore: setting test metadata in annotations is deprecated (use attributes)
Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent b2ffff3 commit 6336eac

File tree

5 files changed

+14
-32
lines changed

5 files changed

+14
-32
lines changed

apps/dav/tests/unit/Listener/OutOfOfficeListenerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636
use Sabre\VObject\Reader;
3737
use Test\TestCase;
3838

39-
/**
40-
* @covers \OCA\DAV\Listener\OutOfOfficeListener
41-
*/
39+
#[\PHPUnit\Framework\Attributes\CoversClass(OutOfOfficeListener::class)]
4240
class OutOfOfficeListenerTest extends TestCase {
4341

4442
private ServerFactory&MockObject $serverFactory;

apps/settings/tests/SetupChecks/AppDirsWithDifferentOwnerTest.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010

1111
use OCA\Settings\SetupChecks\AppDirsWithDifferentOwner;
1212
use OCP\IL10N;
13+
use PHPUnit\Framework\MockObject\MockObject;
1314
use Test\TestCase;
1415

1516
class AppDirsWithDifferentOwnerTest extends TestCase {
16-
private IL10N $l10n;
1717
private AppDirsWithDifferentOwner $check;
1818

19+
private IL10N&MockObject $l10n;
20+
1921
/**
2022
* Holds a list of directories created during tests.
2123
*
@@ -42,8 +44,6 @@ protected function setUp(): void {
4244
* Then calls the 'getAppDirsWithDifferentOwner' method.
4345
* The result is expected to be empty since
4446
* there are no directories with different owners than the current user.
45-
*
46-
* @return void
4747
*/
4848
public function testAppDirectoryOwnersOk(): void {
4949
$tempDir = tempnam(sys_get_temp_dir(), 'apps') . 'dir';
@@ -69,8 +69,6 @@ public function testAppDirectoryOwnersOk(): void {
6969
/**
7070
* Calls the check for a none existing app root that is marked as not writable.
7171
* It's expected that no error happens since the check shouldn't apply.
72-
*
73-
* @return void
7472
*/
7573
public function testAppDirectoryOwnersNotWritable(): void {
7674
$tempDir = tempnam(sys_get_temp_dir(), 'apps') . 'dir';
@@ -89,11 +87,9 @@ public function testAppDirectoryOwnersNotWritable(): void {
8987

9088
/**
9189
* Removes directories created during tests.
92-
*
93-
* @after
94-
* @return void
9590
*/
96-
public function removeTestDirectories() {
91+
#[\PHPUnit\Framework\Attributes\After()]
92+
public function removeTestDirectories(): void {
9793
foreach ($this->dirsToRemove as $dirToRemove) {
9894
rmdir($dirToRemove);
9995
}

tests/lib/Avatar/GuestAvatarTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ class GuestAvatarTest extends TestCase {
2929

3030
/**
3131
* Setups a guest avatar instance for tests.
32-
*
33-
* @before
34-
* @return void
3532
*/
36-
public function setupGuestAvatar() {
33+
#[\PHPUnit\Framework\Attributes\Before()]
34+
public function setupGuestAvatar(): void {
3735
/* @var MockObject|LoggerInterface $logger */
3836
$logger = $this->createMock(LoggerInterface::class);
3937
$config = $this->createMock(IConfig::class);

tests/lib/Files/SimpleFS/InMemoryFileTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,14 @@
2121
class InMemoryFileTest extends TestCase {
2222
/**
2323
* Holds a pdf file with know attributes for tests.
24-
*
25-
* @var InMemoryFile
2624
*/
27-
private $testPdf;
25+
private InMemoryFile $testPdf;
2826

2927
/**
3028
* Sets the test file from "./resources/test.pdf".
31-
*
32-
* @before
33-
* @return void
3429
*/
35-
public function setupTestPdf() {
30+
#[\PHPUnit\Framework\Attributes\Before()]
31+
public function setupTestPdf(): void {
3632
$fileContents = file_get_contents(
3733
__DIR__ . '/../../../data/test.pdf'
3834
);

tests/lib/MemoryInfoTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,15 @@
1818
class MemoryInfoTest extends TestCase {
1919
/**
2020
* The "memory_limit" value before tests.
21-
*
22-
* @var string
2321
*/
24-
private $iniSettingBeforeTest;
22+
private string $iniSettingBeforeTest;
2523

26-
/**
27-
* @beforeClass
28-
*/
24+
#[\PHPUnit\Framework\Attributes\BeforeClass()]
2925
public function backupMemoryInfoIniSetting() {
3026
$this->iniSettingBeforeTest = ini_get('memory_limit');
3127
}
3228

33-
/**
34-
* @afterClass
35-
*/
29+
#[\PHPUnit\Framework\Attributes\AfterClass()]
3630
public function restoreMemoryInfoIniSetting() {
3731
ini_set('memory_limit', $this->iniSettingBeforeTest);
3832
}

0 commit comments

Comments
 (0)