aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/AppFramework
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2025-06-30 16:56:59 +0200
committerRobin Appelman <robin@icewind.nl>2025-07-01 22:45:52 +0200
commitaa15f9d16d5b46d04763c7deedb129990e819364 (patch)
tree758e0aebcac34a545f9a21806120a9fcb96f4cb6 /tests/lib/AppFramework
parent1620a0c0510a42b1da0a66488838f1ce3ba1210d (diff)
downloadnextcloud-server-rector-phpunit10.tar.gz
nextcloud-server-rector-phpunit10.zip
chore: run rectorrector-phpunit10
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests/lib/AppFramework')
-rw-r--r--tests/lib/AppFramework/AppTest.php4
-rw-r--r--tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php4
-rw-r--r--tests/lib/AppFramework/Controller/PublicShareControllerTest.php4
-rw-r--r--tests/lib/AppFramework/Db/EntityTest.php4
-rw-r--r--tests/lib/AppFramework/Db/QBMapperDBTest.php2
-rw-r--r--tests/lib/AppFramework/Db/TransactionalTest.php14
-rw-r--r--tests/lib/AppFramework/Http/DispatcherTest.php6
-rw-r--r--tests/lib/AppFramework/Http/DownloadResponseTest.php4
-rw-r--r--tests/lib/AppFramework/Http/JSONResponseTest.php2
-rw-r--r--tests/lib/AppFramework/Http/RequestTest.php36
-rw-r--r--tests/lib/AppFramework/Http/ResponseTest.php2
-rw-r--r--tests/lib/AppFramework/Http/TemplateResponseTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php4
-rw-r--r--tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php16
-rw-r--r--tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php4
-rw-r--r--tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php32
-rw-r--r--tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php8
-rw-r--r--tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php100
-rw-r--r--tests/lib/AppFramework/OCS/V2ResponseTest.php4
-rw-r--r--tests/lib/AppFramework/Services/AppConfigTest.php57
-rw-r--r--tests/lib/AppFramework/Utility/SimpleContainerTest.php4
21 files changed, 99 insertions, 214 deletions
diff --git a/tests/lib/AppFramework/AppTest.php b/tests/lib/AppFramework/AppTest.php
index 64b4bccbac6..c43cd8e3c54 100644
--- a/tests/lib/AppFramework/AppTest.php
+++ b/tests/lib/AppFramework/AppTest.php
@@ -132,9 +132,7 @@ class AppTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataNoOutput
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoOutput')]
public function testNoOutput(string $statusCode): void {
$return = [$statusCode, [], [], $this->output, new Response()];
$this->dispatcher->expects($this->once())
diff --git a/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php b/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php
index 6469a01cce3..c0095713370 100644
--- a/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php
+++ b/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php
@@ -68,9 +68,7 @@ class RegistrationContextTest extends TestCase {
$this->context->delegateEventListenerRegistrations($dispatcher);
}
- /**
- * @dataProvider dataProvider_TrueFalse
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataProvider_TrueFalse')]
public function testRegisterService(bool $shared): void {
$app = $this->createMock(App::class);
$service = 'abc';
diff --git a/tests/lib/AppFramework/Controller/PublicShareControllerTest.php b/tests/lib/AppFramework/Controller/PublicShareControllerTest.php
index 48ec17b3edf..e676b8a0d7e 100644
--- a/tests/lib/AppFramework/Controller/PublicShareControllerTest.php
+++ b/tests/lib/AppFramework/Controller/PublicShareControllerTest.php
@@ -68,9 +68,7 @@ class PublicShareControllerTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataIsAuthenticated
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataIsAuthenticated')]
public function testIsAuthenticatedNotPasswordProtected(bool $protected, string $token1, string $token2, string $hash1, string $hash2, bool $expected): void {
$controller = new TestController('app', $this->request, $this->session, $hash2, $protected);
diff --git a/tests/lib/AppFramework/Db/EntityTest.php b/tests/lib/AppFramework/Db/EntityTest.php
index 4fcf126e3b1..eab081e6ac6 100644
--- a/tests/lib/AppFramework/Db/EntityTest.php
+++ b/tests/lib/AppFramework/Db/EntityTest.php
@@ -225,9 +225,7 @@ class EntityTest extends \Test\TestCase {
}
- /**
- * @dataProvider dataSetterCasts
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataSetterCasts')]
public function testSetterCasts(string $field, mixed $in, mixed $out): void {
$entity = new TestEntity();
$entity->{'set' . $field}($in);
diff --git a/tests/lib/AppFramework/Db/QBMapperDBTest.php b/tests/lib/AppFramework/Db/QBMapperDBTest.php
index 8ad8c43bed8..614f1099644 100644
--- a/tests/lib/AppFramework/Db/QBMapperDBTest.php
+++ b/tests/lib/AppFramework/Db/QBMapperDBTest.php
@@ -64,7 +64,7 @@ class QBDBTestMapper extends QBMapper {
* @group DB
*/
class QBMapperDBTest extends TestCase {
- /** @var \Doctrine\DBAL\Connection|\OCP\IDBConnection */
+ /** @var \Doctrine\DBAL\Connection|IDBConnection */
protected $connection;
protected $schemaSetup = false;
diff --git a/tests/lib/AppFramework/Db/TransactionalTest.php b/tests/lib/AppFramework/Db/TransactionalTest.php
index bf8abcd7aa2..72a3d9ae59f 100644
--- a/tests/lib/AppFramework/Db/TransactionalTest.php
+++ b/tests/lib/AppFramework/Db/TransactionalTest.php
@@ -28,10 +28,9 @@ class TransactionalTest extends TestCase {
$test = new class($this->db) {
use TTransactional;
- private IDBConnection $db;
-
- public function __construct(IDBConnection $db) {
- $this->db = $db;
+ public function __construct(
+ private IDBConnection $db,
+ ) {
}
public function fail(): void {
@@ -55,10 +54,9 @@ class TransactionalTest extends TestCase {
$test = new class($this->db) {
use TTransactional;
- private IDBConnection $db;
-
- public function __construct(IDBConnection $db) {
- $this->db = $db;
+ public function __construct(
+ private IDBConnection $db,
+ ) {
}
public function succeed(): int {
diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php
index 4ed6627891c..86c78e840e0 100644
--- a/tests/lib/AppFramework/Http/DispatcherTest.php
+++ b/tests/lib/AppFramework/Http/DispatcherTest.php
@@ -32,7 +32,7 @@ use Psr\Log\LoggerInterface;
class TestController extends Controller {
/**
* @param string $appName
- * @param \OCP\IRequest $request
+ * @param IRequest $request
*/
public function __construct($appName, $request) {
parent::__construct($appName, $request);
@@ -547,9 +547,7 @@ class DispatcherTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider rangeDataProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('rangeDataProvider')]
public function testEnsureParameterValueSatisfiesRange(int $min, int $max, int $input, bool $throw): void {
$this->reflector = $this->createMock(ControllerMethodReflector::class);
$this->reflector->expects($this->any())
diff --git a/tests/lib/AppFramework/Http/DownloadResponseTest.php b/tests/lib/AppFramework/Http/DownloadResponseTest.php
index cf179ba270b..b2f60edd999 100644
--- a/tests/lib/AppFramework/Http/DownloadResponseTest.php
+++ b/tests/lib/AppFramework/Http/DownloadResponseTest.php
@@ -27,9 +27,7 @@ class DownloadResponseTest extends \Test\TestCase {
$this->assertEquals('content', $headers['Content-Type']);
}
- /**
- * @dataProvider filenameEncodingProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('filenameEncodingProvider')]
public function testFilenameEncoding(string $input, string $expected): void {
$response = new ChildDownloadResponse($input, 'content');
$headers = $response->getHeaders();
diff --git a/tests/lib/AppFramework/Http/JSONResponseTest.php b/tests/lib/AppFramework/Http/JSONResponseTest.php
index 703e6d89dd1..56f67b23f0d 100644
--- a/tests/lib/AppFramework/Http/JSONResponseTest.php
+++ b/tests/lib/AppFramework/Http/JSONResponseTest.php
@@ -58,10 +58,10 @@ class JSONResponseTest extends \Test\TestCase {
}
/**
- * @dataProvider renderDataProvider
* @param array $input
* @param string $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('renderDataProvider')]
public function testRender(array $input, $expected): void {
$this->json->setData($input);
$this->assertEquals($expected, $this->json->render());
diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php
index 7107131e031..a7ff123fc25 100644
--- a/tests/lib/AppFramework/Http/RequestTest.php
+++ b/tests/lib/AppFramework/Http/RequestTest.php
@@ -260,9 +260,7 @@ class RequestTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataNotJsonData
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNotJsonData')]
public function testNotJsonPost(string $testData): void {
global $data;
$data = $testData;
@@ -709,9 +707,7 @@ class RequestTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataGetRemoteAddress
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataGetRemoteAddress')]
public function testGetRemoteAddress(array $headers, array $trustedProxies, array $forwardedForHeaders, string $expected): void {
$this->config
->method('getSystemValue')
@@ -760,11 +756,11 @@ class RequestTest extends \Test\TestCase {
}
/**
- * @dataProvider dataHttpProtocol
*
* @param mixed $input
* @param string $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataHttpProtocol')]
public function testGetHttpProtocol($input, $expected): void {
$request = new Request(
[
@@ -950,11 +946,11 @@ class RequestTest extends \Test\TestCase {
}
/**
- * @dataProvider dataUserAgent
* @param string $testAgent
* @param array $userAgent
* @param bool $matches
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataUserAgent')]
public function testUserAgent($testAgent, $userAgent, $matches): void {
$request = new Request(
[
@@ -972,11 +968,11 @@ class RequestTest extends \Test\TestCase {
}
/**
- * @dataProvider dataUserAgent
* @param string $testAgent
* @param array $userAgent
* @param bool $matches
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataUserAgent')]
public function testUndefinedUserAgent($testAgent, $userAgent, $matches): void {
$request = new Request(
[],
@@ -1154,11 +1150,11 @@ class RequestTest extends \Test\TestCase {
}
/**
- * @dataProvider dataMatchClientVersion
* @param string $testAgent
* @param string $userAgent
* @param string $version
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataMatchClientVersion')]
public function testMatchClientVersion(string $testAgent, string $userAgent, string $version): void {
preg_match($userAgent, $testAgent, $matches);
@@ -1373,9 +1369,7 @@ class RequestTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataGetServerHostTrustedDomain
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataGetServerHostTrustedDomain')]
public function testGetServerHostTrustedDomain(string $expected, $trustedDomain): void {
$this->config
->method('getSystemValue')
@@ -1485,11 +1479,11 @@ class RequestTest extends \Test\TestCase {
}
/**
- * @dataProvider dataGenericPathInfo
* @param string $requestUri
* @param string $scriptName
* @param string $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataGenericPathInfo')]
public function testGetPathInfoWithoutSetEnvGeneric($requestUri, $scriptName, $expected): void {
$request = new Request(
[
@@ -1508,11 +1502,11 @@ class RequestTest extends \Test\TestCase {
}
/**
- * @dataProvider dataGenericPathInfo
* @param string $requestUri
* @param string $scriptName
* @param string $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataGenericPathInfo')]
public function testGetRawPathInfoWithoutSetEnvGeneric($requestUri, $scriptName, $expected): void {
$request = new Request(
[
@@ -1531,11 +1525,11 @@ class RequestTest extends \Test\TestCase {
}
/**
- * @dataProvider dataRawPathInfo
* @param string $requestUri
* @param string $scriptName
* @param string $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataRawPathInfo')]
public function testGetRawPathInfoWithoutSetEnv($requestUri, $scriptName, $expected): void {
$request = new Request(
[
@@ -1554,11 +1548,11 @@ class RequestTest extends \Test\TestCase {
}
/**
- * @dataProvider dataPathInfo
* @param string $requestUri
* @param string $scriptName
* @param string $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataPathInfo')]
public function testGetPathInfoWithoutSetEnv($requestUri, $scriptName, $expected): void {
$request = new Request(
[
@@ -1629,9 +1623,7 @@ class RequestTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataGetRequestUriWithOverwrite
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataGetRequestUriWithOverwrite')]
public function testGetRequestUriWithOverwrite($expectedUri, $overwriteWebRoot, $overwriteCondAddr, $remoteAddr = ''): void {
$this->config
->expects($this->exactly(2))
@@ -2184,9 +2176,7 @@ class RequestTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataInvalidToken
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataInvalidToken')]
public function testPassesCSRFCheckWithInvalidToken(string $invalidToken): void {
/** @var Request $request */
$request = $this->getMockBuilder(Request::class)
diff --git a/tests/lib/AppFramework/Http/ResponseTest.php b/tests/lib/AppFramework/Http/ResponseTest.php
index 7750db921c6..4c76695f6e4 100644
--- a/tests/lib/AppFramework/Http/ResponseTest.php
+++ b/tests/lib/AppFramework/Http/ResponseTest.php
@@ -16,7 +16,7 @@ use OCP\AppFramework\Utility\ITimeFactory;
class ResponseTest extends \Test\TestCase {
/**
- * @var \OCP\AppFramework\Http\Response
+ * @var Response
*/
private $childResponse;
diff --git a/tests/lib/AppFramework/Http/TemplateResponseTest.php b/tests/lib/AppFramework/Http/TemplateResponseTest.php
index ad0fe808b76..28f952e35e3 100644
--- a/tests/lib/AppFramework/Http/TemplateResponseTest.php
+++ b/tests/lib/AppFramework/Http/TemplateResponseTest.php
@@ -13,7 +13,7 @@ use OCP\AppFramework\Http\TemplateResponse;
class TemplateResponseTest extends \Test\TestCase {
/**
- * @var \OCP\AppFramework\Http\TemplateResponse
+ * @var TemplateResponse
*/
private $tpl;
diff --git a/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php b/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php
index 0abbd9c614c..7dcb28a2af4 100644
--- a/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php
@@ -54,9 +54,7 @@ class NotModifiedMiddlewareTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataModified
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataModified')]
public function testMiddleware(?string $etag, string $etagHeader, ?\DateTime $lastModified, string $lastModifiedHeader, bool $notModifiedSet): void {
$this->request->method('getHeader')
->willReturnCallback(function (string $name) use ($etagHeader, $lastModifiedHeader) {
diff --git a/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php
index 4d190ce6ba6..e5c6a417a4b 100644
--- a/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php
@@ -61,9 +61,7 @@ class OCSMiddlewareTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataAfterException
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataAfterException')]
public function testAfterExceptionOCSv1(string $controller, \Exception $exception, bool $forward, string $message = '', int $code = 0): void {
$controller = $this->createMock($controller);
$this->request
@@ -92,9 +90,7 @@ class OCSMiddlewareTest extends \Test\TestCase {
$this->assertSame(Http::STATUS_OK, $result->getStatus());
}
- /**
- * @dataProvider dataAfterException
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataAfterException')]
public function testAfterExceptionOCSv2(string $controller, \Exception $exception, bool $forward, string $message = '', int $code = 0): void {
$controller = $this->createMock($controller);
$this->request
@@ -121,9 +117,7 @@ class OCSMiddlewareTest extends \Test\TestCase {
$this->assertSame($code, $result->getStatus());
}
- /**
- * @dataProvider dataAfterException
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataAfterException')]
public function testAfterExceptionOCSv2SubFolder(string $controller, \Exception $exception, bool $forward, string $message = '', int $code = 0): void {
$controller = $this->createMock($controller);
$this->request
@@ -167,9 +161,7 @@ class OCSMiddlewareTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataAfterController
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataAfterController')]
public function testAfterController(string $controller, Response $response, bool $converted, int $convertedOCSStatus = 0): void {
$controller = $this->createMock($controller);
$OCSMiddleware = new OCSMiddleware($this->request);
diff --git a/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php b/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php
index b17dc9434ef..e87ee7fd565 100644
--- a/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php
@@ -67,9 +67,7 @@ class PublicShareMiddlewareTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataShareApi
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataShareApi')]
public function testBeforeControllerShareApiDisabled(string $shareApi, string $shareLinks): void {
$controller = $this->createMock(PublicShareController::class);
diff --git a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php
index f9ada6a93e2..c325ae638fb 100644
--- a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php
@@ -53,9 +53,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataSetCORSAPIHeader
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataSetCORSAPIHeader')]
public function testSetCORSAPIHeader(string $method): void {
$request = new Request(
[
@@ -98,9 +96,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataNoOriginHeaderNoCORSHEADER
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoOriginHeaderNoCORSHEADER')]
public function testNoOriginHeaderNoCORSHEADER(string $method): void {
$request = new Request(
[],
@@ -122,9 +118,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataCorsIgnoredIfWithCredentialsHeaderPresent
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataCorsIgnoredIfWithCredentialsHeaderPresent')]
public function testCorsIgnoredIfWithCredentialsHeaderPresent(string $method): void {
$this->expectException(SecurityException::class);
@@ -154,9 +148,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataNoCORSOnAnonymousPublicPage
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCORSOnAnonymousPublicPage')]
public function testNoCORSOnAnonymousPublicPage(string $method): void {
$request = new Request(
[],
@@ -188,9 +180,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataCORSShouldNeverAllowCookieAuth
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataCORSShouldNeverAllowCookieAuth')]
public function testCORSShouldNeverAllowCookieAuth(string $method): void {
$request = new Request(
[],
@@ -220,9 +210,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataCORSShouldRelogin
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataCORSShouldRelogin')]
public function testCORSShouldRelogin(string $method): void {
$request = new Request(
['server' => [
@@ -251,9 +239,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataCORSShouldFailIfPasswordLoginIsForbidden
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataCORSShouldFailIfPasswordLoginIsForbidden')]
public function testCORSShouldFailIfPasswordLoginIsForbidden(string $method): void {
$this->expectException(SecurityException::class);
@@ -284,9 +270,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataCORSShouldNotAllowCookieAuth
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataCORSShouldNotAllowCookieAuth')]
public function testCORSShouldNotAllowCookieAuth(string $method): void {
$this->expectException(SecurityException::class);
diff --git a/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php
index a109ac839c4..90e801ca471 100644
--- a/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php
@@ -91,9 +91,7 @@ class PasswordConfirmationMiddlewareTest extends TestCase {
$this->middleware->beforeController($this->controller, __FUNCTION__);
}
- /**
- * @dataProvider dataProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataProvider')]
public function testAnnotation($backend, $lastConfirm, $currentTime, $exception): void {
$this->reflector->reflect($this->controller, __FUNCTION__);
@@ -126,9 +124,7 @@ class PasswordConfirmationMiddlewareTest extends TestCase {
$this->assertSame($exception, $thrown);
}
- /**
- * @dataProvider dataProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataProvider')]
public function testAttribute($backend, $lastConfirm, $currentTime, $exception): void {
$this->reflector->reflect($this->controller, __FUNCTION__);
diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
index 670e1cc7ca5..0c6fc21357d 100644
--- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
@@ -195,9 +195,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataNoCSRFRequiredPublicPage
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredPublicPage')]
public function testSetNavigationEntry(string $method): void {
$this->navigationManager->expects($this->once())
->method('setActiveEntry')
@@ -245,9 +243,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
);
}
- /**
- * @dataProvider dataNoCSRFRequired
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequired')]
public function testAjaxNotAdminCheck(string $method): void {
$this->ajaxExceptionStatus(
$method,
@@ -256,9 +252,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
);
}
- /**
- * @dataProvider dataPublicPage
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataPublicPage')]
public function testAjaxStatusCSRFCheck(string $method): void {
$this->ajaxExceptionStatus(
$method,
@@ -267,9 +261,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
);
}
- /**
- * @dataProvider dataNoCSRFRequiredPublicPage
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredPublicPage')]
public function testAjaxStatusAllGood(string $method): void {
$this->ajaxExceptionStatus(
$method,
@@ -288,9 +280,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
);
}
- /**
- * @dataProvider dataNoCSRFRequiredPublicPage
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredPublicPage')]
public function testNoChecks(string $method): void {
$this->request->expects($this->never())
->method('passesCSRFCheck')
@@ -329,9 +319,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
}
- /**
- * @dataProvider dataPublicPage
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataPublicPage')]
public function testCsrfCheck(string $method): void {
$this->expectException(CrossSiteRequestForgeryException::class);
@@ -345,9 +333,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$this->middleware->beforeController($this->controller, $method);
}
- /**
- * @dataProvider dataNoCSRFRequiredPublicPage
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredPublicPage')]
public function testNoCsrfCheck(string $method): void {
$this->request->expects($this->never())
->method('passesCSRFCheck')
@@ -357,9 +343,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$this->middleware->beforeController($this->controller, $method);
}
- /**
- * @dataProvider dataPublicPage
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataPublicPage')]
public function testPassesCsrfCheck(string $method): void {
$this->request->expects($this->once())
->method('passesCSRFCheck')
@@ -372,9 +356,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$this->middleware->beforeController($this->controller, $method);
}
- /**
- * @dataProvider dataPublicPage
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataPublicPage')]
public function testFailCsrfCheck(string $method): void {
$this->expectException(CrossSiteRequestForgeryException::class);
@@ -389,9 +371,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$this->middleware->beforeController($this->controller, $method);
}
- /**
- * @dataProvider dataPublicPageStrictCookieRequired
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataPublicPageStrictCookieRequired')]
public function testStrictCookieRequiredCheck(string $method): void {
$this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\StrictCookieMissingException::class);
@@ -405,9 +385,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$this->middleware->beforeController($this->controller, $method);
}
- /**
- * @dataProvider dataNoCSRFRequiredPublicPage
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredPublicPage')]
public function testNoStrictCookieRequiredCheck(string $method): void {
$this->request->expects($this->never())
->method('passesStrictCookieCheck')
@@ -417,9 +395,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$this->middleware->beforeController($this->controller, $method);
}
- /**
- * @dataProvider dataNoCSRFRequiredPublicPageStrictCookieRequired
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredPublicPageStrictCookieRequired')]
public function testPassesStrictCookieRequiredCheck(string $method): void {
$this->request
->expects($this->once())
@@ -445,12 +421,12 @@ class SecurityMiddlewareTest extends \Test\TestCase {
}
/**
- * @dataProvider dataCsrfOcsController
* @param string $controllerClass
* @param bool $hasOcsApiHeader
* @param bool $hasBearerAuth
* @param bool $exception
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataCsrfOcsController')]
public function testCsrfOcsController(string $controllerClass, bool $hasOcsApiHeader, bool $hasBearerAuth, bool $exception): void {
$this->request
->method('getHeader')
@@ -477,30 +453,22 @@ class SecurityMiddlewareTest extends \Test\TestCase {
}
}
- /**
- * @dataProvider dataNoAdminRequiredNoCSRFRequired
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoAdminRequiredNoCSRFRequired')]
public function testLoggedInCheck(string $method): void {
$this->securityCheck($method, 'isLoggedIn');
}
- /**
- * @dataProvider dataNoAdminRequiredNoCSRFRequired
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoAdminRequiredNoCSRFRequired')]
public function testFailLoggedInCheck(string $method): void {
$this->securityCheck($method, 'isLoggedIn', true);
}
- /**
- * @dataProvider dataNoCSRFRequired
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequired')]
public function testIsAdminCheck(string $method): void {
$this->securityCheck($method, 'isAdminUser');
}
- /**
- * @dataProvider dataNoCSRFRequiredSubAdminRequired
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredSubAdminRequired')]
public function testIsNotSubAdminCheck(string $method): void {
$this->reader->reflect($this->controller, $method);
$sec = $this->getMiddleware(true, false, false);
@@ -509,9 +477,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$sec->beforeController($this->controller, $method);
}
- /**
- * @dataProvider dataNoCSRFRequiredSubAdminRequired
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredSubAdminRequired')]
public function testIsSubAdminCheck(string $method): void {
$this->reader->reflect($this->controller, $method);
$sec = $this->getMiddleware(true, false, true);
@@ -520,9 +486,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
- /**
- * @dataProvider dataNoCSRFRequiredSubAdminRequired
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredSubAdminRequired')]
public function testIsSubAdminAndAdminCheck(string $method): void {
$this->reader->reflect($this->controller, $method);
$sec = $this->getMiddleware(true, true, true);
@@ -531,16 +495,12 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
- /**
- * @dataProvider dataNoCSRFRequired
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequired')]
public function testFailIsAdminCheck(string $method): void {
$this->securityCheck($method, 'isAdminUser', true);
}
- /**
- * @dataProvider dataNoAdminRequiredNoCSRFRequiredPublicPage
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoAdminRequiredNoCSRFRequiredPublicPage')]
public function testRestrictedAppLoggedInPublicPage(string $method): void {
$middleware = $this->getMiddleware(true, false, false);
$this->reader->reflect($this->controller, $method);
@@ -557,9 +517,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
- /**
- * @dataProvider dataNoAdminRequiredNoCSRFRequiredPublicPage
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoAdminRequiredNoCSRFRequiredPublicPage')]
public function testRestrictedAppNotLoggedInPublicPage(string $method): void {
$middleware = $this->getMiddleware(false, false, false);
$this->reader->reflect($this->controller, $method);
@@ -576,9 +534,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
- /**
- * @dataProvider dataNoAdminRequiredNoCSRFRequired
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoAdminRequiredNoCSRFRequired')]
public function testRestrictedAppLoggedIn(string $method): void {
$middleware = $this->getMiddleware(true, false, false, false);
$this->reader->reflect($this->controller, $method);
@@ -675,9 +631,9 @@ class SecurityMiddlewareTest extends \Test\TestCase {
}
/**
- * @dataProvider exceptionProvider
* @param SecurityException $exception
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('exceptionProvider')]
public function testAfterExceptionReturnsTemplateResponse(SecurityException $exception): void {
$this->request = new Request(
[
@@ -711,9 +667,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$this->assertTrue($response instanceof JSONResponse);
}
- /**
- * @dataProvider dataExAppRequired
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataExAppRequired')]
public function testExAppRequired(string $method): void {
$middleware = $this->getMiddleware(true, false, false);
$this->reader->reflect($this->controller, $method);
@@ -732,9 +686,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$middleware->beforeController($this->controller, $method);
}
- /**
- * @dataProvider dataExAppRequired
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataExAppRequired')]
public function testExAppRequiredError(string $method): void {
$middleware = $this->getMiddleware(true, false, false, false);
$this->reader->reflect($this->controller, $method);
diff --git a/tests/lib/AppFramework/OCS/V2ResponseTest.php b/tests/lib/AppFramework/OCS/V2ResponseTest.php
index 0037763f163..7a70ad6d633 100644
--- a/tests/lib/AppFramework/OCS/V2ResponseTest.php
+++ b/tests/lib/AppFramework/OCS/V2ResponseTest.php
@@ -15,9 +15,7 @@ use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
class V2ResponseTest extends \Test\TestCase {
- /**
- * @dataProvider providesStatusCodes
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('providesStatusCodes')]
public function testStatusCodeMapper(int $expected, int $sc): void {
$response = new V2Response(new DataResponse([], $sc));
$this->assertEquals($expected, $response->getStatus());
diff --git a/tests/lib/AppFramework/Services/AppConfigTest.php b/tests/lib/AppFramework/Services/AppConfigTest.php
index 718817a7636..38fa6bdcac6 100644
--- a/tests/lib/AppFramework/Services/AppConfigTest.php
+++ b/tests/lib/AppFramework/Services/AppConfigTest.php
@@ -57,11 +57,11 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerHasAppKey
*
* @param bool $lazy
* @param bool $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerHasAppKey')]
public function testHasAppKey(bool $lazy, bool $expected): void {
$key = 'key';
$this->appConfigCore->expects($this->once())
@@ -87,11 +87,11 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerIsSensitive
*
* @param bool $lazy
* @param bool $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerIsSensitive')]
public function testIsSensitive(bool $lazy, bool $expected): void {
$key = 'key';
$this->appConfigCore->expects($this->once())
@@ -103,11 +103,11 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerIsSensitive
*
* @param bool $lazy
* @param bool $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerIsSensitive')]
public function testIsSensitiveException(bool $lazy, bool $expected): void {
$key = 'unknown-key';
$this->appConfigCore->expects($this->once())
@@ -132,10 +132,9 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerIsLazy
- *
* @param bool $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerIsLazy')]
public function testIsLazy(bool $expected): void {
$key = 'key';
$this->appConfigCore->expects($this->once())
@@ -172,11 +171,11 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerGetAllAppValues
*
* @param string $key
* @param bool $filtered
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerGetAllAppValues')]
public function testGetAllAppValues(string $key, bool $filtered): void {
$expected = [
'key1' => 'value1',
@@ -229,12 +228,12 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerSetAppValue
*
* @param bool $lazy
* @param bool $sensitive
* @param bool $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerSetAppValue')]
public function testSetAppValueString(bool $lazy, bool $sensitive, bool $expected): void {
$key = 'key';
$value = 'valueString';
@@ -247,11 +246,11 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerSetAppValue
*
* @param bool $lazy
* @param bool $sensitive
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerSetAppValue')]
public function testSetAppValueStringException(bool $lazy, bool $sensitive): void {
$key = 'key';
$value = 'valueString';
@@ -265,12 +264,12 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerSetAppValue
*
* @param bool $lazy
* @param bool $sensitive
* @param bool $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerSetAppValue')]
public function testSetAppValueInt(bool $lazy, bool $sensitive, bool $expected): void {
$key = 'key';
$value = 42;
@@ -283,11 +282,11 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerSetAppValue
*
* @param bool $lazy
* @param bool $sensitive
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerSetAppValue')]
public function testSetAppValueIntException(bool $lazy, bool $sensitive): void {
$key = 'key';
$value = 42;
@@ -301,12 +300,12 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerSetAppValue
*
* @param bool $lazy
* @param bool $sensitive
* @param bool $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerSetAppValue')]
public function testSetAppValueFloat(bool $lazy, bool $sensitive, bool $expected): void {
$key = 'key';
$value = 3.14;
@@ -319,11 +318,11 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerSetAppValue
*
* @param bool $lazy
* @param bool $sensitive
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerSetAppValue')]
public function testSetAppValueFloatException(bool $lazy, bool $sensitive): void {
$key = 'key';
$value = 3.14;
@@ -351,11 +350,11 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerSetAppValueBool
*
* @param bool $lazy
* @param bool $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerSetAppValueBool')]
public function testSetAppValueBool(bool $lazy, bool $expected): void {
$key = 'key';
$value = true;
@@ -368,10 +367,9 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerSetAppValueBool
- *
* @param bool $lazy
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerSetAppValueBool')]
public function testSetAppValueBoolException(bool $lazy): void {
$key = 'key';
$value = true;
@@ -385,12 +383,12 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerSetAppValue
*
* @param bool $lazy
* @param bool $sensitive
* @param bool $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerSetAppValue')]
public function testSetAppValueArray(bool $lazy, bool $sensitive, bool $expected): void {
$key = 'key';
$value = ['item' => true];
@@ -403,11 +401,11 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerSetAppValue
*
* @param bool $lazy
* @param bool $sensitive
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerSetAppValue')]
public function testSetAppValueArrayException(bool $lazy, bool $sensitive): void {
$key = 'key';
$value = ['item' => true];
@@ -467,11 +465,11 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerGetAppValue
*
* @param bool $lazy
* @param bool $exist
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerGetAppValue')]
public function testGetAppValueString(bool $lazy, bool $exist): void {
$key = 'key';
$value = 'valueString';
@@ -487,10 +485,9 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerGetAppValue
- *
* @param bool $lazy
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerGetAppValue')]
public function testGetAppValueStringException(bool $lazy): void {
$key = 'key';
$default = 'default';
@@ -505,11 +502,11 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerGetAppValue
*
* @param bool $lazy
* @param bool $exist
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerGetAppValue')]
public function testGetAppValueInt(bool $lazy, bool $exist): void {
$key = 'key';
$value = 42;
@@ -525,10 +522,9 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerGetAppValue
- *
* @param bool $lazy
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerGetAppValue')]
public function testGetAppValueIntException(bool $lazy): void {
$key = 'key';
$default = 17;
@@ -543,11 +539,11 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerGetAppValue
*
* @param bool $lazy
* @param bool $exist
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerGetAppValue')]
public function testGetAppValueFloat(bool $lazy, bool $exist): void {
$key = 'key';
$value = 3.14;
@@ -563,10 +559,9 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerGetAppValue
- *
* @param bool $lazy
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerGetAppValue')]
public function testGetAppValueFloatException(bool $lazy): void {
$key = 'key';
$default = 17.04;
@@ -581,11 +576,11 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerGetAppValue
*
* @param bool $lazy
* @param bool $exist
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerGetAppValue')]
public function testGetAppValueBool(bool $lazy, bool $exist): void {
$key = 'key';
$value = true;
@@ -601,10 +596,9 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerGetAppValue
- *
* @param bool $lazy
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerGetAppValue')]
public function testGetAppValueBoolException(bool $lazy): void {
$key = 'key';
$default = false;
@@ -619,11 +613,11 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerGetAppValue
*
* @param bool $lazy
* @param bool $exist
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerGetAppValue')]
public function testGetAppValueArray(bool $lazy, bool $exist): void {
$key = 'key';
$value = ['item' => true];
@@ -639,10 +633,9 @@ class AppConfigTest extends TestCase {
}
/**
- * @dataProvider providerGetAppValue
- *
* @param bool $lazy
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('providerGetAppValue')]
public function testGetAppValueArrayException(bool $lazy): void {
$key = 'key';
$default = [];
diff --git a/tests/lib/AppFramework/Utility/SimpleContainerTest.php b/tests/lib/AppFramework/Utility/SimpleContainerTest.php
index 93db01d3bc8..33800c7376f 100644
--- a/tests/lib/AppFramework/Utility/SimpleContainerTest.php
+++ b/tests/lib/AppFramework/Utility/SimpleContainerTest.php
@@ -201,9 +201,7 @@ class SimpleContainerTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider sanitizeNameProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('sanitizeNameProvider')]
public function testSanitizeName($register, $query): void {
$this->container->registerService($register, function () {
return 'abc';