From 11cfa5c745f84b0120579bdfe7df9a271842145b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Thu, 25 May 2023 16:16:18 +0200 Subject: [PATCH] Enhancement: Synchronize with ergebnis/php-package-template --- .github/CODEOWNERS | 2 +- .github/CONTRIBUTING.md | 2 +- .github/SECURITY.md | 17 +++++++ .github/settings.yml | 1 + .github/workflows/integrate.yaml | 48 +++++++++++++++---- .github/workflows/renew.yaml | 2 +- .gitignore | 2 +- .php-cs-fixer.php | 2 +- .yamllint.yaml | 2 +- Makefile | 15 +++--- composer-require-checker.json | 18 +------ psalm-baseline.xml | 27 ++++++++++- rector.php | 7 ++- test/EndToEnd/Default/SleeperTest.php | 10 +--- .../MaximumCount/Five/SleeperTest.php | 10 +--- .../MaximumDuration/Fifty/SleeperTest.php | 6 +-- test/EndToEnd/NoOutput/SleeperTest.php | 10 +--- test/Fixture/Sleeper.php | 2 +- .../Comparator/DurationComparatorTest.php | 6 +-- test/Unit/Console/ColorTest.php | 13 ++--- .../Exception/InvalidMaximumCountTest.php | 6 +-- .../Exception/InvalidMaximumDurationTest.php | 6 +-- .../DefaultDurationFormatterTest.php | 10 +--- test/Unit/MaximumCountTest.php | 20 +++----- test/Unit/MaximumDurationTest.php | 30 ++++-------- 25 files changed, 136 insertions(+), 138 deletions(-) create mode 100644 .github/SECURITY.md diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1d765050..21dd5340 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,3 @@ -# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-file-size +# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners * @ergebnis-bot @localheinz diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index ec04c5c5..31c7b47f 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -114,7 +114,7 @@ Run make ``` -to enforce coding standards, run a static code analysis, and run tests! +to automatically refactor code, enforce coding standards, run a static code analysis, and run tests! ## Help diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 00000000..68e59c2f --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,17 @@ +# Security Policy + +## Supported Versions + +The following versions of `ergebnis/phpunit-slow-test-detector` have active support: + +- `^2.1.1` + +## Unsupported Versions + +The following versions of `ergebnis/phpunit-slow-test-detector` have reached their end of life: + +- `<=2.1.0` + +## Reporting a Vulnerability + +If you believe that you have found a security vulnerability, please send an email to `am@localheinz.com`. Ensure to include all details required to understand the severity of the issue. diff --git a/.github/settings.yml b/.github/settings.yml index 84481961..a00c1899 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -75,6 +75,7 @@ repository: description: ":stopwatch: Provides an extension for detecting slow tests in phpunit/phpunit." enable_automated_security_fixes: true enable_vulnerability_alerts: true + has_discussions: false has_downloads: true has_issues: true has_pages: false diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index 8b2d14d3..273a5184 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -30,7 +30,7 @@ jobs: uses: "shivammathur/setup-php@2.25.2" with: coverage: "xdebug" - extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter" + extensions: "none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter" php-version: "${{ matrix.php-version }}" - name: "Set up problem matchers for PHP" @@ -39,6 +39,9 @@ jobs: - name: "Set up problem matchers for phpunit/phpunit" run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\"" + - name: "Validate composer.json and composer.lock" + run: "composer validate --ansi --strict" + - name: "Determine composer cache directory" uses: "ergebnis/.github/actions/composer/determine-cache-directory@1.8.0" @@ -93,7 +96,7 @@ jobs: uses: "shivammathur/setup-php@2.25.2" with: coverage: "none" - extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter" + extensions: "none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter" php-version: "${{ matrix.php-version }}" - name: "Set up problem matchers for PHP" @@ -121,7 +124,7 @@ jobs: run: "composer normalize --ansi --dry-run" - name: "Create cache directory for friendsofphp/php-cs-fixer" - run: "mkdir -p .build/php-cs-fixer" + run: "mkdir -p .build/php-cs-fixer/" - name: "Cache cache directory for friendsofphp/php-cs-fixer" uses: "actions/cache@v3.3.1" @@ -156,13 +159,16 @@ jobs: uses: "shivammathur/setup-php@2.25.2" with: coverage: "none" - extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter" + extensions: "none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter" php-version: "${{ matrix.php-version }}" tools: "phive" - name: "Set up problem matchers for PHP" run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\"" + - name: "Validate composer.json and composer.lock" + run: "composer validate --ansi --strict" + - name: "Determine composer cache directory" uses: "ergebnis/.github/actions/composer/determine-cache-directory@1.8.0" @@ -207,12 +213,15 @@ jobs: uses: "shivammathur/setup-php@2.25.2" with: coverage: "none" - extensions: "none, ctype, dom, intl, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter" + extensions: "none, ctype, curl, dom, intl, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter" php-version: "${{ matrix.php-version }}" - name: "Set up problem matchers for PHP" run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\"" + - name: "Validate composer.json and composer.lock" + run: "composer validate --ansi --strict" + - name: "Determine composer cache directory" uses: "ergebnis/.github/actions/composer/determine-cache-directory@1.8.0" @@ -229,7 +238,7 @@ jobs: dependencies: "${{ matrix.dependencies }}" - name: "Create cache directory for rector/rector" - run: "mkdir -p .build/rector" + run: "mkdir -p .build/rector/" - name: "Cache cache directory for rector/rector" uses: "actions/cache@v3.3.1" @@ -273,6 +282,21 @@ jobs: - name: "Validate composer.json and composer.lock" run: "composer validate --ansi --strict" + - name: "Determine composer cache directory" + uses: "ergebnis/.github/actions/composer/determine-cache-directory@1.8.0" + + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v3.3.1" + with: + path: "${{ env.COMPOSER_CACHE_DIR }}" + key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}" + restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-" + + - name: "Install ${{ matrix.dependencies }} dependencies with composer" + uses: "ergebnis/.github/actions/composer/install@1.8.0" + with: + dependencies: "${{ matrix.dependencies }}" + - name: "Check installed packages for security vulnerability advisories" run: "composer audit --ansi" @@ -297,12 +321,15 @@ jobs: uses: "shivammathur/setup-php@2.25.2" with: coverage: "none" - extensions: "none, ctype, curl, dom, json, mbstring, pcntl, phar, posix, simplexml, tokenizer, xml, xmlwriter" + extensions: "none, ctype, curl, dom, json, mbstring, opcache, pcntl, phar, posix, simplexml, tokenizer, xml, xmlwriter" php-version: "${{ matrix.php-version }}" - name: "Set up problem matchers for PHP" run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\"" + - name: "Validate composer.json and composer.lock" + run: "composer validate --ansi --strict" + - name: "Determine composer cache directory" uses: "ergebnis/.github/actions/composer/determine-cache-directory@1.8.0" @@ -319,7 +346,7 @@ jobs: dependencies: "${{ matrix.dependencies }}" - name: "Create cache directory for vimeo/psalm" - run: "mkdir -p .build/psalm" + run: "mkdir -p .build/psalm/" - name: "Run vimeo/psalm" run: "vendor/bin/psalm --config=psalm.xml --output-format=github --shepherd --show-info=false --stats --threads=4" @@ -348,7 +375,7 @@ jobs: uses: "shivammathur/setup-php@2.25.2" with: coverage: "none" - extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter" + extensions: "none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter" php-version: "${{ matrix.php-version }}" - name: "Set up problem matchers for PHP" @@ -357,6 +384,9 @@ jobs: - name: "Set up problem matchers for phpunit/phpunit" run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\"" + - name: "Validate composer.json and composer.lock" + run: "composer validate --ansi --strict" + - name: "Determine composer cache directory" uses: "ergebnis/.github/actions/composer/determine-cache-directory@1.8.0" diff --git a/.github/workflows/renew.yaml b/.github/workflows/renew.yaml index 7d1abbc6..ffd6891e 100644 --- a/.github/workflows/renew.yaml +++ b/.github/workflows/renew.yaml @@ -30,7 +30,7 @@ jobs: uses: "shivammathur/setup-php@2.25.2" with: coverage: "none" - extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter" + extensions: "none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter" php-version: "${{ matrix.php-version }}" - name: "Set up problem matchers for PHP" diff --git a/.gitignore b/.gitignore index c6b4dc9c..f1cf866a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ /.build/ -/.notes/ +/.note/ /.phive/ /vendor/ !/.phive/phars.xml diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 7739c74f..255fbfd4 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -34,7 +34,7 @@ ->exclude([ '.build/', '.github/', - '.notes/', + '.note/', ]) ->ignoreDotFiles(false) ->in(__DIR__) diff --git a/.yamllint.yaml b/.yamllint.yaml index b2129ac2..af99fe0f 100644 --- a/.yamllint.yaml +++ b/.yamllint.yaml @@ -2,7 +2,7 @@ extends: "default" ignore: | .build/ - .notes/ + .note/ vendor/ rules: diff --git a/Makefile b/Makefile index 93d3b31d..9cbb099e 100644 --- a/Makefile +++ b/Makefile @@ -3,14 +3,14 @@ it: refactoring coding-standards security-analysis static-code-analysis tests ## .PHONY: code-coverage code-coverage: vendor ## Collects coverage from running unit tests with phpunit/phpunit - mkdir -p .build/phpunit - vendor/bin/phpunit --configuration=test/phpunit.xml --coverage-text + mkdir -p .build/phpunit/ + vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --coverage-text .PHONY: coding-standards coding-standards: vendor ## Lints YAML files with yamllint, normalizes composer.json with ergebnis/composer-normalize, and fixes code style issues with friendsofphp/php-cs-fixer yamllint -c .yamllint.yaml --strict . composer normalize - mkdir -p .build/php-cs-fixer + mkdir -p .build/php-cs-fixer/ vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --verbose .PHONY: dependency-analysis @@ -22,12 +22,13 @@ help: ## Displays this list of targets with descriptions @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' .PHONY: phive -phive: .phive## Installs dependencies with phive - mkdir -p .build/phive +phive: .phive ## Installs dependencies with phive + mkdir -p .build/phive/ PHIVE_HOME=.build/phive phive install --trust-gpg-keys 0x033E5F8D801A2F8D .PHONY: refactoring refactoring: vendor ## Runs automated refactoring with rector/rector + mkdir -p .build/rector/ vendor/bin/rector process --config=rector.php .PHONY: security-analysis @@ -36,13 +37,13 @@ security-analysis: vendor ## Runs a security analysis with composer .PHONY: static-code-analysis static-code-analysis: vendor ## Runs a static code analysis with vimeo/psalm - mkdir -p .build/psalm + mkdir -p .build/psalm/ vendor/bin/psalm --config=psalm.xml --clear-cache vendor/bin/psalm --config=psalm.xml --show-info=false --stats --threads=4 .PHONY: static-code-analysis-baseline static-code-analysis-baseline: vendor ## Generates a baseline for static code analysis with vimeo/psalm - mkdir -p .build/psalm + mkdir -p .build/psalm/ vendor/bin/psalm --config=psalm.xml --clear-cache vendor/bin/psalm --config=psalm.xml --set-baseline=psalm-baseline.xml diff --git a/composer-require-checker.json b/composer-require-checker.json index 67d0aa16..b8b091ad 100644 --- a/composer-require-checker.json +++ b/composer-require-checker.json @@ -1,19 +1,3 @@ { - "symbol-whitelist": [ - "array", - "bool", - "callable", - "false", - "float", - "int", - "iterable", - "null", - "object", - "parent", - "self", - "static", - "string", - "true", - "void" - ] + "symbol-whitelist": [] } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 550b56cb..9375c609 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + Extension @@ -46,9 +46,34 @@ NullReporter + + + provideMillisecondsGreaterThanDefaultMaximumDuration + + + + + provideMillisecondsGreaterThanDefaultMaximumDuration + + + + + provideMillisecondsGreaterThanDefaultMaximumDuration + + milliseconds * 1000]]> + + + provideDurationAndFormattedDuration + + + + + provideMillisecondsAndTelemetryDuration + + diff --git a/rector.php b/rector.php index 759b5ec0..90708320 100644 --- a/rector.php +++ b/rector.php @@ -13,6 +13,7 @@ use Rector\Config; use Rector\Core; +use Rector\Php81; use Rector\PHPUnit; return static function (Config\RectorConfig $rectorConfig): void { @@ -27,7 +28,11 @@ $rectorConfig->phpVersion(Core\ValueObject\PhpVersion::PHP_81); + $rectorConfig->rules([ + Php81\Rector\Property\ReadOnlyPropertyRector::class, + ]); + $rectorConfig->sets([ - PHPUnit\Set\PHPUnitSetList::PHPUNIT_90, + PHPUnit\Set\PHPUnitSetList::PHPUNIT_100, ]); }; diff --git a/test/EndToEnd/Default/SleeperTest.php b/test/EndToEnd/Default/SleeperTest.php index cb022003..3437ab95 100644 --- a/test/EndToEnd/Default/SleeperTest.php +++ b/test/EndToEnd/Default/SleeperTest.php @@ -16,11 +16,7 @@ use Ergebnis\PHPUnit\SlowTestDetector\Test; use PHPUnit\Framework; -/** - * @internal - * - * @covers \Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Sleeper - */ +#[Framework\Attributes\CoversClass(Test\Fixture\Sleeper::class)] final class SleeperTest extends Framework\TestCase { use Test\Util\Helper; @@ -58,9 +54,7 @@ public function testSleeperSleepsJustAboveDefaultMaximumDuration(): void self::assertSame($milliseconds, $sleeper->milliseconds()); } - /** - * @dataProvider provideMillisecondsGreaterThanDefaultMaximumDuration - */ + #[Framework\Attributes\DataProvider('provideMillisecondsGreaterThanDefaultMaximumDuration')] public function testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider(int $milliseconds): void { $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); diff --git a/test/EndToEnd/MaximumCount/Five/SleeperTest.php b/test/EndToEnd/MaximumCount/Five/SleeperTest.php index d6a6bb14..f8bdc166 100644 --- a/test/EndToEnd/MaximumCount/Five/SleeperTest.php +++ b/test/EndToEnd/MaximumCount/Five/SleeperTest.php @@ -16,11 +16,7 @@ use Ergebnis\PHPUnit\SlowTestDetector\Test; use PHPUnit\Framework; -/** - * @internal - * - * @covers \Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Sleeper - */ +#[Framework\Attributes\CoversClass(Test\Fixture\Sleeper::class)] final class SleeperTest extends Framework\TestCase { use Test\Util\Helper; @@ -58,9 +54,7 @@ public function testSleeperSleepsJustAboveDefaultMaximumDuration(): void self::assertSame($milliseconds, $sleeper->milliseconds()); } - /** - * @dataProvider provideMillisecondsGreaterThanDefaultMaximumDuration - */ + #[Framework\Attributes\DataProvider('provideMillisecondsGreaterThanDefaultMaximumDuration')] public function testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider(int $milliseconds): void { $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); diff --git a/test/EndToEnd/MaximumDuration/Fifty/SleeperTest.php b/test/EndToEnd/MaximumDuration/Fifty/SleeperTest.php index ace46b34..f9ee5256 100644 --- a/test/EndToEnd/MaximumDuration/Fifty/SleeperTest.php +++ b/test/EndToEnd/MaximumDuration/Fifty/SleeperTest.php @@ -16,11 +16,7 @@ use Ergebnis\PHPUnit\SlowTestDetector\Test; use PHPUnit\Framework; -/** - * @internal - * - * @covers \Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Sleeper - */ +#[Framework\Attributes\CoversClass(Test\Fixture\Sleeper::class)] final class SleeperTest extends Framework\TestCase { use Test\Util\Helper; diff --git a/test/EndToEnd/NoOutput/SleeperTest.php b/test/EndToEnd/NoOutput/SleeperTest.php index b0fa3ad9..ef8fdbdd 100644 --- a/test/EndToEnd/NoOutput/SleeperTest.php +++ b/test/EndToEnd/NoOutput/SleeperTest.php @@ -16,11 +16,7 @@ use Ergebnis\PHPUnit\SlowTestDetector\Test; use PHPUnit\Framework; -/** - * @internal - * - * @covers \Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Sleeper - */ +#[Framework\Attributes\CoversClass(Test\Fixture\Sleeper::class)] final class SleeperTest extends Framework\TestCase { use Test\Util\Helper; @@ -58,9 +54,7 @@ public function testSleeperSleepsJustAboveDefaultMaximumDuration(): void self::assertSame($milliseconds, $sleeper->milliseconds()); } - /** - * @dataProvider provideMillisecondsGreaterThanDefaultMaximumDuration - */ + #[Framework\Attributes\DataProvider('provideMillisecondsGreaterThanDefaultMaximumDuration')] public function testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider(int $milliseconds): void { $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); diff --git a/test/Fixture/Sleeper.php b/test/Fixture/Sleeper.php index f7f92421..f845c6d7 100644 --- a/test/Fixture/Sleeper.php +++ b/test/Fixture/Sleeper.php @@ -15,7 +15,7 @@ final class Sleeper { - private function __construct(private int $milliseconds) + private function __construct(private readonly int $milliseconds) { } diff --git a/test/Unit/Comparator/DurationComparatorTest.php b/test/Unit/Comparator/DurationComparatorTest.php index c64965d8..1119356e 100644 --- a/test/Unit/Comparator/DurationComparatorTest.php +++ b/test/Unit/Comparator/DurationComparatorTest.php @@ -18,11 +18,7 @@ use PHPUnit\Event; use PHPUnit\Framework; -/** - * @internal - * - * @covers \Ergebnis\PHPUnit\SlowTestDetector\Comparator\DurationComparator - */ +#[Framework\Attributes\CoversClass(Comparator\DurationComparator::class)] final class DurationComparatorTest extends Framework\TestCase { use Test\Util\Helper; diff --git a/test/Unit/Console/ColorTest.php b/test/Unit/Console/ColorTest.php index 66c40f06..3260edb0 100644 --- a/test/Unit/Console/ColorTest.php +++ b/test/Unit/Console/ColorTest.php @@ -13,23 +13,18 @@ namespace Ergebnis\PHPUnit\SlowTestDetector\Test\Unit\Console; +use Ergebnis\DataProvider; use Ergebnis\PHPUnit\SlowTestDetector\Console; use Ergebnis\PHPUnit\SlowTestDetector\Test; use PHPUnit\Framework; -/** - * @internal - * - * @covers \Ergebnis\PHPUnit\SlowTestDetector\Console\Color - */ +#[Framework\Attributes\CoversClass(Console\Color::class)] final class ColorTest extends Framework\TestCase { use Test\Util\Helper; - /** - * @dataProvider \Ergebnis\DataProvider\StringProvider::blank - * @dataProvider \Ergebnis\DataProvider\StringProvider::empty - */ + #[Framework\Attributes\DataProviderExternal(DataProvider\StringProvider::class, 'blank')] + #[Framework\Attributes\DataProviderExternal(DataProvider\StringProvider::class, 'empty')] public function testDimReturnsOriginalStringWhenItIsWhitespaceOnly(string $output): void { self::assertSame($output, Console\Color::dim($output)); diff --git a/test/Unit/Exception/InvalidMaximumCountTest.php b/test/Unit/Exception/InvalidMaximumCountTest.php index 7cd1b679..c12cf330 100644 --- a/test/Unit/Exception/InvalidMaximumCountTest.php +++ b/test/Unit/Exception/InvalidMaximumCountTest.php @@ -17,11 +17,7 @@ use Ergebnis\PHPUnit\SlowTestDetector\Test; use PHPUnit\Framework; -/** - * @internal - * - * @covers \Ergebnis\PHPUnit\SlowTestDetector\Exception\InvalidMaximumCount - */ +#[Framework\Attributes\CoversClass(Exception\InvalidMaximumCount::class)] final class InvalidMaximumCountTest extends Framework\TestCase { use Test\Util\Helper; diff --git a/test/Unit/Exception/InvalidMaximumDurationTest.php b/test/Unit/Exception/InvalidMaximumDurationTest.php index 929e5369..855f89f8 100644 --- a/test/Unit/Exception/InvalidMaximumDurationTest.php +++ b/test/Unit/Exception/InvalidMaximumDurationTest.php @@ -17,11 +17,7 @@ use Ergebnis\PHPUnit\SlowTestDetector\Test; use PHPUnit\Framework; -/** - * @internal - * - * @covers \Ergebnis\PHPUnit\SlowTestDetector\Exception\InvalidMaximumDuration - */ +#[Framework\Attributes\CoversClass(Exception\InvalidMaximumDuration::class)] final class InvalidMaximumDurationTest extends Framework\TestCase { use Test\Util\Helper; diff --git a/test/Unit/Formatter/DefaultDurationFormatterTest.php b/test/Unit/Formatter/DefaultDurationFormatterTest.php index e48cd1e3..324c9047 100644 --- a/test/Unit/Formatter/DefaultDurationFormatterTest.php +++ b/test/Unit/Formatter/DefaultDurationFormatterTest.php @@ -18,18 +18,12 @@ use PHPUnit\Event; use PHPUnit\Framework; -/** - * @internal - * - * @covers \Ergebnis\PHPUnit\SlowTestDetector\Formatter\DefaultDurationFormatter - */ +#[Framework\Attributes\CoversClass(Formatter\DefaultDurationFormatter::class)] final class DefaultDurationFormatterTest extends Framework\TestCase { use Test\Util\Helper; - /** - * @dataProvider provideDurationAndFormattedDuration - */ + #[Framework\Attributes\DataProvider('provideDurationAndFormattedDuration')] public function testFormatFormats( Event\Telemetry\Duration $duration, string $formattedDuration, diff --git a/test/Unit/MaximumCountTest.php b/test/Unit/MaximumCountTest.php index afbc9dac..0e7ee130 100644 --- a/test/Unit/MaximumCountTest.php +++ b/test/Unit/MaximumCountTest.php @@ -13,23 +13,17 @@ namespace Ergebnis\PHPUnit\SlowTestDetector\Test\Unit; +use Ergebnis\DataProvider; use Ergebnis\PHPUnit\SlowTestDetector\Exception; use Ergebnis\PHPUnit\SlowTestDetector\MaximumCount; use PHPUnit\Framework; -/** - * @internal - * - * @covers \Ergebnis\PHPUnit\SlowTestDetector\MaximumCount - * - * @uses \Ergebnis\PHPUnit\SlowTestDetector\Exception\InvalidMaximumCount - */ +#[Framework\Attributes\CoversClass(MaximumCount::class)] +#[Framework\Attributes\UsesClass(Exception\InvalidMaximumCount::class)] final class MaximumCountTest extends Framework\TestCase { - /** - * @dataProvider \Ergebnis\DataProvider\IntProvider::lessThanZero - * @dataProvider \Ergebnis\DataProvider\IntProvider::zero - */ + #[Framework\Attributes\DataProviderExternal(DataProvider\IntProvider::class, 'lessThanZero')] + #[Framework\Attributes\DataProviderExternal(DataProvider\IntProvider::class, 'zero')] public function testFromIntRejectsInvalidValue(int $value): void { $this->expectException(Exception\InvalidMaximumCount::class); @@ -37,9 +31,7 @@ public function testFromIntRejectsInvalidValue(int $value): void MaximumCount::fromInt($value); } - /** - * @dataProvider \Ergebnis\DataProvider\IntProvider::greaterThanZero - */ + #[Framework\Attributes\DataProviderExternal(DataProvider\IntProvider::class, 'greaterThanZero')] public function testFromSecondsReturnsMaximumDuration(int $value): void { $maximumCount = MaximumCount::fromInt($value); diff --git a/test/Unit/MaximumDurationTest.php b/test/Unit/MaximumDurationTest.php index 44946c67..409fd6aa 100644 --- a/test/Unit/MaximumDurationTest.php +++ b/test/Unit/MaximumDurationTest.php @@ -13,27 +13,21 @@ namespace Ergebnis\PHPUnit\SlowTestDetector\Test\Unit; +use Ergebnis\DataProvider; use Ergebnis\PHPUnit\SlowTestDetector\Exception; use Ergebnis\PHPUnit\SlowTestDetector\MaximumDuration; use Ergebnis\PHPUnit\SlowTestDetector\Test; use PHPUnit\Event; use PHPUnit\Framework; -/** - * @internal - * - * @covers \Ergebnis\PHPUnit\SlowTestDetector\MaximumDuration - * - * @uses \Ergebnis\PHPUnit\SlowTestDetector\Exception\InvalidMaximumDuration - */ +#[Framework\Attributes\CoversClass(MaximumDuration::class)] +#[Framework\Attributes\UsesClass(Exception\InvalidMaximumDuration::class)] final class MaximumDurationTest extends Framework\TestCase { use Test\Util\Helper; - /** - * @dataProvider \Ergebnis\DataProvider\IntProvider::lessThanZero - * @dataProvider \Ergebnis\DataProvider\IntProvider::zero - */ + #[Framework\Attributes\DataProviderExternal(DataProvider\IntProvider::class, 'lessThanZero')] + #[Framework\Attributes\DataProviderExternal(DataProvider\IntProvider::class, 'zero')] public function testFromMillisecondsRejectsInvalidValue(int $milliseconds): void { $this->expectException(Exception\InvalidMaximumDuration::class); @@ -41,9 +35,7 @@ public function testFromMillisecondsRejectsInvalidValue(int $milliseconds): void MaximumDuration::fromMilliseconds($milliseconds); } - /** - * @dataProvider provideMillisecondsAndTelemetryDuration - */ + #[Framework\Attributes\DataProvider('provideMillisecondsAndTelemetryDuration')] public function testFromMillisecondsReturnsMaximumDuration( int $milliseconds, Event\Telemetry\Duration $duration, @@ -73,10 +65,8 @@ public static function provideMillisecondsAndTelemetryDuration(): \Generator } } - /** - * @dataProvider \Ergebnis\DataProvider\IntProvider::lessThanZero - * @dataProvider \Ergebnis\DataProvider\IntProvider::zero - */ + #[Framework\Attributes\DataProviderExternal(DataProvider\IntProvider::class, 'lessThanZero')] + #[Framework\Attributes\DataProviderExternal(DataProvider\IntProvider::class, 'zero')] public function testFromSecondsRejectsInvalidValue(int $seconds): void { $this->expectException(Exception\InvalidMaximumDuration::class); @@ -84,9 +74,7 @@ public function testFromSecondsRejectsInvalidValue(int $seconds): void MaximumDuration::fromSeconds($seconds); } - /** - * @dataProvider \Ergebnis\DataProvider\IntProvider::greaterThanZero - */ + #[Framework\Attributes\DataProviderExternal(DataProvider\IntProvider::class, 'greaterThanZero')] public function testFromSecondsReturnsMaximumDuration(int $seconds): void { $maximumDuration = MaximumDuration::fromSeconds($seconds);