diff --git a/.docker/PHP83-Dockerfile b/.docker/PHP83-Dockerfile index 8b8c348e..4b2ffa60 100644 --- a/.docker/PHP83-Dockerfile +++ b/.docker/PHP83-Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.3.1-fpm +FROM php:8.3.3-fpm RUN apt-get update RUN apt-get --yes --no-install-recommends install \ diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e6bea5c4..f5dda41b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -77,7 +77,7 @@ jobs: - name: Upload coverage reports to Codecov if: ${{ matrix.tool == 'code-coverage' }} - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} files: ./.phpunit.cache/clover.xml diff --git a/composer.json b/composer.json index fea2c0eb..01382ecd 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "guzzlehttp/psr7": "^2", "php-mock/php-mock-phpunit": "^2.6", "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^9 || ^10.5" + "phpunit/phpunit": "^9.5 || ^10.5" }, "autoload": { "psr-4": { diff --git a/docker-compose.yml b/docker-compose.yml index 11861779..8ba6c8a5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,7 @@ services: - ./:/var/www/project/ # Location of the project for php-fpm. Note this should be the same for NGINX.* redmine-dev: - image: redmine:5.1.1 + image: redmine:5.1.2 user: "1000:1000" ports: - "3000:3000" @@ -26,8 +26,8 @@ services: # Make sure the following services are supported in /tests/RedmineExtension/RedmineInstance.php - redmine-50101: - image: redmine:5.1.1 + redmine-50102: + image: redmine:5.1.2 user: "1000:1000" ports: - "5101:3000" @@ -35,11 +35,11 @@ services: REDMINE_SECRET_KEY_BASE: supersecretkey REDMINE_PLUGINS_MIGRATE: true volumes: - - ./.docker/redmine-50101_data/files:/usr/src/redmine/files - - ./.docker/redmine-50101_data/sqlite:/usr/src/redmine/sqlite + - ./.docker/redmine-50102_data/files:/usr/src/redmine/files + - ./.docker/redmine-50102_data/sqlite:/usr/src/redmine/sqlite - redmine-50007: - image: redmine:5.0.7 + redmine-50008: + image: redmine:5.0.8 user: "1000:1000" ports: - "5007:3000" @@ -47,5 +47,5 @@ services: REDMINE_SECRET_KEY_BASE: supersecretkey REDMINE_PLUGINS_MIGRATE: true volumes: - - ./.docker/redmine-50007_data/files:/usr/src/redmine/files - - ./.docker/redmine-50007_data/sqlite:/usr/src/redmine/sqlite + - ./.docker/redmine-50008_data/files:/usr/src/redmine/files + - ./.docker/redmine-50008_data/sqlite:/usr/src/redmine/sqlite diff --git a/tests/Behat/behat.yml b/tests/Behat/behat.yml index cf006462..ee6fb477 100644 --- a/tests/Behat/behat.yml +++ b/tests/Behat/behat.yml @@ -1,14 +1,14 @@ default: suites: - redmine_50101: + redmine_50102: paths: - '%paths.base%/features' contexts: - Redmine\Tests\Behat\Bootstrap\FeatureContext: - redmineVersion: '5.1.1' - redmine_50007: + redmineVersion: '5.1.2' + redmine_50008: paths: - '%paths.base%/features' contexts: - Redmine\Tests\Behat\Bootstrap\FeatureContext: - redmineVersion: '5.0.7' + redmineVersion: '5.0.8' diff --git a/tests/Fixtures/AssertingHttpClient.php b/tests/Fixtures/AssertingHttpClient.php index 6ba12431..c6fb6ebc 100644 --- a/tests/Fixtures/AssertingHttpClient.php +++ b/tests/Fixtures/AssertingHttpClient.php @@ -4,6 +4,8 @@ namespace Redmine\Tests\Fixtures; +use PHPUnit\Framework\MockObject\MockBuilder; +use PHPUnit\Framework\MockObject\Rule\InvokedCount; use PHPUnit\Framework\TestCase; use Redmine\Http\HttpClient; use Redmine\Http\Request; @@ -21,8 +23,8 @@ public static function create(TestCase $testCase, array $dataSet, ...$dataSets): $dataSets = array_merge([$dataSet], $dataSets); /** @var \PHPUnit\Framework\MockObject\MockObject&HttpClient */ - $mock = $testCase->getMockBuilder(HttpClient::class)->getMock(); - $mock->expects($testCase->exactly(count($dataSets)))->method('request'); + $mock = (new MockBuilder($testCase, HttpClient::class))->getMock(); + $mock->expects(new InvokedCount(count($dataSets)))->method('request'); $client = new self($testCase, $mock); @@ -95,7 +97,7 @@ public function request(Request $request): Response } /** @var \PHPUnit\Framework\MockObject\MockObject&Response */ - $response = $this->testCase->getMockBuilder(Response::class)->getMock(); + $response = (new MockBuilder($this->testCase, Response::class))->getMock(); $response->method('getStatusCode')->willReturn($data['responseCode']); $response->method('getContentType')->willReturn($data['responseContentType']); diff --git a/tests/Integration/Psr18ClientRequestGenerationTest.php b/tests/Integration/Psr18ClientRequestGenerationTest.php index ad8efb45..885605b1 100644 --- a/tests/Integration/Psr18ClientRequestGenerationTest.php +++ b/tests/Integration/Psr18ClientRequestGenerationTest.php @@ -6,6 +6,8 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Utils; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestFactoryInterface; @@ -14,14 +16,13 @@ use Psr\Http\Message\StreamInterface; use Redmine\Client\Psr18Client; +#[CoversClass(Psr18Client::class)] class Psr18ClientRequestGenerationTest extends TestCase { /** - * @covers \Redmine\Client\Psr18Client - * @test - * * @dataProvider createdGetRequestsData */ + #[DataProvider('createdGetRequestsData')] public function testPsr18ClientCreatesCorrectRequests( string $url, string $apikeyOrUsername, @@ -34,42 +35,39 @@ public function testPsr18ClientCreatesCorrectRequests( ) { $response = $this->createMock(ResponseInterface::class); + /** @var ClientInterface|\PHPUnit\Framework\MockObject\MockObject */ $httpClient = $this->createMock(ClientInterface::class); - $httpClient->method('sendRequest')->will( - $this->returnCallback(function ($request) use ($response, $expectedOutput) { - // Create a text representation of the HTTP request - $content = $request->getBody()->__toString(); + $httpClient->method('sendRequest')->willReturnCallback(function ($request) use ($response, $expectedOutput) { + // Create a text representation of the HTTP request + $content = $request->getBody()->__toString(); - $headers = ''; + $headers = ''; - foreach ($request->getHeaders() as $k => $v) { - $headers .= $k . ': ' . $request->getHeaderLine($k) . \PHP_EOL; - } + foreach ($request->getHeaders() as $k => $v) { + $headers .= $k . ': ' . $request->getHeaderLine($k) . \PHP_EOL; + } - $statusLine = sprintf( - '%s %s HTTP/%s', - $request->getMethod(), - $request->getUri()->__toString(), - $request->getProtocolVersion() - ); + $statusLine = sprintf( + '%s %s HTTP/%s', + $request->getMethod(), + $request->getUri()->__toString(), + $request->getProtocolVersion() + ); - $fullRequest = $statusLine . \PHP_EOL . - $headers . \PHP_EOL . - $content - ; + $fullRequest = $statusLine . \PHP_EOL . + $headers . \PHP_EOL . + $content + ; - $this->assertSame($expectedOutput, $fullRequest); + $this->assertSame($expectedOutput, $fullRequest); - return $response; - }) - ); + return $response; + }); $requestFactory = $this->createMock(RequestFactoryInterface::class); - $requestFactory->method('createRequest')->will( - $this->returnCallback(function ($method, $uri) { - return new Request($method, $uri); - }) - ); + $requestFactory->method('createRequest')->willReturnCallback(function ($method, $uri) { + return new Request($method, $uri); + }); $streamFactory = new class () implements StreamFactoryInterface { public function createStream(string $content = ''): StreamInterface diff --git a/tests/RedmineExtension/RedmineInstance.php b/tests/RedmineExtension/RedmineInstance.php index 14bc684b..70575843 100644 --- a/tests/RedmineExtension/RedmineInstance.php +++ b/tests/RedmineExtension/RedmineInstance.php @@ -16,8 +16,8 @@ final class RedmineInstance public static function getSupportedVersions(): array { return [ - RedmineVersion::V5_1_1, - RedmineVersion::V5_0_7, + RedmineVersion::V5_1_2, + RedmineVersion::V5_0_8, ]; } diff --git a/tests/RedmineExtension/RedmineVersion.php b/tests/RedmineExtension/RedmineVersion.php index 8a4c6afd..214aa39c 100644 --- a/tests/RedmineExtension/RedmineVersion.php +++ b/tests/RedmineExtension/RedmineVersion.php @@ -6,6 +6,14 @@ enum RedmineVersion: string { + /** + * Redmine 5.1.2 + * + * @link https://www.redmine.org/versions/193 + * @link https://www.redmine.org/projects/redmine/wiki/Changelog_5_1#512-2024-03-04 + */ + case V5_1_2 = '5.1.2'; + /** * Redmine 5.1.1 * @@ -22,6 +30,15 @@ enum RedmineVersion: string */ case V5_1_0 = '5.1.0'; + /** + * Redmine 5.0.8 + * + * @link https://www.redmine.org/versions/192 + * @link https://www.redmine.org/projects/redmine/wiki/Changelog_5_0#508-2024-03-04 + */ + + case V5_0_8 = '5.0.8'; + /** * Redmine 5.0.7 * diff --git a/tests/Unit/Api/AbstractApi/DeleteTest.php b/tests/Unit/Api/AbstractApi/DeleteTest.php index ca38f22f..8c77dc05 100644 --- a/tests/Unit/Api/AbstractApi/DeleteTest.php +++ b/tests/Unit/Api/AbstractApi/DeleteTest.php @@ -4,15 +4,15 @@ namespace Redmine\Tests\Unit\Api\AbstractApi; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\AbstractApi; use Redmine\Client\Client; use Redmine\Tests\Fixtures\AssertingHttpClient; use ReflectionMethod; -/** - * @covers \Redmine\Api\AbstractApi::delete - */ +#[CoversClass(AbstractApi::class)] class DeleteTest extends TestCase { public function testDeleteWithHttpClient() @@ -44,6 +44,7 @@ public function testDeleteWithHttpClient() /** * @dataProvider getXmlDecodingFromDeleteMethodData */ + #[DataProvider('getXmlDecodingFromDeleteMethodData')] public function testXmlDecodingFromDeleteMethod($response, $expected) { $client = $this->createMock(Client::class); diff --git a/tests/Unit/Api/AbstractApi/GetTest.php b/tests/Unit/Api/AbstractApi/GetTest.php index 9a49a7c3..7e260143 100644 --- a/tests/Unit/Api/AbstractApi/GetTest.php +++ b/tests/Unit/Api/AbstractApi/GetTest.php @@ -4,6 +4,8 @@ namespace Redmine\Tests\Unit\Api\AbstractApi; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\AbstractApi; use Redmine\Client\Client; @@ -11,9 +13,7 @@ use ReflectionMethod; use SimpleXMLElement; -/** - * @covers \Redmine\Api\AbstractApi::get - */ +#[CoversClass(AbstractApi::class)] class GetTest extends TestCase { public function testGetWithHttpClient() @@ -46,6 +46,7 @@ public function testGetWithHttpClient() /** * @dataProvider getJsonDecodingFromGetMethodData */ + #[DataProvider('getJsonDecodingFromGetMethodData')] public function testJsonDecodingFromGetMethod($response, $decode, $expected) { $client = $this->createMock(Client::class); @@ -80,6 +81,7 @@ public static function getJsonDecodingFromGetMethodData(): array /** * @dataProvider getXmlDecodingFromGetMethodData */ + #[DataProvider('getXmlDecodingFromGetMethodData')] public function testXmlDecodingFromGetMethod($response, $decode, $expected) { $client = $this->createMock(Client::class); diff --git a/tests/Unit/Api/AbstractApi/PostTest.php b/tests/Unit/Api/AbstractApi/PostTest.php index 8facc959..4a2e6545 100644 --- a/tests/Unit/Api/AbstractApi/PostTest.php +++ b/tests/Unit/Api/AbstractApi/PostTest.php @@ -4,6 +4,8 @@ namespace Redmine\Tests\Unit\Api\AbstractApi; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\AbstractApi; use Redmine\Client\Client; @@ -11,9 +13,7 @@ use ReflectionMethod; use SimpleXMLElement; -/** - * @covers \Redmine\Api\AbstractApi::post - */ +#[CoversClass(AbstractApi::class)] class PostTest extends TestCase { public function testPostWithHttpClient() @@ -46,6 +46,7 @@ public function testPostWithHttpClient() /** * @dataProvider getXmlDecodingFromPostMethodData */ + #[DataProvider('getXmlDecodingFromPostMethodData')] public function testXmlDecodingFromPostMethod($response, $expected) { $client = $this->createMock(Client::class); diff --git a/tests/Unit/Api/AbstractApi/PutTest.php b/tests/Unit/Api/AbstractApi/PutTest.php index 61656088..a8709b1b 100644 --- a/tests/Unit/Api/AbstractApi/PutTest.php +++ b/tests/Unit/Api/AbstractApi/PutTest.php @@ -4,6 +4,8 @@ namespace Redmine\Tests\Unit\Api\AbstractApi; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\AbstractApi; use Redmine\Client\Client; @@ -11,9 +13,7 @@ use ReflectionMethod; use SimpleXMLElement; -/** - * @covers \Redmine\Api\AbstractApi::put - */ +#[CoversClass(AbstractApi::class)] class PutTest extends TestCase { public function testPutWithHttpClient() @@ -46,6 +46,7 @@ public function testPutWithHttpClient() /** * @dataProvider getXmlDecodingFromPutMethodData */ + #[DataProvider('getXmlDecodingFromPutMethodData')] public function testXmlDecodingFromPutMethod($response, $expected) { $client = $this->createMock(Client::class); diff --git a/tests/Unit/Api/AbstractApiTest.php b/tests/Unit/Api/AbstractApiTest.php index 39a473c7..0c138a9b 100644 --- a/tests/Unit/Api/AbstractApiTest.php +++ b/tests/Unit/Api/AbstractApiTest.php @@ -3,6 +3,8 @@ namespace Redmine\Tests\Unit\Api; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\AbstractApi; use Redmine\Client\Client; @@ -13,9 +15,7 @@ use ReflectionMethod; use SimpleXMLElement; -/** - * @coversDefaultClass \Redmine\Api\AbstractApi - */ +#[CoversClass(AbstractApi::class)] class AbstractApiTest extends TestCase { public function testCreateWithHttpClientWorks() @@ -51,9 +51,6 @@ public function testCreateWithoutClitentOrHttpClientThrowsException() new class (new \stdClass()) extends AbstractApi {}; } - /** - * @covers ::get - */ public function testGetTriggersDeprecationWarning() { $client = $this->createMock(HttpClient::class); @@ -82,9 +79,6 @@ function ($errno, $errstr): bool { $api->runGet('/path.json'); } - /** - * @covers ::getLastResponse - */ public function testGetLastResponseWithHttpClientWorks() { $client = $this->createMock(HttpClient::class); @@ -94,9 +88,6 @@ public function testGetLastResponseWithHttpClientWorks() $this->assertInstanceOf(Response::class, $api->getLastResponse()); } - /** - * @covers ::post - */ public function testPostTriggersDeprecationWarning() { $client = $this->createMock(HttpClient::class); @@ -126,9 +117,9 @@ function ($errno, $errstr): bool { } /** - * @test * @dataProvider getIsNotNullReturnsCorrectBooleanData */ + #[DataProvider('getIsNotNullReturnsCorrectBooleanData')] public function testIsNotNullReturnsCorrectBoolean(bool $expected, $value) { $client = $this->createMock(Client::class); @@ -163,9 +154,6 @@ public static function getIsNotNullReturnsCorrectBooleanData(): array ]; } - /** - * @covers ::lastCallFailed - */ public function testLastCallFailedPreventsRaceCondition() { $client = AssertingHttpClient::create( @@ -210,10 +198,9 @@ public function __construct($client) } /** - * @covers ::lastCallFailed - * @test * @dataProvider getLastCallFailedData */ + #[DataProvider('getLastCallFailedData')] public function testLastCallFailedWithClientReturnsCorrectBoolean($statusCode, $expectedBoolean) { $client = $this->createMock(Client::class); @@ -225,10 +212,9 @@ public function testLastCallFailedWithClientReturnsCorrectBoolean($statusCode, $ } /** - * @covers ::lastCallFailed - * @test * @dataProvider getLastCallFailedData */ + #[DataProvider('getLastCallFailedData')] public function testLastCallFailedWithHttpClientReturnsCorrectBoolean($statusCode, $expectedBoolean) { $response = $this->createMock(Response::class); @@ -320,10 +306,9 @@ public static function getLastCallFailedData(): array } /** - * @covers ::retrieveData - * * @dataProvider retrieveDataData */ + #[DataProvider('retrieveDataData')] public function testRetrieveData($response, $contentType, $expected) { $client = $this->createMock(Client::class); @@ -347,10 +332,9 @@ public static function retrieveDataData(): array } /** - * @covers ::retrieveData - * * @dataProvider getRetrieveDataToExceptionData */ + #[DataProvider('getRetrieveDataToExceptionData')] public function testRetrieveDataThrowsException($response, $contentType, $expectedException, $expectedMessage) { $client = $this->createMock(Client::class); @@ -377,10 +361,9 @@ public static function getRetrieveDataToExceptionData(): array } /** - * @covers ::retrieveAll - * * @dataProvider getRetrieveAllData */ + #[DataProvider('getRetrieveAllData')] public function testDeprecatedRetrieveAll($content, $contentType, $expected) { $client = $this->createMock(Client::class); @@ -405,9 +388,6 @@ public static function getRetrieveAllData(): array ]; } - /** - * @covers ::attachCustomFieldXML - */ public function testDeprecatedAttachCustomFieldXML() { $client = $this->createMock(Client::class); diff --git a/tests/Unit/Api/Attachment/DownloadTest.php b/tests/Unit/Api/Attachment/DownloadTest.php index c0aa4f16..2814c6e3 100644 --- a/tests/Unit/Api/Attachment/DownloadTest.php +++ b/tests/Unit/Api/Attachment/DownloadTest.php @@ -2,18 +2,19 @@ namespace Redmine\Tests\Unit\Api\Attachment; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Attachment; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\Attachment::download - */ +#[CoversClass(Attachment::class)] class DownloadTest extends TestCase { /** * @dataProvider getDownloadData */ + #[DataProvider('getDownloadData')] public function testDownloadReturnsCorrectResponse($id, $expectedPath, $responseCode, $response, $expectedReturn) { $client = AssertingHttpClient::create( diff --git a/tests/Unit/Api/Attachment/RemoveTest.php b/tests/Unit/Api/Attachment/RemoveTest.php index 642a42b3..257eb9eb 100644 --- a/tests/Unit/Api/Attachment/RemoveTest.php +++ b/tests/Unit/Api/Attachment/RemoveTest.php @@ -4,13 +4,12 @@ namespace Redmine\Tests\Unit\Api\Attachment; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\Attachment; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\Attachment::remove - */ +#[CoversClass(Attachment::class)] class RemoveTest extends TestCase { public function testRemoveReturnsString() diff --git a/tests/Unit/Api/Attachment/ShowTest.php b/tests/Unit/Api/Attachment/ShowTest.php index 1a14d6a6..0249335e 100644 --- a/tests/Unit/Api/Attachment/ShowTest.php +++ b/tests/Unit/Api/Attachment/ShowTest.php @@ -2,18 +2,19 @@ namespace Redmine\Tests\Unit\Api\Attachment; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Attachment; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\Attachment::show - */ +#[CoversClass(Attachment::class)] class ShowTest extends TestCase { /** * @dataProvider getShowData */ + #[DataProvider('getShowData')] public function testShowReturnsCorrectResponse($id, $expectedPath, $response, $expectedReturn) { $client = AssertingHttpClient::create( diff --git a/tests/Unit/Api/Attachment/UploadTest.php b/tests/Unit/Api/Attachment/UploadTest.php index f7eabdaf..2816610a 100644 --- a/tests/Unit/Api/Attachment/UploadTest.php +++ b/tests/Unit/Api/Attachment/UploadTest.php @@ -2,18 +2,19 @@ namespace Redmine\Tests\Unit\Api\Attachment; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Attachment; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\Attachment::upload - */ +#[CoversClass(Attachment::class)] class UploadTest extends TestCase { /** * @dataProvider getUploadData */ + #[DataProvider('getUploadData')] public function testUploadReturnsCorrectResponse($attachment, $params, $expectedAttachment, $expectedPath, $responseCode, $response, $expectedReturn) { $client = AssertingHttpClient::create( diff --git a/tests/Unit/Api/AttachmentTest.php b/tests/Unit/Api/AttachmentTest.php index 67171210..321950ba 100644 --- a/tests/Unit/Api/AttachmentTest.php +++ b/tests/Unit/Api/AttachmentTest.php @@ -2,28 +2,27 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Attachment; use Redmine\Client\Client; /** - * @coversDefaultClass \Redmine\Api\Attachment - * * @author Malte Gerth */ +#[CoversClass(Attachment::class)] class AttachmentTest extends TestCase { /** * Test lastCallFailed(). * - * @covers ::__construct - * @covers ::lastCallFailed * @dataProvider responseCodeProvider * * @param int $responseCode * @param bool $hasFailed - * @test */ + #[DataProvider('responseCodeProvider')] public function testLastCallFailedTrue($responseCode, $hasFailed) { // Create the used mock objects diff --git a/tests/Unit/Api/CustomField/ListTest.php b/tests/Unit/Api/CustomField/ListTest.php index 3d79e09f..60803fb1 100644 --- a/tests/Unit/Api/CustomField/ListTest.php +++ b/tests/Unit/Api/CustomField/ListTest.php @@ -2,14 +2,13 @@ namespace Redmine\Tests\Unit\Api\CustomField; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\CustomField; use Redmine\Client\Client; use Redmine\Exception\UnexpectedResponseException; -/** - * @covers \Redmine\Api\CustomField::list - */ +#[CoversClass(CustomField::class)] class ListTest extends TestCase { public function testListWithoutParametersReturnsResponse() diff --git a/tests/Unit/Api/CustomFieldTest.php b/tests/Unit/Api/CustomFieldTest.php index 030a4915..0aec8702 100644 --- a/tests/Unit/Api/CustomFieldTest.php +++ b/tests/Unit/Api/CustomFieldTest.php @@ -2,22 +2,21 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\CustomField; use Redmine\Client\Client; use Redmine\Tests\Fixtures\MockClient; /** - * @coversDefaultClass \Redmine\Api\CustomField - * * @author Malte Gerth */ +#[CoversClass(CustomField::class)] class CustomFieldTest extends TestCase { /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -43,10 +42,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllData - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponse($response, $responseType, $expectedResponse) { // Create the used mock objects @@ -80,9 +78,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParameters() { @@ -115,9 +110,6 @@ public function testAllReturnsClientGetResponseWithParameters() /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithHighLimit() { @@ -153,9 +145,6 @@ public function testAllReturnsClientGetResponseWithHighLimit() /** * Test all(). - * - * @covers ::all - * @test */ public function testAllCallsEndpointUntilOffsetIsHigherThanTotalCount() { @@ -196,9 +185,6 @@ public function testAllCallsEndpointUntilOffsetIsHigherThanTotalCount() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingReturnsNameIdArray() { @@ -233,9 +219,6 @@ public function testListingReturnsNameIdArray() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetOnlyTheFirstTime() { @@ -271,9 +254,6 @@ public function testListingCallsGetOnlyTheFirstTime() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetEveryTimeWithForceUpdate() { @@ -309,9 +289,6 @@ public function testListingCallsGetEveryTimeWithForceUpdate() /** * Test getIdByName(). - * - * @covers ::getIdByName - * @test */ public function testGetIdByNameMakesGetRequest() { diff --git a/tests/Unit/Api/Group/AddUserTest.php b/tests/Unit/Api/Group/AddUserTest.php index 175c6a05..62306e21 100644 --- a/tests/Unit/Api/Group/AddUserTest.php +++ b/tests/Unit/Api/Group/AddUserTest.php @@ -2,19 +2,20 @@ namespace Redmine\Tests\Unit\Api\Group; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Group; use Redmine\Tests\Fixtures\AssertingHttpClient; use SimpleXMLElement; -/** - * @covers \Redmine\Api\Group::addUser - */ +#[CoversClass(Group::class)] class AddUserTest extends TestCase { /** * @dataProvider getAddUserData */ + #[DataProvider('getAddUserData')] public function testAddUserReturnsCorrectResponse($groupId, $userId, $expectedPath, $expectedBody, $responseCode, $response) { $client = AssertingHttpClient::create( diff --git a/tests/Unit/Api/Group/CreateTest.php b/tests/Unit/Api/Group/CreateTest.php index b99238f4..1c853c2b 100644 --- a/tests/Unit/Api/Group/CreateTest.php +++ b/tests/Unit/Api/Group/CreateTest.php @@ -4,6 +4,8 @@ namespace Redmine\Tests\Unit\Api\Group; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Group; use Redmine\Exception\MissingParameterException; @@ -11,14 +13,13 @@ use Redmine\Tests\Fixtures\AssertingHttpClient; use SimpleXMLElement; -/** - * @covers \Redmine\Api\Group::create - */ +#[CoversClass(Group::class)] class CreateTest extends TestCase { /** * @dataProvider getCreateData */ + #[DataProvider('getCreateData')] public function testCreateReturnsCorrectResponse($parameters, $expectedPath, $expectedBody, $responseCode, $response) { $client = AssertingHttpClient::create( diff --git a/tests/Unit/Api/Group/ListTest.php b/tests/Unit/Api/Group/ListTest.php index ff41c229..6f9f403c 100644 --- a/tests/Unit/Api/Group/ListTest.php +++ b/tests/Unit/Api/Group/ListTest.php @@ -2,14 +2,13 @@ namespace Redmine\Tests\Unit\Api\Group; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\Group; use Redmine\Client\Client; use Redmine\Exception\UnexpectedResponseException; -/** - * @covers \Redmine\Api\Group::list - */ +#[CoversClass(Group::class)] class ListTest extends TestCase { public function testListWithoutParametersReturnsResponse() diff --git a/tests/Unit/Api/Group/ShowTest.php b/tests/Unit/Api/Group/ShowTest.php index 39559cc9..c2c50d95 100644 --- a/tests/Unit/Api/Group/ShowTest.php +++ b/tests/Unit/Api/Group/ShowTest.php @@ -2,18 +2,19 @@ namespace Redmine\Tests\Unit\Api\Group; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Group; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\Group::show - */ +#[CoversClass(Group::class)] class ShowTest extends TestCase { /** * @dataProvider getShowData */ + #[DataProvider('getShowData')] public function testShowReturnsCorrectResponse($groupId, array $params, $expectedPath, $response, $expectedReturn) { $client = AssertingHttpClient::create( diff --git a/tests/Unit/Api/Group/UpdateTest.php b/tests/Unit/Api/Group/UpdateTest.php index e75ac708..5bc216d5 100644 --- a/tests/Unit/Api/Group/UpdateTest.php +++ b/tests/Unit/Api/Group/UpdateTest.php @@ -4,13 +4,12 @@ namespace Redmine\Tests\Unit\Api\Group; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\Group; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\Group::update - */ +#[CoversClass(Group::class)] class UpdateTest extends TestCase { public function testUpdateWithNameUpdatesGroup() diff --git a/tests/Unit/Api/GroupTest.php b/tests/Unit/Api/GroupTest.php index d4acdde6..e2bc83ff 100644 --- a/tests/Unit/Api/GroupTest.php +++ b/tests/Unit/Api/GroupTest.php @@ -4,22 +4,21 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Group; use Redmine\Client\Client; use Redmine\Tests\Fixtures\MockClient; /** - * @coversDefaultClass \Redmine\Api\Group - * * @author Malte Gerth */ +#[CoversClass(Group::class)] class GroupTest extends TestCase { /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -45,10 +44,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllData - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponse($response, $responseType, $expectedResponse) { // Create the used mock objects @@ -82,9 +80,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParameters() { @@ -120,9 +115,6 @@ public function testAllReturnsClientGetResponseWithParameters() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingReturnsNameIdArray() { @@ -157,9 +149,6 @@ public function testListingReturnsNameIdArray() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetOnlyTheFirstTime() { @@ -195,9 +184,6 @@ public function testListingCallsGetOnlyTheFirstTime() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetEveryTimeWithForceUpdate() { @@ -233,10 +219,6 @@ public function testListingCallsGetEveryTimeWithForceUpdate() /** * Test remove(). - * - * @covers ::delete - * @covers ::remove - * @test */ public function testRemoveCallsDelete() { @@ -274,10 +256,6 @@ public function testRemoveCallsDelete() /** * Test removeUser(). - * - * @covers ::delete - * @covers ::removeUser - * @test */ public function testRemoveUserCallsDelete() { diff --git a/tests/Unit/Api/Issue/AddWatcherTest.php b/tests/Unit/Api/Issue/AddWatcherTest.php index 9e1d6492..dae6884a 100644 --- a/tests/Unit/Api/Issue/AddWatcherTest.php +++ b/tests/Unit/Api/Issue/AddWatcherTest.php @@ -2,19 +2,20 @@ namespace Redmine\Tests\Unit\Api\Issue; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Issue; use Redmine\Tests\Fixtures\AssertingHttpClient; use SimpleXMLElement; -/** - * @covers \Redmine\Api\Issue::addWatcher - */ +#[CoversClass(Issue::class)] class AddWatcherTest extends TestCase { /** * @dataProvider getAddWatcherData */ + #[DataProvider('getAddWatcherData')] public function testCreateReturnsCorrectResponse($issueId, $watcherUserId, $expectedPath, $expectedBody, $responseCode, $response) { $client = AssertingHttpClient::create( diff --git a/tests/Unit/Api/Issue/CreateTest.php b/tests/Unit/Api/Issue/CreateTest.php index 1334a8ea..1cca0bd0 100644 --- a/tests/Unit/Api/Issue/CreateTest.php +++ b/tests/Unit/Api/Issue/CreateTest.php @@ -2,19 +2,20 @@ namespace Redmine\Tests\Unit\Api\Issue; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Issue; use Redmine\Tests\Fixtures\AssertingHttpClient; use SimpleXMLElement; -/** - * @covers \Redmine\Api\Issue::create - */ +#[CoversClass(Issue::class)] class CreateTest extends TestCase { /** * @dataProvider getCreateData */ + #[DataProvider('getCreateData')] public function testCreateReturnsCorrectResponse($parameters, $expectedPath, $expectedBody, $responseCode, $response) { $client = AssertingHttpClient::create( @@ -255,10 +256,6 @@ public function testCreateReturnsEmptyString() $this->assertSame('', $return); } - /** - * @covers \Redmine\Api\Issue::cleanParams - * @covers \Redmine\Api\Issue::getIssueStatusApi - */ public function testCreateWithHttpClientRetrievesIssueStatusId() { $client = AssertingHttpClient::create( @@ -296,10 +293,6 @@ public function testCreateWithHttpClientRetrievesIssueStatusId() ); } - /** - * @covers \Redmine\Api\Issue::cleanParams - * @covers \Redmine\Api\Issue::getProjectApi - */ public function testCreateWithHttpClientRetrievesProjectId() { $client = AssertingHttpClient::create( @@ -337,10 +330,6 @@ public function testCreateWithHttpClientRetrievesProjectId() ); } - /** - * @covers \Redmine\Api\Issue::cleanParams - * @covers \Redmine\Api\Issue::getIssueCategoryApi - */ public function testCreateWithHttpClientRetrievesIssueCategoryId() { $client = AssertingHttpClient::create( @@ -378,10 +367,6 @@ public function testCreateWithHttpClientRetrievesIssueCategoryId() ); } - /** - * @covers \Redmine\Api\Issue::cleanParams - * @covers \Redmine\Api\Issue::getTrackerApi - */ public function testCreateWithHttpClientRetrievesTrackerId() { $client = AssertingHttpClient::create( @@ -419,10 +404,6 @@ public function testCreateWithHttpClientRetrievesTrackerId() ); } - /** - * @covers \Redmine\Api\Issue::cleanParams - * @covers \Redmine\Api\Issue::getUserApi - */ public function testCreateWithHttpClientRetrievesUserId() { $client = AssertingHttpClient::create( @@ -462,13 +443,6 @@ public function testCreateWithHttpClientRetrievesUserId() /** * Test cleanParams(). - * - * @covers \Redmine\Api\Issue::cleanParams - * @covers \Redmine\Api\Issue::getIssueCategoryApi - * @covers \Redmine\Api\Issue::getIssueStatusApi - * @covers \Redmine\Api\Issue::getProjectApi - * @covers \Redmine\Api\Issue::getTrackerApi - * @covers \Redmine\Api\Issue::getUserApi */ public function testCreateWithClientCleansParameters() { diff --git a/tests/Unit/Api/Issue/ListTest.php b/tests/Unit/Api/Issue/ListTest.php index 3a9ea99c..ee3899ed 100644 --- a/tests/Unit/Api/Issue/ListTest.php +++ b/tests/Unit/Api/Issue/ListTest.php @@ -2,14 +2,13 @@ namespace Redmine\Tests\Unit\Api\Issue; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\Issue; use Redmine\Client\Client; use Redmine\Exception\UnexpectedResponseException; -/** - * @covers \Redmine\Api\Issue::list - */ +#[CoversClass(Issue::class)] class ListTest extends TestCase { public function testListWithoutParametersReturnsResponse() diff --git a/tests/Unit/Api/Issue/ShowTest.php b/tests/Unit/Api/Issue/ShowTest.php index 1686e49b..c9da9e70 100644 --- a/tests/Unit/Api/Issue/ShowTest.php +++ b/tests/Unit/Api/Issue/ShowTest.php @@ -2,18 +2,19 @@ namespace Redmine\Tests\Unit\Api\Issue; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Issue; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\Issue::show - */ +#[CoversClass(Issue::class)] class ShowTest extends TestCase { /** * @dataProvider getShowData */ + #[DataProvider('getShowData')] public function testShowReturnsCorrectResponse($issueId, array $params, $expectedPath, $response, $expectedReturn) { $client = AssertingHttpClient::create( diff --git a/tests/Unit/Api/IssueCategory/CreateTest.php b/tests/Unit/Api/IssueCategory/CreateTest.php index 588c3b5f..b3fce28f 100644 --- a/tests/Unit/Api/IssueCategory/CreateTest.php +++ b/tests/Unit/Api/IssueCategory/CreateTest.php @@ -2,6 +2,8 @@ namespace Redmine\Tests\Unit\Api\IssueCategory; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\IssueCategory; use Redmine\Exception\MissingParameterException; @@ -9,14 +11,13 @@ use Redmine\Tests\Fixtures\AssertingHttpClient; use SimpleXMLElement; -/** - * @covers \Redmine\Api\IssueCategory::create - */ +#[CoversClass(IssueCategory::class)] class CreateTest extends TestCase { /** * @dataProvider getCreateData */ + #[DataProvider('getCreateData')] public function testCreateReturnsCorrectResponse($identifier, $parameters, $expectedPath, $expectedBody, $responseCode, $response) { $client = AssertingHttpClient::create( @@ -114,6 +115,7 @@ public function testCreateThrowsExceptionWithEmptyParameters() /** * @dataProvider incompleteCreateParameterProvider */ + #[DataProvider('incompleteCreateParameterProvider')] public function testCreateThrowsExceptionIfMandatoyParametersAreMissing($parameters) { // Create the used mock objects diff --git a/tests/Unit/Api/IssueCategory/ListByProjectTest.php b/tests/Unit/Api/IssueCategory/ListByProjectTest.php index 6a40ec13..52a0b920 100644 --- a/tests/Unit/Api/IssueCategory/ListByProjectTest.php +++ b/tests/Unit/Api/IssueCategory/ListByProjectTest.php @@ -2,6 +2,8 @@ namespace Redmine\Tests\Unit\Api\IssueCategory; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\IssueCategory; use Redmine\Client\Client; @@ -10,9 +12,7 @@ use Redmine\Tests\Fixtures\MockClient; use stdClass; -/** - * @covers \Redmine\Api\IssueCategory::listByProject - */ +#[CoversClass(IssueCategory::class)] class ListByProjectTest extends TestCase { public function testListByProjectWithoutParametersReturnsResponse() @@ -73,6 +73,7 @@ public function testListByProjectWithParametersReturnsResponse() /** * @dataProvider getInvalidProjectIdentifiers */ + #[DataProvider('getInvalidProjectIdentifiers')] public function testListByProjectWithWrongProjectIdentifierThrowsException($projectIdentifier) { $api = new IssueCategory(MockClient::create()); diff --git a/tests/Unit/Api/IssueCategory/ShowTest.php b/tests/Unit/Api/IssueCategory/ShowTest.php index 7e5acd5f..23244d9e 100644 --- a/tests/Unit/Api/IssueCategory/ShowTest.php +++ b/tests/Unit/Api/IssueCategory/ShowTest.php @@ -2,18 +2,19 @@ namespace Redmine\Tests\Unit\Api\IssueCategory; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\IssueCategory; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\IssueCategory::show - */ +#[CoversClass(IssueCategory::class)] class ShowTest extends TestCase { /** * @dataProvider getShowData */ + #[DataProvider('getShowData')] public function testShowReturnsCorrectResponse($id, $expectedPath, $response, $expectedReturn) { $client = AssertingHttpClient::create( diff --git a/tests/Unit/Api/IssueCategoryTest.php b/tests/Unit/Api/IssueCategoryTest.php index 00b854ba..b232ee2e 100644 --- a/tests/Unit/Api/IssueCategoryTest.php +++ b/tests/Unit/Api/IssueCategoryTest.php @@ -2,23 +2,21 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\IssueCategory; use Redmine\Client\Client; -use Redmine\Exception\MissingParameterException; use Redmine\Tests\Fixtures\MockClient; /** - * @coversDefaultClass \Redmine\Api\IssueCategory - * * @author Malte Gerth */ +#[CoversClass(IssueCategory::class)] class IssueCategoryTest extends TestCase { /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -44,10 +42,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllDAta - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponseWithProject($response, $responseType, $expectedResponse) { // Test values @@ -84,9 +81,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParametersAndProject() { @@ -123,9 +117,6 @@ public function testAllReturnsClientGetResponseWithParametersAndProject() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingReturnsNameIdArray() { @@ -160,9 +151,6 @@ public function testListingReturnsNameIdArray() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetOnlyTheFirstTime() { @@ -198,9 +186,6 @@ public function testListingCallsGetOnlyTheFirstTime() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetEveryTimeWithForceUpdate() { @@ -236,10 +221,6 @@ public function testListingCallsGetEveryTimeWithForceUpdate() /** * Test remove(). - * - * @covers ::delete - * @covers ::remove - * @test */ public function testRemoveCallsDelete() { @@ -270,10 +251,6 @@ public function testRemoveCallsDelete() /** * Test remove(). - * - * @covers ::delete - * @covers ::remove - * @test */ public function testRemoveCallsDeleteWithParameters() { @@ -309,9 +286,6 @@ public function testRemoveCallsDeleteWithParameters() /** * Test getIdByName(). - * - * @covers ::getIdByName - * @test */ public function testGetIdByNameMakesGetRequest() { @@ -343,10 +317,6 @@ public function testGetIdByNameMakesGetRequest() /** * Test update(). - * - * @covers ::put - * @covers ::update - * @test */ public function testUpdateCallsPut() { diff --git a/tests/Unit/Api/IssuePriority/ListTest.php b/tests/Unit/Api/IssuePriority/ListTest.php index 19a3a540..eb3c541b 100644 --- a/tests/Unit/Api/IssuePriority/ListTest.php +++ b/tests/Unit/Api/IssuePriority/ListTest.php @@ -2,14 +2,13 @@ namespace Redmine\Tests\Unit\Api\IssuePriority; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\IssuePriority; use Redmine\Client\Client; use Redmine\Exception\UnexpectedResponseException; -/** - * @covers \Redmine\Api\IssuePriority::list - */ +#[CoversClass(IssuePriority::class)] class ListTest extends TestCase { public function testListWithoutParametersReturnsResponse() diff --git a/tests/Unit/Api/IssuePriorityTest.php b/tests/Unit/Api/IssuePriorityTest.php index 08911274..7a2ea1ee 100644 --- a/tests/Unit/Api/IssuePriorityTest.php +++ b/tests/Unit/Api/IssuePriorityTest.php @@ -2,22 +2,21 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\IssuePriority; use Redmine\Client\Client; use Redmine\Tests\Fixtures\MockClient; /** - * @coversDefaultClass \Redmine\Api\IssuePriority - * * @author Malte Gerth */ +#[CoversClass(IssuePriority::class)] class IssuePriorityTest extends TestCase { /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -43,10 +42,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllData - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponse($response, $responseType, $expectedResponse) { // Create the used mock objects @@ -80,9 +78,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParameters() { diff --git a/tests/Unit/Api/IssueRelation/CreateTest.php b/tests/Unit/Api/IssueRelation/CreateTest.php index ecbf35a8..b59a7645 100644 --- a/tests/Unit/Api/IssueRelation/CreateTest.php +++ b/tests/Unit/Api/IssueRelation/CreateTest.php @@ -2,6 +2,8 @@ namespace Redmine\Tests\Unit\Api\IssueRelation; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\IssueRelation; use Redmine\Exception\MissingParameterException; @@ -9,14 +11,13 @@ use Redmine\Http\HttpClient; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\IssueRelation::create - */ +#[CoversClass(IssueRelation::class)] class CreateTest extends TestCase { /** * @dataProvider getCreateData */ + #[DataProvider('getCreateData')] public function testCreateReturnsCorrectResponse($issueId, $parameters, $expectedPath, $expectedBody, $responseCode, $response, $expectedReturn) { $client = AssertingHttpClient::create( @@ -100,6 +101,7 @@ public function testCreateThrowsExceptionWithEmptyParameters() /** * @dataProvider incompleteCreateParameterProvider */ + #[DataProvider('incompleteCreateParameterProvider')] public function testCreateThrowsExceptionIfMandatoyParametersAreMissing($parameters) { // Create the used mock objects diff --git a/tests/Unit/Api/IssueRelation/ListByIssueIdTest.php b/tests/Unit/Api/IssueRelation/ListByIssueIdTest.php index a69a613d..d230015f 100644 --- a/tests/Unit/Api/IssueRelation/ListByIssueIdTest.php +++ b/tests/Unit/Api/IssueRelation/ListByIssueIdTest.php @@ -2,14 +2,13 @@ namespace Redmine\Tests\Unit\Api\IssueRelation; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\IssueRelation; use Redmine\Client\Client; use Redmine\Exception\UnexpectedResponseException; -/** - * @covers \Redmine\Api\IssueRelation::listByIssueId - */ +#[CoversClass(IssueRelation::class)] class ListByIssueIdTest extends TestCase { public function testListByIssueIdWithoutParametersReturnsResponse() diff --git a/tests/Unit/Api/IssueRelation/ShowTest.php b/tests/Unit/Api/IssueRelation/ShowTest.php index 144ac1e2..9c90db84 100644 --- a/tests/Unit/Api/IssueRelation/ShowTest.php +++ b/tests/Unit/Api/IssueRelation/ShowTest.php @@ -2,18 +2,19 @@ namespace Redmine\Tests\Unit\Api\IssueRelation; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\IssueRelation; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\IssueRelation::show - */ +#[CoversClass(IssueRelation::class)] class ShowTest extends TestCase { /** * @dataProvider getShowData */ + #[DataProvider('getShowData')] public function testShowReturnsCorrectResponse($id, $expectedPath, $response, $expectedReturn) { $client = AssertingHttpClient::create( diff --git a/tests/Unit/Api/IssueRelationTest.php b/tests/Unit/Api/IssueRelationTest.php index ba97896c..fa9a3e2a 100644 --- a/tests/Unit/Api/IssueRelationTest.php +++ b/tests/Unit/Api/IssueRelationTest.php @@ -2,22 +2,21 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\IssueRelation; use Redmine\Client\Client; use Redmine\Tests\Fixtures\MockClient; /** - * @coversDefaultClass \Redmine\Api\IssueRelation - * * @author Malte Gerth */ +#[CoversClass(IssueRelation::class)] class IssueRelationTest extends TestCase { /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -43,10 +42,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllData - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponseWithProject($response, $responseType, $expectedResponse) { // Create the used mock objects @@ -80,9 +78,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParametersAndProject() { @@ -118,10 +113,6 @@ public function testAllReturnsClientGetResponseWithParametersAndProject() /** * Test remove(). - * - * @covers ::delete - * @covers ::remove - * @test */ public function testRemoveCallsDelete() { diff --git a/tests/Unit/Api/IssueStatus/ListTest.php b/tests/Unit/Api/IssueStatus/ListTest.php index 9affbd5d..9e4e573c 100644 --- a/tests/Unit/Api/IssueStatus/ListTest.php +++ b/tests/Unit/Api/IssueStatus/ListTest.php @@ -2,14 +2,13 @@ namespace Redmine\Tests\Unit\Api\IssueStatus; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\IssueStatus; use Redmine\Client\Client; use Redmine\Exception\UnexpectedResponseException; -/** - * @covers \Redmine\Api\IssueStatus::list - */ +#[CoversClass(IssueStatus::class)] class ListTest extends TestCase { public function testListWithoutParametersReturnsResponse() diff --git a/tests/Unit/Api/IssueStatusTest.php b/tests/Unit/Api/IssueStatusTest.php index 9651565a..767f8b1b 100644 --- a/tests/Unit/Api/IssueStatusTest.php +++ b/tests/Unit/Api/IssueStatusTest.php @@ -2,22 +2,21 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\IssueStatus; use Redmine\Client\Client; use Redmine\Tests\Fixtures\MockClient; /** - * @coversDefaultClass \Redmine\Api\IssueStatus - * * @author Malte Gerth */ +#[CoversClass(IssueStatus::class)] class IssueStatusTest extends TestCase { /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -43,10 +42,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllData - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponse($response, $responseType, $expectedResponse) { // Create the used mock objects @@ -80,9 +78,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParametersAndProject() { @@ -118,9 +113,6 @@ public function testAllReturnsClientGetResponseWithParametersAndProject() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingReturnsNameIdArray() { @@ -155,9 +147,6 @@ public function testListingReturnsNameIdArray() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetOnlyTheFirstTime() { @@ -193,9 +182,6 @@ public function testListingCallsGetOnlyTheFirstTime() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetEveryTimeWithForceUpdate() { @@ -231,9 +217,6 @@ public function testListingCallsGetEveryTimeWithForceUpdate() /** * Test getIdByName(). - * - * @covers ::getIdByName - * @test */ public function testGetIdByNameMakesGetRequest() { diff --git a/tests/Unit/Api/IssueTest.php b/tests/Unit/Api/IssueTest.php index a278d71e..23722a85 100644 --- a/tests/Unit/Api/IssueTest.php +++ b/tests/Unit/Api/IssueTest.php @@ -2,6 +2,8 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Issue; use Redmine\Client\Client; @@ -10,10 +12,9 @@ use SimpleXMLElement; /** - * @coversDefaultClass \Redmine\Api\Issue - * * @author Malte Gerth */ +#[CoversClass(Issue::class)] class IssueTest extends TestCase { public static function getPriorityConstantsData(): array @@ -31,9 +32,8 @@ public static function getPriorityConstantsData(): array * Test the constants. * * @dataProvider getPriorityConstantsData - * - * @test */ + #[DataProvider('getPriorityConstantsData')] public function testPriorityConstants($expected, $value) { $this->assertSame($expected, $value); @@ -41,8 +41,6 @@ public function testPriorityConstants($expected, $value) /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -68,10 +66,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllData - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponse($response, $responseType, $expectedResponse) { // Create the used mock objects @@ -105,9 +102,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParameters() { @@ -143,10 +137,6 @@ public function testAllReturnsClientGetResponseWithParameters() /** * Test remove(). - * - * @covers ::delete - * @covers ::remove - * @test */ public function testRemoveCallsDelete() { @@ -180,10 +170,6 @@ public function testRemoveCallsDelete() /** * Test attach(). - * - * @covers ::attach - * @covers ::put - * @test */ public function testAttachCallsPut() { @@ -228,9 +214,6 @@ public function testAttachCallsPut() /** * Test removeWatcher(). - * - * @covers ::removeWatcher - * @test */ public function testRemoveWatcherCallsPost() { @@ -258,15 +241,6 @@ public function testRemoveWatcherCallsPost() /** * Test cleanParams() with Client for BC - * - * @covers ::create - * @covers ::cleanParams - * @covers ::getIssueCategoryApi - * @covers ::getIssueStatusApi - * @covers ::getProjectApi - * @covers ::getTrackerApi - * @covers ::getUserApi - * @test */ public function testCreateWithClientCleansParameters() { @@ -340,10 +314,6 @@ public function testCreateWithClientCleansParameters() /** * Test update(). - * - * @covers ::update - * @covers ::put - * @test */ public function testUpdateCallsPut() { @@ -373,10 +343,6 @@ public function testUpdateCallsPut() /** * Test update(). - * - * @covers ::update - * @covers ::cleanParams - * @test */ public function testUpdateCleansParameters() { @@ -448,9 +414,6 @@ public function testUpdateCleansParameters() /** * Test setIssueStatus(). - * - * @covers ::setIssueStatus - * @test */ public function testSetIssueStatusWithClient() { @@ -494,9 +457,6 @@ public function testSetIssueStatusWithClient() /** * Test setIssueStatus(). - * - * @covers ::setIssueStatus - * @test */ public function testSetIssueStatusWithHttpClient() { @@ -537,9 +497,6 @@ public function testSetIssueStatusWithHttpClient() /** * Test addNoteToIssue(). - * - * @covers ::addNoteToIssue - * @test */ public function testAddNoteToIssue() { @@ -574,7 +531,6 @@ public function testAddNoteToIssue() /** * Test assign an user to an issue. * - * @test */ public function testAssignUserToAnIssue() { @@ -606,7 +562,6 @@ public function testAssignUserToAnIssue() /** * Test unassign an user from an issue. * - * @test */ public function testUnassignUserFromAnIssue() { diff --git a/tests/Unit/Api/Membership/CreateTest.php b/tests/Unit/Api/Membership/CreateTest.php index f736e52c..59f0dd04 100644 --- a/tests/Unit/Api/Membership/CreateTest.php +++ b/tests/Unit/Api/Membership/CreateTest.php @@ -2,6 +2,8 @@ namespace Redmine\Tests\Unit\Api\Membership; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Membership; use Redmine\Exception\MissingParameterException; @@ -9,14 +11,13 @@ use Redmine\Tests\Fixtures\AssertingHttpClient; use SimpleXMLElement; -/** - * @covers \Redmine\Api\Membership::create - */ +#[CoversClass(Membership::class)] class CreateTest extends TestCase { /** * @dataProvider getCreateData */ + #[DataProvider('getCreateData')] public function testCreateReturnsCorrectResponse($identifier, $parameters, $expectedPath, $expectedBody, $responseCode, $response) { $client = AssertingHttpClient::create( @@ -106,6 +107,7 @@ public function testCreateThrowsExceptionWithEmptyParameters() /** * @dataProvider incompleteCreateParameterProvider */ + #[DataProvider('incompleteCreateParameterProvider')] public function testCreateThrowsExceptionIfMandatoyParametersAreMissing($parameters) { // Create the used mock objects diff --git a/tests/Unit/Api/Membership/ListByProjectTest.php b/tests/Unit/Api/Membership/ListByProjectTest.php index 100fd765..c6c4483d 100644 --- a/tests/Unit/Api/Membership/ListByProjectTest.php +++ b/tests/Unit/Api/Membership/ListByProjectTest.php @@ -2,6 +2,8 @@ namespace Redmine\Tests\Unit\Api\Membership; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Membership; use Redmine\Client\Client; @@ -10,9 +12,7 @@ use Redmine\Tests\Fixtures\MockClient; use stdClass; -/** - * @covers \Redmine\Api\Membership::listByProject - */ +#[CoversClass(Membership::class)] class ListByProjectTest extends TestCase { public function testListByProjectWithoutParametersReturnsResponse() @@ -71,6 +71,7 @@ public function testListByProjectWithParametersReturnsResponse() /** * @dataProvider getInvalidProjectIdentifiers */ + #[DataProvider('getInvalidProjectIdentifiers')] public function testListByProjectWithWrongProjectIdentifierThrowsException($projectIdentifier) { $api = new Membership(MockClient::create()); diff --git a/tests/Unit/Api/MembershipTest.php b/tests/Unit/Api/MembershipTest.php index 2e9a22a3..53f7b9ab 100644 --- a/tests/Unit/Api/MembershipTest.php +++ b/tests/Unit/Api/MembershipTest.php @@ -3,23 +3,21 @@ namespace Redmine\Tests\Unit\Api; use Exception; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Membership; use Redmine\Client\Client; -use Redmine\Exception\MissingParameterException; use Redmine\Tests\Fixtures\MockClient; /** - * @coversDefaultClass \Redmine\Api\Membership - * * @author Malte Gerth */ +#[CoversClass(Membership::class)] class MembershipTest extends TestCase { /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -45,10 +43,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllData - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponseWithProject($response, $responseType, $expectedResponse) { // Create the used mock objects @@ -82,9 +79,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParametersAndProject() { @@ -120,10 +114,6 @@ public function testAllReturnsClientGetResponseWithParametersAndProject() /** * Test remove(). - * - * @covers ::delete - * @covers ::remove - * @test */ public function testRemoveCallsDelete() { @@ -157,9 +147,6 @@ public function testRemoveCallsDelete() /** * Test removeMember(). - * - * @covers ::removeMember - * @test */ public function testRemoveMemberCallsDelete() { @@ -204,9 +191,6 @@ public function testRemoveMemberCallsDelete() /** * Test removeMember(). - * - * @covers ::removeMember - * @test */ public function testRemoveMemberReturnsFalseIfUserIsNotMemberOfProject() { @@ -232,9 +216,6 @@ public function testRemoveMemberReturnsFalseIfUserIsNotMemberOfProject() /** * Test removeMember(). - * - * @covers ::removeMember - * @test */ public function testRemoveMemberReturnsFalseIfMemberlistIsMissing() { @@ -261,9 +242,6 @@ public function testRemoveMemberReturnsFalseIfMemberlistIsMissing() /** * Test update(). * - * @covers ::update - * - * @test */ public function testUpdateThrowsExceptionIfRoleIdsAreMissingInParameters() { @@ -285,10 +263,6 @@ public function testUpdateThrowsExceptionIfRoleIdsAreMissingInParameters() /** * Test update(). - * - * @covers ::put - * @covers ::update - * @test */ public function testUpdateCallsPut() { diff --git a/tests/Unit/Api/News/ListByProjectTest.php b/tests/Unit/Api/News/ListByProjectTest.php index 863196bb..4fa4db83 100644 --- a/tests/Unit/Api/News/ListByProjectTest.php +++ b/tests/Unit/Api/News/ListByProjectTest.php @@ -2,6 +2,8 @@ namespace Redmine\Tests\Unit\Api\News; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\News; use Redmine\Client\Client; @@ -10,9 +12,7 @@ use Redmine\Tests\Fixtures\MockClient; use stdClass; -/** - * @covers \Redmine\Api\News::listByProject - */ +#[CoversClass(News::class)] class ListByProjectTest extends TestCase { public function testListByProjectWithoutParametersReturnsResponse() @@ -73,6 +73,7 @@ public function testListByProjectWithParametersReturnsResponse() /** * @dataProvider getInvalidProjectIdentifiers */ + #[DataProvider('getInvalidProjectIdentifiers')] public function testListByProjectWithWrongProjectIdentifierThrowsException($projectIdentifier) { $api = new News(MockClient::create()); diff --git a/tests/Unit/Api/News/ListTest.php b/tests/Unit/Api/News/ListTest.php index ec31cf16..ae6eee9d 100644 --- a/tests/Unit/Api/News/ListTest.php +++ b/tests/Unit/Api/News/ListTest.php @@ -2,14 +2,13 @@ namespace Redmine\Tests\Unit\Api\News; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\News; use Redmine\Client\Client; use Redmine\Exception\UnexpectedResponseException; -/** - * @covers \Redmine\Api\News::list - */ +#[CoversClass(News::class)] class ListTest extends TestCase { public function testListWithoutParametersReturnsResponse() diff --git a/tests/Unit/Api/NewsTest.php b/tests/Unit/Api/NewsTest.php index 7fbb4b6c..1c9f2545 100644 --- a/tests/Unit/Api/NewsTest.php +++ b/tests/Unit/Api/NewsTest.php @@ -2,22 +2,21 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\News; use Redmine\Client\Client; use Redmine\Tests\Fixtures\MockClient; /** - * @coversDefaultClass \Redmine\Api\News - * * @author Malte Gerth */ +#[CoversClass(News::class)] class NewsTest extends TestCase { /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -43,10 +42,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllData - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponse($response, $responseType, $expectedResponse) { // Create the used mock objects @@ -80,9 +78,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithProject() { @@ -115,9 +110,6 @@ public function testAllReturnsClientGetResponseWithProject() /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParametersAndProject() { diff --git a/tests/Unit/Api/Project/ArchiveTest.php b/tests/Unit/Api/Project/ArchiveTest.php index 9d6bb9dd..3e703897 100644 --- a/tests/Unit/Api/Project/ArchiveTest.php +++ b/tests/Unit/Api/Project/ArchiveTest.php @@ -5,15 +5,14 @@ namespace Redmine\Tests\Unit\Api\Project; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\Project; use Redmine\Exception\UnexpectedResponseException; use Redmine\Http\HttpClient; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\Project::archive - */ +#[CoversClass(Project::class)] class ArchiveTest extends TestCase { public function testArchiveReturnsTrue() diff --git a/tests/Unit/Api/Project/CloseTest.php b/tests/Unit/Api/Project/CloseTest.php index cacfbfc4..f40bb2b4 100644 --- a/tests/Unit/Api/Project/CloseTest.php +++ b/tests/Unit/Api/Project/CloseTest.php @@ -3,16 +3,14 @@ namespace Redmine\Tests\Unit\Api\Project; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\Project; use Redmine\Exception\UnexpectedResponseException; use Redmine\Http\HttpClient; -use Redmine\Http\Response; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\Project::close - */ +#[CoversClass(Project::class)] class CloseTest extends TestCase { public function testCloseReturnsTrue() diff --git a/tests/Unit/Api/Project/CreateTest.php b/tests/Unit/Api/Project/CreateTest.php index 780ab6f9..98cfdae8 100644 --- a/tests/Unit/Api/Project/CreateTest.php +++ b/tests/Unit/Api/Project/CreateTest.php @@ -2,6 +2,8 @@ namespace Redmine\Tests\Unit\Api\Project; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Project; use Redmine\Exception\MissingParameterException; @@ -9,14 +11,13 @@ use Redmine\Tests\Fixtures\AssertingHttpClient; use SimpleXMLElement; -/** - * @covers \Redmine\Api\Project::create - */ +#[CoversClass(Project::class)] class CreateTest extends TestCase { /** * @dataProvider getCreateData */ + #[DataProvider('getCreateData')] public function testCreateReturnsCorrectResponse($parameters, $expectedPath, $expectedBody, $responseCode, $response) { $client = AssertingHttpClient::create( @@ -172,6 +173,7 @@ public function testCreateThrowsExceptionWithEmptyParameters() /** * @dataProvider incompleteCreateParameterProvider */ + #[DataProvider('incompleteCreateParameterProvider')] public function testCreateThrowsExceptionIfMandatoyParametersAreMissing($parameters) { // Create the used mock objects diff --git a/tests/Unit/Api/Project/ListTest.php b/tests/Unit/Api/Project/ListTest.php index e85de578..efe1fee6 100644 --- a/tests/Unit/Api/Project/ListTest.php +++ b/tests/Unit/Api/Project/ListTest.php @@ -2,14 +2,13 @@ namespace Redmine\Tests\Unit\Api\Project; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\Project; use Redmine\Client\Client; use Redmine\Exception\UnexpectedResponseException; -/** - * @covers \Redmine\Api\Project::list - */ +#[CoversClass(Project::class)] class ListTest extends TestCase { public function testListWithoutParametersReturnsResponse() diff --git a/tests/Unit/Api/Project/ReopenTest.php b/tests/Unit/Api/Project/ReopenTest.php index 6978783c..f9426ffb 100644 --- a/tests/Unit/Api/Project/ReopenTest.php +++ b/tests/Unit/Api/Project/ReopenTest.php @@ -3,15 +3,14 @@ namespace Redmine\Tests\Unit\Api\Project; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\Project; use Redmine\Exception\UnexpectedResponseException; use Redmine\Http\HttpClient; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\Project::reopen - */ +#[CoversClass(Project::class)] class ReopenTest extends TestCase { public function testReopenReturnsTrue() diff --git a/tests/Unit/Api/Project/ShowTest.php b/tests/Unit/Api/Project/ShowTest.php index 21429ee2..f8d4c663 100644 --- a/tests/Unit/Api/Project/ShowTest.php +++ b/tests/Unit/Api/Project/ShowTest.php @@ -2,18 +2,19 @@ namespace Redmine\Tests\Unit\Api\Project; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Project; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\Project::show - */ +#[CoversClass(Project::class)] class ShowTest extends TestCase { /** * @dataProvider getShowData */ + #[DataProvider('getShowData')] public function testShowReturnsCorrectResponse($identifier, array $params, $expectedPath, $response, $expectedReturn) { $client = AssertingHttpClient::create( diff --git a/tests/Unit/Api/Project/UnarchiveTest.php b/tests/Unit/Api/Project/UnarchiveTest.php index 0ac0eaf0..84776bf2 100644 --- a/tests/Unit/Api/Project/UnarchiveTest.php +++ b/tests/Unit/Api/Project/UnarchiveTest.php @@ -3,16 +3,14 @@ namespace Redmine\Tests\Unit\Api\Project; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\Project; use Redmine\Exception\UnexpectedResponseException; use Redmine\Http\HttpClient; -use Redmine\Http\Response; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\Project::unarchive - */ +#[CoversClass(Project::class)] class UnarchiveTest extends TestCase { public function testUnarchiveReturnsTrue() diff --git a/tests/Unit/Api/ProjectTest.php b/tests/Unit/Api/ProjectTest.php index 18d07b6e..32b09e40 100644 --- a/tests/Unit/Api/ProjectTest.php +++ b/tests/Unit/Api/ProjectTest.php @@ -2,25 +2,23 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Project; use Redmine\Client\Client; -use Redmine\Exception\MissingParameterException; use Redmine\Tests\Fixtures\MockClient; use ReflectionMethod; use SimpleXMLElement; /** - * @coversDefaultClass \Redmine\Api\Project - * * @author Malte Gerth */ +#[CoversClass(Project::class)] class ProjectTest extends TestCase { /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -46,10 +44,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllData - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponse($response, $responseType, $expectedResponse) { // Create the used mock objects @@ -83,9 +80,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParameters() { @@ -121,10 +115,6 @@ public function testAllReturnsClientGetResponseWithParameters() /** * Test remove(). - * - * @covers ::delete - * @covers ::remove - * @test */ public function testRemoveCallsDelete() { @@ -150,9 +140,6 @@ public function testRemoveCallsDelete() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingReturnsNameIdArray() { @@ -187,9 +174,6 @@ public function testListingReturnsNameIdArray() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetOnlyTheFirstTime() { @@ -225,9 +209,6 @@ public function testListingCallsGetOnlyTheFirstTime() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetEveryTimeWithForceUpdate() { @@ -263,9 +244,6 @@ public function testListingCallsGetEveryTimeWithForceUpdate() /** * Test getIdByName(). - * - * @covers ::getIdByName - * @test */ public function testGetIdByNameMakesGetRequest() { @@ -297,10 +275,6 @@ public function testGetIdByNameMakesGetRequest() /** * Test update(). - * - * @covers ::put - * @covers ::update - * @test */ public function testUpdateCallsPut() { @@ -327,9 +301,6 @@ public function testUpdateCallsPut() $this->assertSame($response, $api->update(5, $parameters)); } - /** - * @covers \Redmine\Api\Project::prepareParamsXml - */ public function testDeprecatedPrepareParamsXml() { $client = $this->createMock(Client::class); diff --git a/tests/Unit/Api/Query/ListTest.php b/tests/Unit/Api/Query/ListTest.php index fd39cc35..e000b977 100644 --- a/tests/Unit/Api/Query/ListTest.php +++ b/tests/Unit/Api/Query/ListTest.php @@ -2,14 +2,13 @@ namespace Redmine\Tests\Unit\Api\Query; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\Query; use Redmine\Client\Client; use Redmine\Exception\UnexpectedResponseException; -/** - * @covers \Redmine\Api\Query::list - */ +#[CoversClass(Query::class)] class ListTest extends TestCase { public function testListWithoutParametersReturnsResponse() diff --git a/tests/Unit/Api/QueryTest.php b/tests/Unit/Api/QueryTest.php index 0b22773e..10411455 100644 --- a/tests/Unit/Api/QueryTest.php +++ b/tests/Unit/Api/QueryTest.php @@ -2,22 +2,21 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Query; use Redmine\Client\Client; use Redmine\Tests\Fixtures\MockClient; /** - * @coversDefaultClass \Redmine\Api\Query - * * @author Malte Gerth */ +#[CoversClass(Query::class)] class QueryTest extends TestCase { /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -43,10 +42,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllData - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponse($response, $responseType, $expectedResponse) { // Create the used mock objects @@ -80,9 +78,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParameters() { diff --git a/tests/Unit/Api/Role/ListTest.php b/tests/Unit/Api/Role/ListTest.php index ec1dd55f..b0026edd 100644 --- a/tests/Unit/Api/Role/ListTest.php +++ b/tests/Unit/Api/Role/ListTest.php @@ -2,14 +2,13 @@ namespace Redmine\Tests\Unit\Api\Role; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\Role; use Redmine\Client\Client; use Redmine\Exception\UnexpectedResponseException; -/** - * @covers \Redmine\Api\Role::list - */ +#[CoversClass(Role::class)] class ListTest extends TestCase { public function testListWithoutParametersReturnsResponse() diff --git a/tests/Unit/Api/Role/ShowTest.php b/tests/Unit/Api/Role/ShowTest.php index af7c24cb..4dd64df3 100644 --- a/tests/Unit/Api/Role/ShowTest.php +++ b/tests/Unit/Api/Role/ShowTest.php @@ -2,18 +2,19 @@ namespace Redmine\Tests\Unit\Api\Role; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Role; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\Role::show - */ +#[CoversClass(Role::class)] class ShowTest extends TestCase { /** * @dataProvider getShowData */ + #[DataProvider('getShowData')] public function testShowReturnsCorrectResponse($id, $expectedPath, $response, $expectedReturn) { $client = AssertingHttpClient::create( diff --git a/tests/Unit/Api/RoleTest.php b/tests/Unit/Api/RoleTest.php index 75f8d6ff..51263ba6 100644 --- a/tests/Unit/Api/RoleTest.php +++ b/tests/Unit/Api/RoleTest.php @@ -2,22 +2,21 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Role; use Redmine\Client\Client; use Redmine\Tests\Fixtures\MockClient; /** - * @coversDefaultClass \Redmine\Api\Role - * * @author Malte Gerth */ +#[CoversClass(Role::class)] class RoleTest extends TestCase { /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -43,10 +42,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllData - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponse($response, $responseType, $expectedResponse) { // Create the used mock objects @@ -80,9 +78,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParametersAndProject() { @@ -118,9 +113,6 @@ public function testAllReturnsClientGetResponseWithParametersAndProject() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingReturnsNameIdArray() { @@ -155,9 +147,6 @@ public function testListingReturnsNameIdArray() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetOnlyTheFirstTime() { @@ -193,9 +182,6 @@ public function testListingCallsGetOnlyTheFirstTime() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetEveryTimeWithForceUpdate() { diff --git a/tests/Unit/Api/Search/ListByQueryTest.php b/tests/Unit/Api/Search/ListByQueryTest.php index 3d284e0a..d80515c1 100644 --- a/tests/Unit/Api/Search/ListByQueryTest.php +++ b/tests/Unit/Api/Search/ListByQueryTest.php @@ -2,15 +2,13 @@ namespace Redmine\Tests\Unit\Api\Search; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\Search; use Redmine\Client\Client; use Redmine\Exception\UnexpectedResponseException; -use Redmine\Tests\Fixtures\MockClient; -/** - * @covers \Redmine\Api\Search::listByQuery - */ +#[CoversClass(Search::class)] class ListByQueryTest extends TestCase { public function testListByQueryWithoutParametersReturnsResponse() diff --git a/tests/Unit/Api/Search/SearchTest.php b/tests/Unit/Api/Search/SearchTest.php index 2eb9126d..def15aee 100644 --- a/tests/Unit/Api/Search/SearchTest.php +++ b/tests/Unit/Api/Search/SearchTest.php @@ -2,14 +2,14 @@ namespace Redmine\Tests\Unit\Api\Search; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Search; use Redmine\Client\Client; use Redmine\Tests\Fixtures\MockClient; -/** - * @covers \Redmine\Api\Search::search - */ +#[CoversClass(Search::class)] class SearchTest extends TestCase { public function testSearchTriggersDeprecationWarning() @@ -36,6 +36,7 @@ function ($errno, $errstr): bool { /** * @dataProvider getAllData */ + #[DataProvider('getAllData')] public function testSearchReturnsClientGetResponse($response, $responseType, $expectedResponse) { // Create the used mock objects diff --git a/tests/Unit/Api/TimeEntry/CreateTest.php b/tests/Unit/Api/TimeEntry/CreateTest.php index 753735c1..4bbbb7c2 100644 --- a/tests/Unit/Api/TimeEntry/CreateTest.php +++ b/tests/Unit/Api/TimeEntry/CreateTest.php @@ -2,6 +2,8 @@ namespace Redmine\Tests\Unit\Api\TimeEntry; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\TimeEntry; use Redmine\Exception\MissingParameterException; @@ -9,14 +11,13 @@ use Redmine\Tests\Fixtures\AssertingHttpClient; use SimpleXMLElement; -/** - * @covers \Redmine\Api\TimeEntry::create - */ +#[CoversClass(TimeEntry::class)] class CreateTest extends TestCase { /** * @dataProvider getCreateData */ + #[DataProvider('getCreateData')] public function testCreateReturnsCorrectResponse($parameters, $expectedPath, $expectedBody, $responseCode, $response) { $client = AssertingHttpClient::create( @@ -147,6 +148,7 @@ public function testCreateThrowsExceptionWithEmptyParameters() /** * @dataProvider incompleteCreateParameterProvider */ + #[DataProvider('incompleteCreateParameterProvider')] public function testCreateThrowsExceptionIfValueIsMissingInParameters($parameters) { // Create the used mock objects diff --git a/tests/Unit/Api/TimeEntry/ListTest.php b/tests/Unit/Api/TimeEntry/ListTest.php index 963414b0..0524d9da 100644 --- a/tests/Unit/Api/TimeEntry/ListTest.php +++ b/tests/Unit/Api/TimeEntry/ListTest.php @@ -2,14 +2,13 @@ namespace Redmine\Tests\Unit\Api\TimeEntry; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\TimeEntry; use Redmine\Client\Client; use Redmine\Exception\UnexpectedResponseException; -/** - * @covers \Redmine\Api\TimeEntry::list - */ +#[CoversClass(TimeEntry::class)] class ListTest extends TestCase { public function testListWithoutParametersReturnsResponse() diff --git a/tests/Unit/Api/TimeEntry/ShowTest.php b/tests/Unit/Api/TimeEntry/ShowTest.php index d2f0e1a8..c6444407 100644 --- a/tests/Unit/Api/TimeEntry/ShowTest.php +++ b/tests/Unit/Api/TimeEntry/ShowTest.php @@ -2,18 +2,19 @@ namespace Redmine\Tests\Unit\Api\TimeEntry; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\TimeEntry; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\TimeEntry::show - */ +#[CoversClass(TimeEntry::class)] class ShowTest extends TestCase { /** * @dataProvider getShowData */ + #[DataProvider('getShowData')] public function testShowReturnsCorrectResponse($id, $expectedPath, $response, $expectedReturn) { $client = AssertingHttpClient::create( diff --git a/tests/Unit/Api/TimeEntryActivity/ListTest.php b/tests/Unit/Api/TimeEntryActivity/ListTest.php index 439817dc..38127a3d 100644 --- a/tests/Unit/Api/TimeEntryActivity/ListTest.php +++ b/tests/Unit/Api/TimeEntryActivity/ListTest.php @@ -2,14 +2,13 @@ namespace Redmine\Tests\Unit\Api\TimeEntryActivity; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\TimeEntryActivity; use Redmine\Client\Client; use Redmine\Exception\UnexpectedResponseException; -/** - * @coversDefaultClass \Redmine\Api\TimeEntryActivity::list - */ +#[CoversClass(TimeEntryActivity::class)] class ListTest extends TestCase { public function testListWithoutParametersReturnsResponse() diff --git a/tests/Unit/Api/TimeEntryActivityTest.php b/tests/Unit/Api/TimeEntryActivityTest.php index 492e563e..e74118d7 100644 --- a/tests/Unit/Api/TimeEntryActivityTest.php +++ b/tests/Unit/Api/TimeEntryActivityTest.php @@ -2,22 +2,21 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\TimeEntryActivity; use Redmine\Client\Client; use Redmine\Tests\Fixtures\MockClient; /** - * @coversDefaultClass \Redmine\Api\TimeEntryActivity - * * @author Malte Gerth */ +#[CoversClass(TimeEntryActivity::class)] class TimeEntryActivityTest extends TestCase { /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -43,10 +42,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllData - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponse($response, $responseType, $expectedResponse) { // Create the used mock objects @@ -80,9 +78,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParameters() { diff --git a/tests/Unit/Api/TimeEntryTest.php b/tests/Unit/Api/TimeEntryTest.php index 4f2f25e2..f228d1c3 100644 --- a/tests/Unit/Api/TimeEntryTest.php +++ b/tests/Unit/Api/TimeEntryTest.php @@ -2,23 +2,21 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\TimeEntry; use Redmine\Client\Client; -use Redmine\Exception\MissingParameterException; use Redmine\Tests\Fixtures\MockClient; /** - * @coversDefaultClass \Redmine\Api\TimeEntry - * * @author Malte Gerth */ +#[CoversClass(TimeEntry::class)] class TimeEntryTest extends TestCase { /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -44,10 +42,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllData - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponse($response, $responseType, $expectedResponse) { // Create the used mock objects @@ -81,9 +78,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParameters() { @@ -125,10 +119,6 @@ public function testAllReturnsClientGetResponseWithParameters() /** * Test remove(). - * - * @covers ::delete - * @covers ::remove - * @test */ public function testRemoveCallsDelete() { @@ -154,10 +144,6 @@ public function testRemoveCallsDelete() /** * Test update(). - * - * @covers ::put - * @covers ::update - * @test */ public function testUpdateCallsPut() { diff --git a/tests/Unit/Api/Tracker/ListTest.php b/tests/Unit/Api/Tracker/ListTest.php index 8318b44b..5e9ac948 100644 --- a/tests/Unit/Api/Tracker/ListTest.php +++ b/tests/Unit/Api/Tracker/ListTest.php @@ -2,14 +2,13 @@ namespace Redmine\Tests\Unit\Api\Tracker; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\Tracker; use Redmine\Client\Client; use Redmine\Exception\UnexpectedResponseException; -/** - * @covers \Redmine\Api\Tracker::list - */ +#[CoversClass(Tracker::class)] class ListTest extends TestCase { public function testListWithoutParametersReturnsResponse() diff --git a/tests/Unit/Api/TrackerTest.php b/tests/Unit/Api/TrackerTest.php index 35343bf1..4ba07e45 100644 --- a/tests/Unit/Api/TrackerTest.php +++ b/tests/Unit/Api/TrackerTest.php @@ -2,22 +2,21 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Tracker; use Redmine\Client\Client; use Redmine\Tests\Fixtures\MockClient; /** - * @coversDefaultClass \Redmine\Api\Tracker - * * @author Malte Gerth */ +#[CoversClass(Tracker::class)] class TrackerTest extends TestCase { /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -43,10 +42,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllData - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponse($response, $responseType, $expectedResponse) { // Create the used mock objects @@ -80,9 +78,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParametersAndProject() { @@ -118,9 +113,6 @@ public function testAllReturnsClientGetResponseWithParametersAndProject() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingReturnsNameIdArray() { @@ -155,9 +147,6 @@ public function testListingReturnsNameIdArray() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetOnlyTheFirstTime() { @@ -193,9 +182,6 @@ public function testListingCallsGetOnlyTheFirstTime() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetEveryTimeWithForceUpdate() { @@ -231,9 +217,6 @@ public function testListingCallsGetEveryTimeWithForceUpdate() /** * Test getIdByName(). - * - * @covers ::getIdByName - * @test */ public function testGetIdByNameMakesGetRequest() { diff --git a/tests/Unit/Api/User/CreateTest.php b/tests/Unit/Api/User/CreateTest.php index 0bd6be32..556f67ae 100644 --- a/tests/Unit/Api/User/CreateTest.php +++ b/tests/Unit/Api/User/CreateTest.php @@ -2,6 +2,8 @@ namespace Redmine\Tests\Unit\Api\User; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\User; use Redmine\Exception\MissingParameterException; @@ -9,14 +11,13 @@ use Redmine\Tests\Fixtures\AssertingHttpClient; use SimpleXMLElement; -/** - * @covers \Redmine\Api\User::create - */ +#[CoversClass(User::class)] class CreateTest extends TestCase { /** * @dataProvider getCreateData */ + #[DataProvider('getCreateData')] public function testCreateReturnsCorrectResponse($parameters, $expectedPath, $expectedBody, $responseCode, $response) { $client = AssertingHttpClient::create( @@ -134,6 +135,7 @@ public function testCreateThrowsExceptionWithEmptyParameters() /** * @dataProvider incompleteCreateParameterProvider */ + #[DataProvider('incompleteCreateParameterProvider')] public function testCreateThrowsExceptionIfValueIsMissingInParameters($parameters) { // Create the used mock objects diff --git a/tests/Unit/Api/User/ListTest.php b/tests/Unit/Api/User/ListTest.php index 8d0f1311..ab12faf7 100644 --- a/tests/Unit/Api/User/ListTest.php +++ b/tests/Unit/Api/User/ListTest.php @@ -2,14 +2,13 @@ namespace Redmine\Tests\Unit\Api\User; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Api\User; use Redmine\Client\Client; use Redmine\Exception\UnexpectedResponseException; -/** - * @covers \Redmine\Api\User::list - */ +#[CoversClass(User::class)] class ListTest extends TestCase { public function testListWithoutParametersReturnsResponse() diff --git a/tests/Unit/Api/User/ShowTest.php b/tests/Unit/Api/User/ShowTest.php index 57cdc60f..9de66df5 100644 --- a/tests/Unit/Api/User/ShowTest.php +++ b/tests/Unit/Api/User/ShowTest.php @@ -2,18 +2,19 @@ namespace Redmine\Tests\Unit\Api\User; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\User; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\User::show - */ +#[CoversClass(User::class)] class ShowTest extends TestCase { /** * @dataProvider getShowData */ + #[DataProvider('getShowData')] public function testShowReturnsCorrectResponse($userId, array $params, $expectedPath, $response, $expectedReturn) { $client = AssertingHttpClient::create( diff --git a/tests/Unit/Api/UserTest.php b/tests/Unit/Api/UserTest.php index 12f60e6d..ad34c0fc 100644 --- a/tests/Unit/Api/UserTest.php +++ b/tests/Unit/Api/UserTest.php @@ -2,23 +2,21 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\User; use Redmine\Client\Client; use Redmine\Tests\Fixtures\MockClient; /** - * @coversDefaultClass \Redmine\Api\User - * * @author Malte Gerth */ +#[CoversClass(User::class)] class UserTest extends TestCase { /** * Test getCurrentUser(). - * - * @covers ::getCurrentUser - * @test */ public function testGetCurrentUserReturnsClientGetResponse() { @@ -53,9 +51,6 @@ public function testGetCurrentUserReturnsClientGetResponse() /** * Test getIdByUsername(). - * - * @covers ::getIdByUsername - * @test */ public function testGetIdByUsernameMakesGetRequest() { @@ -90,8 +85,6 @@ public function testGetIdByUsernameMakesGetRequest() /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -117,10 +110,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllData - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponse($response, $responseType, $expectedResponse) { // Create the used mock objects @@ -154,9 +146,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParameters() { @@ -196,10 +185,6 @@ public function testAllReturnsClientGetResponseWithParameters() /** * Test remove(). - * - * @covers ::delete - * @covers ::remove - * @test */ public function testRemoveCallsDelete() { @@ -225,10 +210,6 @@ public function testRemoveCallsDelete() /** * Test update(). - * - * @covers ::put - * @covers ::update - * @test */ public function testUpdateCallsPut() { @@ -264,11 +245,6 @@ public function testUpdateCallsPut() /** * Test update(). - * - * @covers ::put - * @covers ::update - * @covers ::attachCustomFieldXML - * @test */ public function testUpdateWithCustomField() { @@ -313,9 +289,6 @@ public function testUpdateWithCustomField() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingReturnsNameIdArray() { @@ -350,9 +323,6 @@ public function testListingReturnsNameIdArray() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetOnlyTheFirstTime() { @@ -388,9 +358,6 @@ public function testListingCallsGetOnlyTheFirstTime() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetEveryTimeWithForceUpdate() { diff --git a/tests/Unit/Api/Version/CreateTest.php b/tests/Unit/Api/Version/CreateTest.php index 4531710c..e54e780f 100644 --- a/tests/Unit/Api/Version/CreateTest.php +++ b/tests/Unit/Api/Version/CreateTest.php @@ -2,6 +2,8 @@ namespace Redmine\Tests\Unit\Api\Version; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Version; use Redmine\Exception\InvalidParameterException; @@ -10,14 +12,13 @@ use Redmine\Tests\Fixtures\AssertingHttpClient; use SimpleXMLElement; -/** - * @covers \Redmine\Api\Version::create - */ +#[CoversClass(Version::class)] class CreateTest extends TestCase { /** * @dataProvider getCreateData */ + #[DataProvider('getCreateData')] public function testCreateReturnsCorrectResponse($identifier, $parameters, $expectedPath, $expectedBody, $responseCode, $response) { $client = AssertingHttpClient::create( diff --git a/tests/Unit/Api/Version/ListByProjectTest.php b/tests/Unit/Api/Version/ListByProjectTest.php index a9fca8d5..d993f65d 100644 --- a/tests/Unit/Api/Version/ListByProjectTest.php +++ b/tests/Unit/Api/Version/ListByProjectTest.php @@ -2,6 +2,8 @@ namespace Redmine\Tests\Unit\Api\Version; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Version; use Redmine\Client\Client; @@ -10,9 +12,7 @@ use Redmine\Tests\Fixtures\MockClient; use stdClass; -/** - * @covers \Redmine\Api\Version::listByProject - */ +#[CoversClass(Version::class)] class ListByProjectTest extends TestCase { public function testListByProjectWithoutParametersReturnsResponse() @@ -74,6 +74,7 @@ public function testListByProjectWithParametersReturnsResponse() /** * @dataProvider getInvalidProjectIdentifiers */ + #[DataProvider('getInvalidProjectIdentifiers')] public function testListByProjectWithWrongProjectIdentifierThrowsException($projectIdentifier) { $api = new Version(MockClient::create()); diff --git a/tests/Unit/Api/Version/ShowTest.php b/tests/Unit/Api/Version/ShowTest.php index 1e3cbade..15286c8a 100644 --- a/tests/Unit/Api/Version/ShowTest.php +++ b/tests/Unit/Api/Version/ShowTest.php @@ -2,18 +2,19 @@ namespace Redmine\Tests\Unit\Api\Version; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Version; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\Version::show - */ +#[CoversClass(Version::class)] class ShowTest extends TestCase { /** * @dataProvider getShowData */ + #[DataProvider('getShowData')] public function testShowReturnsCorrectResponse($version, $expectedPath, $response, $expectedReturn) { $client = AssertingHttpClient::create( diff --git a/tests/Unit/Api/VersionTest.php b/tests/Unit/Api/VersionTest.php index cc276b9f..643ce7f2 100644 --- a/tests/Unit/Api/VersionTest.php +++ b/tests/Unit/Api/VersionTest.php @@ -2,6 +2,8 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Version; use Redmine\Client\Client; @@ -9,16 +11,13 @@ use Redmine\Tests\Fixtures\MockClient; /** - * @coversDefaultClass \Redmine\Api\Version - * * @author Malte Gerth */ +#[CoversClass(Version::class)] class VersionTest extends TestCase { /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -44,10 +43,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllData - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponse($response, $responseType, $expectedResponse) { // Create the used mock objects @@ -81,9 +79,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParameters() { @@ -123,10 +118,6 @@ public function testAllReturnsClientGetResponseWithParameters() /** * Test remove(). - * - * @covers ::delete - * @covers ::remove - * @test */ public function testRemoveWithNumericIdCallsDelete() { @@ -152,10 +143,6 @@ public function testRemoveWithNumericIdCallsDelete() /** * Test remove(). - * - * @covers ::delete - * @covers ::remove - * @test */ public function testRemoveWithStringCallsDelete() { @@ -182,10 +169,6 @@ public function testRemoveWithStringCallsDelete() /** * Test update(). * - * @covers ::update - * @covers ::validateStatus - * - * @test */ public function testUpdateThrowsExceptionWithInvalidStatus() { @@ -210,10 +193,6 @@ public function testUpdateThrowsExceptionWithInvalidStatus() /** * Test update(). - * - * @covers ::put - * @covers ::update - * @test */ public function testUpdateCallsPut() { @@ -249,11 +228,6 @@ public function testUpdateCallsPut() /** * Test update(). - * - * @covers ::update - * @covers ::put - * @covers ::validateStatus - * @test */ public function testUpdateWithValidStatusCallsPut() { @@ -291,9 +265,6 @@ public function testUpdateWithValidStatusCallsPut() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingReturnsNameIdArray() { @@ -326,9 +297,6 @@ public function testListingReturnsNameIdArray() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingReturnsIdNameIfReverseIsFalseArray() { @@ -361,9 +329,6 @@ public function testListingReturnsIdNameIfReverseIsFalseArray() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetOnlyTheFirstTime() { @@ -397,9 +362,6 @@ public function testListingCallsGetOnlyTheFirstTime() /** * Test listing(). - * - * @covers ::listing - * @test */ public function testListingCallsGetEveryTimeWithForceUpdate() { @@ -433,9 +395,6 @@ public function testListingCallsGetEveryTimeWithForceUpdate() /** * Test getIdByName(). - * - * @covers ::getIdByName - * @test */ public function testGetIdByNameMakesGetRequest() { @@ -468,14 +427,12 @@ public function testGetIdByNameMakesGetRequest() /** * Test validateSharing(). * - * @covers ::create - * @covers ::validateSharing * @dataProvider invalidSharingProvider * - * @test * * @param string $sharingValue */ + #[DataProvider('invalidSharingProvider')] public function testCreateThrowsExceptionWithInvalidSharing($sharingValue) { // Test values @@ -500,14 +457,12 @@ public function testCreateThrowsExceptionWithInvalidSharing($sharingValue) /** * Test validateSharing(). * - * @covers ::update - * @covers ::validateSharing * @dataProvider validSharingProvider - * @test * * @param string $sharingValue * @param string $sharingXmlElement */ + #[DataProvider('validSharingProvider')] public function testUpdateWithValidSharing($sharingValue, $sharingXmlElement) { // Test values @@ -545,13 +500,11 @@ public function testUpdateWithValidSharing($sharingValue, $sharingXmlElement) /** * Test validateSharing(). * - * @covers ::update - * @covers ::validateSharing * @dataProvider validEmptySharingProvider - * @test * * @param string $sharingValue */ + #[DataProvider('validEmptySharingProvider')] public function testUpdateWithValidEmptySharing($sharingValue) { // Test values @@ -591,14 +544,12 @@ public function testUpdateWithValidEmptySharing($sharingValue) /** * Test validateSharing(). * - * @covers ::update - * @covers ::validateSharing * @dataProvider invalidSharingProvider * - * @test * * @param string $sharingValue */ + #[DataProvider('invalidSharingProvider')] public function testUpdateThrowsExceptionWithInvalidSharing($sharingValue) { // Test values diff --git a/tests/Unit/Api/Wiki/ListByProjectTest.php b/tests/Unit/Api/Wiki/ListByProjectTest.php index 1a336e5e..31381a22 100644 --- a/tests/Unit/Api/Wiki/ListByProjectTest.php +++ b/tests/Unit/Api/Wiki/ListByProjectTest.php @@ -2,6 +2,8 @@ namespace Redmine\Tests\Unit\Api\Wiki; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Wiki; use Redmine\Client\Client; @@ -10,9 +12,7 @@ use Redmine\Tests\Fixtures\MockClient; use stdClass; -/** - * @covers \Redmine\Api\Wiki::listByProject - */ +#[CoversClass(Wiki::class)] class ListByProjectTest extends TestCase { public function testListByProjectWithoutParametersReturnsResponse() @@ -74,6 +74,7 @@ public function testListByProjectWithParametersReturnsResponse() /** * @dataProvider getInvalidProjectIdentifiers */ + #[DataProvider('getInvalidProjectIdentifiers')] public function testListByProjectWithWrongProjectIdentifierThrowsException($projectIdentifier) { $api = new Wiki(MockClient::create()); diff --git a/tests/Unit/Api/Wiki/ShowTest.php b/tests/Unit/Api/Wiki/ShowTest.php index 07bff14c..eb6b2fb5 100644 --- a/tests/Unit/Api/Wiki/ShowTest.php +++ b/tests/Unit/Api/Wiki/ShowTest.php @@ -2,18 +2,19 @@ namespace Redmine\Tests\Unit\Api\Wiki; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Wiki; use Redmine\Tests\Fixtures\AssertingHttpClient; -/** - * @covers \Redmine\Api\Wiki::show - */ +#[CoversClass(Wiki::class)] class ShowTest extends TestCase { /** * @dataProvider getShowData */ + #[DataProvider('getShowData')] public function testShowReturnsCorrectResponse($identifier, $page, $version, $expectedPath, $response, $expectedReturn) { $client = AssertingHttpClient::create( diff --git a/tests/Unit/Api/WikiTest.php b/tests/Unit/Api/WikiTest.php index ace37136..1f3e9f75 100644 --- a/tests/Unit/Api/WikiTest.php +++ b/tests/Unit/Api/WikiTest.php @@ -2,22 +2,21 @@ namespace Redmine\Tests\Unit\Api; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Api\Wiki; use Redmine\Client\Client; use Redmine\Tests\Fixtures\MockClient; /** - * @coversDefaultClass \Redmine\Api\Wiki - * * @author Malte Gerth */ +#[CoversClass(Wiki::class)] class WikiTest extends TestCase { /** * Test all(). - * - * @covers ::all */ public function testAllTriggersDeprecationWarning() { @@ -43,10 +42,9 @@ function ($errno, $errstr): bool { /** * Test all(). * - * @covers ::all * @dataProvider getAllData - * @test */ + #[DataProvider('getAllData')] public function testAllReturnsClientGetResponse($response, $responseType, $expectedResponse) { // Create the used mock objects @@ -80,9 +78,6 @@ public static function getAllData(): array /** * Test all(). - * - * @covers ::all - * @test */ public function testAllReturnsClientGetResponseWithParameters() { @@ -122,10 +117,6 @@ public function testAllReturnsClientGetResponseWithParameters() /** * Test remove(). - * - * @covers ::delete - * @covers ::remove - * @test */ public function testRemoveCallsDelete() { @@ -151,10 +142,6 @@ public function testRemoveCallsDelete() /** * Test create(). - * - * @covers ::create - * @covers ::post - * @test */ public function testCreateCallsPost() { @@ -183,10 +170,6 @@ public function testCreateCallsPost() /** * Test create(). - * - * @covers ::create - * @covers ::post - * @test */ public function testCreateWithParametersCallsPost() { @@ -226,10 +209,6 @@ public function testCreateWithParametersCallsPost() /** * Test update(). - * - * @covers ::put - * @covers ::update - * @test */ public function testUpdateCallsPut() { @@ -258,10 +237,6 @@ public function testUpdateCallsPut() /** * Test update(). - * - * @covers ::put - * @covers ::update - * @test */ public function testUpdateWithParametersCallsPut() { diff --git a/tests/Unit/Client/NativeCurlClient/RequestTest.php b/tests/Unit/Client/NativeCurlClient/RequestTest.php index ccdc05c4..63523a24 100644 --- a/tests/Unit/Client/NativeCurlClient/RequestTest.php +++ b/tests/Unit/Client/NativeCurlClient/RequestTest.php @@ -3,18 +3,15 @@ namespace Redmine\Tests\Unit\Client\NativeCurlClientTest; use phpmock\phpunit\PHPMock; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Client\NativeCurlClient; use Redmine\Http\Request; use Redmine\Http\Response; use stdClass; -/** - * @covers \Redmine\Client\NativeCurlClient::request - * @covers \Redmine\Client\NativeCurlClient::runRequest - * @covers \Redmine\Client\NativeCurlClient::createCurl - * @covers \Redmine\Client\NativeCurlClient::createHttpHeader - */ +#[CoversClass(NativeCurlClient::class)] class RequestTest extends TestCase { use PHPMock; @@ -22,6 +19,7 @@ class RequestTest extends TestCase /** * @dataProvider getRequestReponseData */ + #[DataProvider('getRequestReponseData')] public function testRequestReturnsCorrectResponse($method, $data, $statusCode, $contentType, $content) { $namespace = 'Redmine\Client'; @@ -37,10 +35,10 @@ public function testRequestReturnsCorrectResponse($method, $data, $statusCode, $ $curlSetoptArray = $this->getFunctionMock($namespace, 'curl_setopt_array'); $curlGetinfo = $this->getFunctionMock($namespace, 'curl_getinfo'); - $curlGetinfo->expects($this->exactly(2))->will($this->returnValueMap(([ + $curlGetinfo->expects($this->exactly(2))->willReturnMap(([ [$curl, CURLINFO_HTTP_CODE, $statusCode], [$curl, CURLINFO_CONTENT_TYPE, $contentType], - ]))); + ])); $curlErrno = $this->getFunctionMock($namespace, 'curl_errno'); $curlErrno->expects($this->exactly(1))->willReturn(CURLE_OK); @@ -52,6 +50,7 @@ public function testRequestReturnsCorrectResponse($method, $data, $statusCode, $ 'access_token' ); + /** @var Request|\PHPUnit\Framework\MockObject\MockObject */ $request = $this->createConfiguredMock(Request::class, [ 'getMethod' => $method, 'getPath' => '/path', @@ -109,10 +108,10 @@ public function testRequestWithUploadAndFilepathReturnsCorrectResponse() $curlSetoptArray = $this->getFunctionMock($namespace, 'curl_setopt_array'); $curlGetinfo = $this->getFunctionMock($namespace, 'curl_getinfo'); - $curlGetinfo->expects($this->exactly(2))->will($this->returnValueMap(([ + $curlGetinfo->expects($this->exactly(2))->willReturnMap(([ [$curl, CURLINFO_HTTP_CODE, 201], [$curl, CURLINFO_CONTENT_TYPE, 'application/json'], - ]))); + ])); $curlErrno = $this->getFunctionMock($namespace, 'curl_errno'); $curlErrno->expects($this->exactly(1))->willReturn(CURLE_OK); @@ -138,6 +137,7 @@ function ($errno, $errstr): bool { E_USER_DEPRECATED ); + /** @var Request|\PHPUnit\Framework\MockObject\MockObject */ $request = $this->createConfiguredMock(Request::class, [ 'getMethod' => 'POST', 'getPath' => '/uploads.json', diff --git a/tests/Unit/Client/NativeCurlClientTest.php b/tests/Unit/Client/NativeCurlClientTest.php index ec317453..32af6d89 100644 --- a/tests/Unit/Client/NativeCurlClientTest.php +++ b/tests/Unit/Client/NativeCurlClientTest.php @@ -7,12 +7,15 @@ use Exception; use InvalidArgumentException; use phpmock\phpunit\PHPMock; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Client\Client; use Redmine\Client\NativeCurlClient; use Redmine\Http\HttpClient; use stdClass; +#[CoversClass(NativeCurlClient::class)] class NativeCurlClientTest extends TestCase { use PHPMock; @@ -32,11 +35,7 @@ class NativeCurlClientTest extends TestCase CURLOPT_RETURNTRANSFER => 1, ]; - /** - * @covers \Redmine\Client\NativeCurlClient - * @test - */ - public function shouldPassApiKeyToConstructor() + public function testApiKeyShouldBePassToConstructor() { $client = new NativeCurlClient( 'http://test.local', @@ -48,11 +47,7 @@ public function shouldPassApiKeyToConstructor() $this->assertInstanceOf(HttpClient::class, $client); } - /** - * @covers \Redmine\Client\NativeCurlClient - * @test - */ - public function shouldPassUsernameAndPasswordToConstructor() + public function testShouldPassUsernameAndPasswordToConstructor() { $client = new NativeCurlClient( 'http://test.local', @@ -64,10 +59,6 @@ public function shouldPassUsernameAndPasswordToConstructor() $this->assertInstanceOf(Client::class, $client); } - /** - * @covers \Redmine\Client\NativeCurlClient - * @test - */ public function testGetLastResponseStatusCodeIsInitialNull() { $client = new NativeCurlClient( @@ -78,10 +69,6 @@ public function testGetLastResponseStatusCodeIsInitialNull() $this->assertSame(0, $client->getLastResponseStatusCode()); } - /** - * @covers \Redmine\Client\NativeCurlClient - * @test - */ public function testGetLastResponseContentTypeIsInitialEmpty() { $client = new NativeCurlClient( @@ -92,10 +79,6 @@ public function testGetLastResponseContentTypeIsInitialEmpty() $this->assertSame('', $client->getLastResponseContentType()); } - /** - * @covers \Redmine\Client\NativeCurlClient - * @test - */ public function testGetLastResponseBodyIsInitialEmpty() { $client = new NativeCurlClient( @@ -106,10 +89,6 @@ public function testGetLastResponseBodyIsInitialEmpty() $this->assertSame('', $client->getLastResponseBody()); } - /** - * @covers \Redmine\Client\NativeCurlClient - * @test - */ public function testStartAndStopImpersonateUser() { $expectedOptions = [ @@ -135,10 +114,10 @@ public function testStartAndStopImpersonateUser() $curlExec->expects($this->exactly(3))->willReturn(''); $curlGetinfo = $this->getFunctionMock(self::__NAMESPACE__, 'curl_getinfo'); - $curlGetinfo->expects($this->exactly(6))->will($this->returnValueMap(([ + $curlGetinfo->expects($this->exactly(6))->willReturnMap(([ [$curl, CURLINFO_HTTP_CODE, 200], [$curl, CURLINFO_CONTENT_TYPE, 'application/json'], - ]))); + ])); $curlSetoptArray = $this->getFunctionMock(self::__NAMESPACE__, 'curl_setopt_array'); $curlSetoptArray->expects($this->exactly(3)) @@ -166,10 +145,6 @@ public function testStartAndStopImpersonateUser() $client->requestGet('/path'); } - /** - * @covers \Redmine\Client\NativeCurlClient - * @test - */ public function testSetSslVersion() { $expectedOptions = [ @@ -194,10 +169,10 @@ public function testSetSslVersion() $curlExec->expects($this->exactly(3))->willReturn(''); $curlGetinfo = $this->getFunctionMock(self::__NAMESPACE__, 'curl_getinfo'); - $curlGetinfo->expects($this->exactly(6))->will($this->returnValueMap(([ + $curlGetinfo->expects($this->exactly(6))->willReturnMap(([ [$curl, CURLINFO_HTTP_CODE, 200], [$curl, CURLINFO_CONTENT_TYPE, 'application/json'], - ]))); + ])); $curlSetoptArray = $this->getFunctionMock(self::__NAMESPACE__, 'curl_setopt_array'); $curlSetoptArray->expects($this->exactly(3)) @@ -225,10 +200,6 @@ public function testSetSslVersion() $client->requestGet('/path'); } - /** - * @covers \Redmine\Client\NativeCurlClient - * @test - */ public function testSetSslVerifypeer() { $expectedOptions = [ @@ -254,10 +225,10 @@ public function testSetSslVerifypeer() $curlExec->expects($this->exactly(3))->willReturn(''); $curlGetinfo = $this->getFunctionMock(self::__NAMESPACE__, 'curl_getinfo'); - $curlGetinfo->expects($this->exactly(6))->will($this->returnValueMap(([ + $curlGetinfo->expects($this->exactly(6))->willReturnMap(([ [$curl, CURLINFO_HTTP_CODE, 200], [$curl, CURLINFO_CONTENT_TYPE, 'application/json'], - ]))); + ])); $curlSetoptArray = $this->getFunctionMock(self::__NAMESPACE__, 'curl_setopt_array'); $curlSetoptArray->expects($this->exactly(3)) @@ -285,10 +256,6 @@ public function testSetSslVerifypeer() $client->requestGet('/path'); } - /** - * @covers \Redmine\Client\NativeCurlClient - * @test - */ public function testSetSslVerifyhost() { $expectedOptions = [ @@ -314,10 +281,10 @@ public function testSetSslVerifyhost() $curlExec->expects($this->exactly(3))->willReturn(''); $curlGetinfo = $this->getFunctionMock(self::__NAMESPACE__, 'curl_getinfo'); - $curlGetinfo->expects($this->exactly(6))->will($this->returnValueMap(([ + $curlGetinfo->expects($this->exactly(6))->willReturnMap(([ [$curl, CURLINFO_HTTP_CODE, 200], [$curl, CURLINFO_CONTENT_TYPE, 'application/json'], - ]))); + ])); $curlSetoptArray = $this->getFunctionMock(self::__NAMESPACE__, 'curl_setopt_array'); $curlSetoptArray->expects($this->exactly(3)) @@ -345,10 +312,6 @@ public function testSetSslVerifyhost() $client->requestGet('/path'); } - /** - * @covers \Redmine\Client\NativeCurlClient - * @test - */ public function testSetCustomHttpHeaders() { $expectedOptions = [ @@ -375,10 +338,10 @@ public function testSetCustomHttpHeaders() $curlExec->expects($this->exactly(3))->willReturn(''); $curlGetinfo = $this->getFunctionMock(self::__NAMESPACE__, 'curl_getinfo'); - $curlGetinfo->expects($this->exactly(6))->will($this->returnValueMap(([ + $curlGetinfo->expects($this->exactly(6))->willReturnMap(([ [$curl, CURLINFO_HTTP_CODE, 200], [$curl, CURLINFO_CONTENT_TYPE, 'application/json'], - ]))); + ])); $curlSetoptArray = $this->getFunctionMock(self::__NAMESPACE__, 'curl_setopt_array'); $curlSetoptArray->expects($this->exactly(3)) @@ -411,10 +374,6 @@ public function testSetCustomHttpHeaders() $client->requestGet('/path'); } - /** - * @covers \Redmine\Client\NativeCurlClient - * @test - */ public function testSetCustomHost() { $expectedOptions = [ @@ -440,10 +399,10 @@ public function testSetCustomHost() $curlExec->expects($this->exactly(3))->willReturn(''); $curlGetinfo = $this->getFunctionMock(self::__NAMESPACE__, 'curl_getinfo'); - $curlGetinfo->expects($this->exactly(6))->will($this->returnValueMap(([ + $curlGetinfo->expects($this->exactly(6))->willReturnMap(([ [$curl, CURLINFO_HTTP_CODE, 200], [$curl, CURLINFO_CONTENT_TYPE, 'application/json'], - ]))); + ])); $curlSetoptArray = $this->getFunctionMock(self::__NAMESPACE__, 'curl_setopt_array'); $curlSetoptArray->expects($this->exactly(3)) @@ -473,10 +432,6 @@ public function testSetCustomHost() $client->requestGet('/path'); } - /** - * @covers \Redmine\Client\NativeCurlClient - * @test - */ public function testSetPort() { $expectedOptions = [ @@ -501,10 +456,10 @@ public function testSetPort() $curlExec->expects($this->exactly(3))->willReturn(''); $curlGetinfo = $this->getFunctionMock(self::__NAMESPACE__, 'curl_getinfo'); - $curlGetinfo->expects($this->exactly(6))->will($this->returnValueMap(([ + $curlGetinfo->expects($this->exactly(6))->willReturnMap(([ [$curl, CURLINFO_HTTP_CODE, 200], [$curl, CURLINFO_CONTENT_TYPE, 'application/json'], - ]))); + ])); $curlSetoptArray = $this->getFunctionMock(self::__NAMESPACE__, 'curl_setopt_array'); $curlSetoptArray->expects($this->exactly(3)) @@ -532,10 +487,6 @@ public function testSetPort() $client->requestGet('/path'); } - /** - * @covers \Redmine\Client\NativeCurlClient - * @test - */ public function testCustomPortWillSetFromSchema() { $expectedOptions = [ @@ -560,10 +511,10 @@ public function testCustomPortWillSetFromSchema() $curlExec->expects($this->exactly(1))->willReturn(''); $curlGetinfo = $this->getFunctionMock(self::__NAMESPACE__, 'curl_getinfo'); - $curlGetinfo->expects($this->exactly(2))->will($this->returnValueMap(([ + $curlGetinfo->expects($this->exactly(2))->willReturnMap(([ [$curl, CURLINFO_HTTP_CODE, 200], [$curl, CURLINFO_CONTENT_TYPE, 'application/json'], - ]))); + ])); $curlSetoptArray = $this->getFunctionMock(self::__NAMESPACE__, 'curl_setopt_array'); $curlSetoptArray->expects($this->exactly(1)) @@ -586,10 +537,6 @@ public function testCustomPortWillSetFromSchema() $client->requestGet('/path'); } - /** - * @covers \Redmine\Client\NativeCurlClient - * @test - */ public function testCustomPortWillSetFromUrl() { $expectedOptions = [ @@ -614,10 +561,10 @@ public function testCustomPortWillSetFromUrl() $curlExec->expects($this->exactly(1))->willReturn(''); $curlGetinfo = $this->getFunctionMock(self::__NAMESPACE__, 'curl_getinfo'); - $curlGetinfo->expects($this->exactly(2))->will($this->returnValueMap(([ + $curlGetinfo->expects($this->exactly(2))->willReturnMap(([ [$curl, CURLINFO_HTTP_CODE, 200], [$curl, CURLINFO_CONTENT_TYPE, 'application/json'], - ]))); + ])); $curlSetoptArray = $this->getFunctionMock(self::__NAMESPACE__, 'curl_setopt_array'); $curlSetoptArray->expects($this->exactly(1)) @@ -641,10 +588,9 @@ public function testCustomPortWillSetFromUrl() } /** - * @covers \Redmine\Client\NativeCurlClient - * @test * @dataProvider getRequestReponseData */ + #[DataProvider('getRequestReponseData')] public function testRequestsReturnsCorrectContent($method, $data, $boolReturn, $statusCode, $contentType, $content) { $curl = $this->createMock(stdClass::class); @@ -658,10 +604,10 @@ public function testRequestsReturnsCorrectContent($method, $data, $boolReturn, $ $curlSetoptArray = $this->getFunctionMock(self::__NAMESPACE__, 'curl_setopt_array'); $curlGetinfo = $this->getFunctionMock(self::__NAMESPACE__, 'curl_getinfo'); - $curlGetinfo->expects($this->exactly(2))->will($this->returnValueMap(([ + $curlGetinfo->expects($this->exactly(2))->willReturnMap(([ [$curl, CURLINFO_HTTP_CODE, $statusCode], [$curl, CURLINFO_CONTENT_TYPE, $contentType], - ]))); + ])); $curlErrno = $this->getFunctionMock(self::__NAMESPACE__, 'curl_errno'); $curlErrno->expects($this->exactly(1))->willReturn(CURLE_OK); @@ -705,10 +651,6 @@ public static function getRequestReponseData(): array ]; } - /** - * @covers \Redmine\Client\NativeCurlClient - * @test - */ public function testHandlingOfResponseWithoutContent() { $content = ''; @@ -726,10 +668,10 @@ public function testHandlingOfResponseWithoutContent() $curlSetoptArray = $this->getFunctionMock(self::__NAMESPACE__, 'curl_setopt_array'); $curlGetinfo = $this->getFunctionMock(self::__NAMESPACE__, 'curl_getinfo'); - $curlGetinfo->expects($this->exactly(2))->will($this->returnValueMap(([ + $curlGetinfo->expects($this->exactly(2))->willReturnMap(([ [$curl, CURLINFO_HTTP_CODE, $statusCode], [$curl, CURLINFO_CONTENT_TYPE, $contentType], - ]))); + ])); $curlErrno = $this->getFunctionMock(self::__NAMESPACE__, 'curl_errno'); $curlErrno->expects($this->exactly(1))->willReturn(CURLE_OK); @@ -747,10 +689,6 @@ public function testHandlingOfResponseWithoutContent() $this->assertSame($content, $client->getLastResponseBody()); } - /** - * @covers \Redmine\Client\NativeCurlClient - * @test - */ public function testCurlErrorThrowsException() { $curl = $this->createMock(stdClass::class); @@ -783,14 +721,10 @@ public function testCurlErrorThrowsException() } /** - * @covers \Redmine\Client\NativeCurlClient - * @test - * - * @param string $apiName - * @param string $class * @dataProvider getApiClassesProvider */ - public function getApiShouldReturnApiInstance($apiName, $class) + #[DataProvider('getApiClassesProvider')] + public function testGetApiShouldReturnApiInstance(string $apiName, string $class) { $client = new NativeCurlClient( 'http://test.local', @@ -825,11 +759,7 @@ public static function getApiClassesProvider(): array ]; } - /** - * @covers \Redmine\Client\NativeCurlClient - * @test - */ - public function getApiShouldThrowException() + public function testGetApiShouldThrowException() { $client = new NativeCurlClient( 'http://test.local', diff --git a/tests/Unit/Client/Psr18Client/RequestTest.php b/tests/Unit/Client/Psr18Client/RequestTest.php index 3230c888..44d684ed 100644 --- a/tests/Unit/Client/Psr18Client/RequestTest.php +++ b/tests/Unit/Client/Psr18Client/RequestTest.php @@ -3,6 +3,8 @@ namespace Redmine\Tests\Unit\Client\Psr18ClientTest; use Exception; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Client\ClientInterface; @@ -16,16 +18,13 @@ use Redmine\Http\Request; use Redmine\Http\Response; -/** - * @covers \Redmine\Client\Psr18Client::request - * @covers \Redmine\Client\Psr18Client::runRequest - * @covers \Redmine\Client\Psr18Client::createRequest - */ +#[CoversClass(Psr18Client::class)] class RequestTest extends TestCase { /** * @dataProvider getRequestReponseData */ + #[DataProvider('getRequestReponseData')] public function testRequestReturnsCorrectResponse($method, $data, $statusCode, $contentType, $content) { $httpClient = $this->createConfiguredMock(ClientInterface::class, [ diff --git a/tests/Unit/Client/Psr18ClientTest.php b/tests/Unit/Client/Psr18ClientTest.php index 5859e540..0bd722f8 100644 --- a/tests/Unit/Client/Psr18ClientTest.php +++ b/tests/Unit/Client/Psr18ClientTest.php @@ -4,6 +4,8 @@ use Exception; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestFactoryInterface; @@ -18,13 +20,10 @@ use Redmine\Http\HttpClient; use stdClass; +#[CoversClass(Psr18Client::class)] class Psr18ClientTest extends TestCase { - /** - * @covers \Redmine\Client\Psr18Client - * @test - */ - public function shouldPassApiKeyToConstructor() + public function testShouldPassApiKeyToConstructor() { $client = new Psr18Client( $this->createMock(ClientInterface::class), @@ -39,9 +38,6 @@ public function shouldPassApiKeyToConstructor() $this->assertInstanceOf(HttpClient::class, $client); } - /** - * @covers \Redmine\Client\Psr18Client - */ public function testServerRequestFactoryIsAcceptedInConstructorForBC() { $client = new Psr18Client( @@ -66,11 +62,7 @@ public function testServerRequestFactoryIsAcceptedInConstructorForBC() $client->requestGet('/path.xml'); } - /** - * @covers \Redmine\Client\Psr18Client - * @test - */ - public function shouldPassUsernameAndPasswordToConstructor() + public function testShouldPassUsernameAndPasswordToConstructor() { $client = new Psr18Client( $this->createMock(ClientInterface::class), @@ -85,10 +77,6 @@ public function shouldPassUsernameAndPasswordToConstructor() $this->assertInstanceOf(Client::class, $client); } - /** - * @covers \Redmine\Client\Psr18Client - * @test - */ public function testGetLastResponseStatusCodeIsInitialZero() { $client = new Psr18Client( @@ -102,10 +90,6 @@ public function testGetLastResponseStatusCodeIsInitialZero() $this->assertSame(0, $client->getLastResponseStatusCode()); } - /** - * @covers \Redmine\Client\Psr18Client - * @test - */ public function testGetLastResponseContentTypeIsInitialEmpty() { $client = new Psr18Client( @@ -119,10 +103,6 @@ public function testGetLastResponseContentTypeIsInitialEmpty() $this->assertSame('', $client->getLastResponseContentType()); } - /** - * @covers \Redmine\Client\Psr18Client - * @test - */ public function testGetLastResponseBodyIsInitialEmpty() { $client = new Psr18Client( @@ -136,10 +116,6 @@ public function testGetLastResponseBodyIsInitialEmpty() $this->assertSame('', $client->getLastResponseBody()); } - /** - * @covers \Redmine\Client\Psr18Client - * @test - */ public function testStartAndStopImpersonateUser() { $request = $this->createMock(RequestInterface::class); @@ -170,10 +146,6 @@ public function testStartAndStopImpersonateUser() $client->requestGet('/path'); } - /** - * @covers \Redmine\Client\Psr18Client - * @test - */ public function testRequestGetReturnsFalse() { $response = $this->createMock(ResponseInterface::class); @@ -200,10 +172,9 @@ public function testRequestGetReturnsFalse() } /** - * @covers \Redmine\Client\Psr18Client - * @test * @dataProvider getRequestReponseData */ + #[DataProvider('getRequestReponseData')] public function testRequestsReturnsCorrectContent($method, $data, $boolReturn, $statusCode, $contentType, $content) { $stream = $this->createMock(StreamInterface::class); @@ -265,14 +236,10 @@ public static function getRequestReponseData(): array } /** - * @covers \Redmine\Client\Psr18Client - * @test - * - * @param string $apiName - * @param string $class * @dataProvider getApiClassesProvider */ - public function getApiShouldReturnApiInstance($apiName, $class) + #[DataProvider('getApiClassesProvider')] + public function testGetApiShouldReturnApiInstance(string $apiName, string $class) { $client = new Psr18Client( $this->createMock(ClientInterface::class), @@ -310,9 +277,6 @@ public static function getApiClassesProvider(): array ]; } - /** - * @covers \Redmine\Client\Psr18Client::__construct - */ public function testCreateWithoutFactoryThrowsException() { $this->expectException(Exception::class); @@ -328,11 +292,7 @@ public function testCreateWithoutFactoryThrowsException() ); } - /** - * @covers \Redmine\Client\Psr18Client - * @test - */ - public function getApiShouldThrowException() + public function testGetApiShouldThrowException() { $client = new Psr18Client( $this->createMock(ClientInterface::class), diff --git a/tests/Unit/Exception/ClientExceptionTest.php b/tests/Unit/Exception/ClientExceptionTest.php index 200e0941..6857a73d 100644 --- a/tests/Unit/Exception/ClientExceptionTest.php +++ b/tests/Unit/Exception/ClientExceptionTest.php @@ -3,13 +3,12 @@ namespace Redmine\Tests\Unit\Exception; use Exception; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Exception as RedmineException; use Redmine\Exception\ClientException; -/** - * @coversDefaultClass \Redmine\Exception\ClientException - */ +#[CoversClass(ClientException::class)] class ClientExceptionTest extends TestCase { public function testClientException() diff --git a/tests/Unit/Exception/InvalidApiNameExceptionTest.php b/tests/Unit/Exception/InvalidApiNameExceptionTest.php index 9078d8a3..4df5bba3 100644 --- a/tests/Unit/Exception/InvalidApiNameExceptionTest.php +++ b/tests/Unit/Exception/InvalidApiNameExceptionTest.php @@ -3,13 +3,12 @@ namespace Redmine\Tests\Unit\Exception; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Exception as RedmineException; use Redmine\Exception\InvalidApiNameException; -/** - * @coversDefaultClass \Redmine\Exception\InvalidApiNameException - */ +#[CoversClass(InvalidApiNameException::class)] class InvalidApiNameExceptionTest extends TestCase { public function testInvalidApiNameException() diff --git a/tests/Unit/Exception/InvalidParameterExceptionTest.php b/tests/Unit/Exception/InvalidParameterExceptionTest.php index 0324d9f4..f0b9eb6d 100644 --- a/tests/Unit/Exception/InvalidParameterExceptionTest.php +++ b/tests/Unit/Exception/InvalidParameterExceptionTest.php @@ -10,9 +10,6 @@ class InvalidParameterExceptionTest extends TestCase { - /** - * @test - */ public function testInvalidParameterException() { $exception = new InvalidParameterException(); diff --git a/tests/Unit/Exception/MissingParameterExceptionTest.php b/tests/Unit/Exception/MissingParameterExceptionTest.php index 31b00c0e..7fdae1dd 100644 --- a/tests/Unit/Exception/MissingParameterExceptionTest.php +++ b/tests/Unit/Exception/MissingParameterExceptionTest.php @@ -10,9 +10,6 @@ class MissingParameterExceptionTest extends TestCase { - /** - * @test - */ public function testMissingParameterException() { $exception = new MissingParameterException(); diff --git a/tests/Unit/Http/HttpFactory/MakeJsonRequestTest.php b/tests/Unit/Http/HttpFactory/MakeJsonRequestTest.php index 9e97bbbb..155866fc 100644 --- a/tests/Unit/Http/HttpFactory/MakeJsonRequestTest.php +++ b/tests/Unit/Http/HttpFactory/MakeJsonRequestTest.php @@ -4,13 +4,12 @@ namespace Redmine\Tests\Unit\Http\HttpFactory; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Http\HttpFactory; use Redmine\Http\Request; -/** - * @covers \Redmine\Http\HttpFactory::makeJsonRequest - */ +#[CoversClass(HttpFactory::class)] class MakeJsonRequestTest extends TestCase { public function testMakeJsonRequest() diff --git a/tests/Unit/Http/HttpFactory/MakeRequestTest.php b/tests/Unit/Http/HttpFactory/MakeRequestTest.php index 80c728ee..e3e9cdfd 100644 --- a/tests/Unit/Http/HttpFactory/MakeRequestTest.php +++ b/tests/Unit/Http/HttpFactory/MakeRequestTest.php @@ -4,13 +4,12 @@ namespace Redmine\Tests\Unit\Http\HttpFactory; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Http\HttpFactory; use Redmine\Http\Request; -/** - * @covers \Redmine\Http\HttpFactory::makeRequest - */ +#[CoversClass(HttpFactory::class)] class MakeRequestTest extends TestCase { public function testMakeRequest() diff --git a/tests/Unit/Http/HttpFactory/MakeResponseTest.php b/tests/Unit/Http/HttpFactory/MakeResponseTest.php index 407b90ec..d54ddf04 100644 --- a/tests/Unit/Http/HttpFactory/MakeResponseTest.php +++ b/tests/Unit/Http/HttpFactory/MakeResponseTest.php @@ -4,13 +4,12 @@ namespace Redmine\Tests\Unit\Http\HttpFactory; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Http\HttpFactory; use Redmine\Http\Response; -/** - * @covers \Redmine\Http\HttpFactory::makeResponse - */ +#[CoversClass(HttpFactory::class)] class MakeResponseTest extends TestCase { public function testMakeResponse() diff --git a/tests/Unit/Http/HttpFactory/MakeXmlRequestTest.php b/tests/Unit/Http/HttpFactory/MakeXmlRequestTest.php index 5a0bf923..b11adf4d 100644 --- a/tests/Unit/Http/HttpFactory/MakeXmlRequestTest.php +++ b/tests/Unit/Http/HttpFactory/MakeXmlRequestTest.php @@ -4,13 +4,12 @@ namespace Redmine\Tests\Unit\Http\HttpFactory; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Redmine\Http\HttpFactory; use Redmine\Http\Request; -/** - * @covers \Redmine\Http\HttpFactory::makeXmlRequest - */ +#[CoversClass(HttpFactory::class)] class MakeXmlRequestTest extends TestCase { public function testMakeXmlRequest() diff --git a/tests/Unit/Serializer/JsonSerializerTest.php b/tests/Unit/Serializer/JsonSerializerTest.php index afed796d..1b9d5a93 100644 --- a/tests/Unit/Serializer/JsonSerializerTest.php +++ b/tests/Unit/Serializer/JsonSerializerTest.php @@ -4,13 +4,13 @@ namespace Redmine\Tests\Unit\Serializer; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Exception\SerializerException; use Redmine\Serializer\JsonSerializer; -/** - * @coversDefaultClass \Redmine\Serializer\JsonSerializer - */ +#[CoversClass(JsonSerializer::class)] class JsonSerializerTest extends TestCase { public static function getEncodedToNormalizedData(): array @@ -60,11 +60,10 @@ public static function getEncodedToNormalizedData(): array } /** - * @test - * * @dataProvider getEncodedToNormalizedData */ - public function createFromStringDecodesToExpectedNormalizedData(string $data, $expected) + #[DataProvider('getEncodedToNormalizedData')] + public function testCreateFromStringDecodesToExpectedNormalizedData(string $data, $expected) { $serializer = JsonSerializer::createFromString($data); @@ -86,11 +85,10 @@ public static function getInvalidEncodedData(): array } /** - * @test - * * @dataProvider getInvalidEncodedData */ - public function createFromStringWithInvalidStringThrowsException(string $message, string $data) + #[DataProvider('getInvalidEncodedData')] + public function testCreateFromStringWithInvalidStringThrowsException(string $message, string $data) { $this->expectException(SerializerException::class); $this->expectExceptionMessage($message); @@ -183,11 +181,10 @@ public static function getNormalizedToEncodedData(): array } /** - * @test - * * @dataProvider getNormalizedToEncodedData */ - public function createFromArrayEncodesToExpectedString(array $data, $expected) + #[DataProvider('getNormalizedToEncodedData')] + public function testCreateFromArrayEncodesToExpectedString(array $data, $expected) { $serializer = JsonSerializer::createFromArray($data); @@ -205,11 +202,10 @@ public static function getInvalidSerializedData(): array } /** - * @test - * * @dataProvider getInvalidSerializedData */ - public function createFromArrayWithInvalidDataThrowsException(string $message, array $data) + #[DataProvider('getInvalidSerializedData')] + public function testCreateFromArrayWithInvalidDataThrowsException(string $message, array $data) { $this->expectException(SerializerException::class); $this->expectExceptionMessage($message); diff --git a/tests/Unit/Serializer/PathSerializerTest.php b/tests/Unit/Serializer/PathSerializerTest.php index 35a8499a..ec6292fd 100644 --- a/tests/Unit/Serializer/PathSerializerTest.php +++ b/tests/Unit/Serializer/PathSerializerTest.php @@ -4,12 +4,12 @@ namespace Redmine\Tests\Unit\Serializer; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Serializer\PathSerializer; -/** - * @coversDefaultClass \Redmine\Serializer\PathSerializer - */ +#[CoversClass(PathSerializer::class)] class PathSerializerTest extends TestCase { public static function getPathData(): array @@ -51,11 +51,10 @@ public static function getPathData(): array } /** - * @test - * * @dataProvider getPathData */ - public function getPathShouldReturnExpectedString(string $path, array $params, string $expected) + #[DataProvider('getPathData')] + public function testGetPathShouldReturnExpectedString(string $path, array $params, string $expected) { $serializer = PathSerializer::create($path, $params); diff --git a/tests/Unit/Serializer/XmlSerializerTest.php b/tests/Unit/Serializer/XmlSerializerTest.php index 170e456c..09f9bdd9 100644 --- a/tests/Unit/Serializer/XmlSerializerTest.php +++ b/tests/Unit/Serializer/XmlSerializerTest.php @@ -4,15 +4,26 @@ namespace Redmine\Tests\Unit\Serializer; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Redmine\Exception\SerializerException; use Redmine\Serializer\XmlSerializer; -/** - * @coversDefaultClass \Redmine\Serializer\XmlSerializer - */ +#[CoversClass(XmlSerializer::class)] class XmlSerializerTest extends TestCase { + /** + * @dataProvider getEncodedToNormalizedData + */ + #[DataProvider('getEncodedToNormalizedData')] + public function testCreateFromStringDecodesToExpectedNormalizedData(string $data, $expected) + { + $serializer = XmlSerializer::createFromString($data); + + $this->assertSame($expected, $serializer->getNormalized()); + } + public static function getEncodedToNormalizedData(): array { return [ @@ -63,15 +74,15 @@ public static function getEncodedToNormalizedData(): array } /** - * @test - * - * @dataProvider getEncodedToNormalizedData + * @dataProvider getInvalidEncodedData */ - public function createFromStringDecodesToExpectedNormalizedData(string $data, $expected) + #[DataProvider('getInvalidEncodedData')] + public function testCreateFromStringWithInvalidStringThrowsException(string $message, string $data) { - $serializer = XmlSerializer::createFromString($data); + $this->expectException(SerializerException::class); + $this->expectExceptionMessage($message); - $this->assertSame($expected, $serializer->getNormalized()); + XmlSerializer::createFromString($data); } public static function getInvalidEncodedData(): array @@ -101,16 +112,14 @@ public static function getInvalidEncodedData(): array } /** - * @test - * - * @dataProvider getInvalidEncodedData + * @dataProvider getNormalizedToEncodedData */ - public function createFromStringWithInvalidStringThrowsException(string $message, string $data) + #[DataProvider('getNormalizedToEncodedData')] + public function testCreateFromArrayEncodesToExpectedString(array $data, $expected) { - $this->expectException(SerializerException::class); - $this->expectExceptionMessage($message); + $serializer = XmlSerializer::createFromArray($data); - XmlSerializer::createFromString($data); + $this->assertXmlStringEqualsXmlString($expected, $serializer->__toString()); } public static function getNormalizedToEncodedData(): array @@ -253,15 +262,15 @@ public static function getNormalizedToEncodedData(): array } /** - * @test - * - * @dataProvider getNormalizedToEncodedData + * @dataProvider getInvalidSerializedData */ - public function createFromArrayEncodesToExpectedString(array $data, $expected) + #[DataProvider('getInvalidSerializedData')] + public function testCreateFromArrayWithInvalidDataThrowsException(string $message, array $data) { - $serializer = XmlSerializer::createFromArray($data); + $this->expectException(SerializerException::class); + $this->expectExceptionMessage($message); - $this->assertXmlStringEqualsXmlString($expected, $serializer->__toString()); + XmlSerializer::createFromArray($data); } public static function getInvalidSerializedData(): array @@ -273,17 +282,4 @@ public static function getInvalidSerializedData(): array ] ]; } - - /** - * @test - * - * @dataProvider getInvalidSerializedData - */ - public function createFromArrayWithInvalidDataThrowsException(string $message, array $data) - { - $this->expectException(SerializerException::class); - $this->expectExceptionMessage($message); - - XmlSerializer::createFromArray($data); - } }