Compare commits

...

1 Commits

Author SHA1 Message Date
Ferdinand Thiessen
e7cd783b98 chore: setting test metadata in annotations is deprecated (use attributes)
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2025-10-28 17:16:02 +01:00
5 changed files with 14 additions and 32 deletions

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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'
);

View File

@@ -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);
}