Skip to content

Commit 8116e70

Browse files
authored
⬆️ PHPUnit 11 (#85)
1 parent 19ca952 commit 8116e70

26 files changed

+94
-88
lines changed

.github/workflows/workflows.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
runs-on: ubuntu-latest
66
strategy:
77
matrix:
8-
php-versions: ['8.1', '8.2', '8.3']
8+
php-versions: ['8.2', '8.3']
99
steps:
1010
- uses: actions/checkout@v4
1111
- uses: "shivammathur/setup-php@v2"
@@ -23,7 +23,7 @@ jobs:
2323
runs-on: ubuntu-latest
2424
strategy:
2525
matrix:
26-
php-versions: ['8.1', '8.2', '8.3']
26+
php-versions: ['8.2', '8.3']
2727
steps:
2828
- uses: actions/checkout@v4
2929
- uses: "shivammathur/setup-php@v2"
@@ -41,7 +41,7 @@ jobs:
4141
runs-on: ubuntu-latest
4242
strategy:
4343
matrix:
44-
php-versions: ['8.1', '8.2', '8.3']
44+
php-versions: ['8.2', '8.3']
4545
dependency-versions: ['highest', 'lowest']
4646
steps:
4747
- uses: actions/checkout@v4

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"homepage": "https://github.com/previousnext/coding-standard",
55
"keywords": ["drupal", "phpcs"],
66
"require": {
7-
"php": "^8.1",
7+
"php": "^8.2",
88
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
99
"drupal/coder": "^8.3.24",
1010
"slevomat/coding-standard": "^8.15.0",
@@ -15,7 +15,7 @@
1515
"phpstan/phpstan": "^1.11.3",
1616
"phpstan/phpstan-deprecation-rules": "^1.2.0",
1717
"phpstan/phpstan-strict-rules": "^1.6.0",
18-
"phpunit/phpunit": "^9.6.19"
18+
"phpunit/phpunit": "^11"
1919
},
2020
"license": "MIT",
2121
"autoload": {

phpcs.xml

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
<rule ref="PreviousNextDrupal" />
1111
<arg name="report" value="full"/>
1212

13-
<!-- Most functions are tests, and are self documenting. -->
13+
<!-- Most classes and functions are tests, and are self documenting. -->
14+
<rule ref="Drupal.Commenting.ClassComment.Missing">
15+
<exclude-pattern>./tests/*</exclude-pattern>
16+
</rule>
1417
<rule ref="Drupal.Commenting.FunctionComment.Missing">
1518
<exclude-pattern>./tests/*</exclude-pattern>
1619
</rule>

phpunit.xml

+16-17
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
4-
bootstrap="tests/bootstrap.php"
5-
cacheResultFile=".phpunit.cache/test-results"
6-
executionOrder="depends,defects"
7-
beStrictAboutCoversAnnotation="true"
8-
beStrictAboutOutputDuringTests="true"
9-
beStrictAboutTodoAnnotatedTests="true"
10-
convertDeprecationsToExceptions="true"
11-
failOnRisky="true"
12-
failOnWarning="true"
13-
verbose="true">
14-
<testsuites>
15-
<testsuite name="default">
16-
<directory>tests</directory>
17-
</testsuite>
18-
</testsuites>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.1/phpunit.xsd"
5+
bootstrap="tests/bootstrap.php"
6+
executionOrder="depends,defects"
7+
beStrictAboutOutputDuringTests="true"
8+
failOnRisky="true"
9+
failOnWarning="true"
10+
cacheDirectory=".phpunit.cache"
11+
beStrictAboutCoverageMetadata="true"
12+
>
13+
<testsuites>
14+
<testsuite name="default">
15+
<directory>tests</directory>
16+
</testsuite>
17+
</testsuites>
1918
</phpunit>

tests/Ignore/IgnoreDocCommentSniffTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Ignore;
66

7-
/**
8-
* @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\DocCommentSniff
9-
*/
7+
use PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\DocCommentSniff;
8+
use PHPUnit\Framework\Attributes\CoversClass;
9+
10+
#[CoversClass(DocCommentSniff::class)]
1011
final class IgnoreDocCommentSniffTest extends Base {
1112

1213
/**

tests/Ignore/IgnoreDrupalArraysArrayLongLineDeclarationTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Ignore;
66

7-
/**
8-
* @covers \Drupal\Sniffs\Arrays\ArraySniff
9-
*/
7+
use Drupal\Sniffs\Arrays\ArraySniff;
8+
use PHPUnit\Framework\Attributes\CoversClass;
9+
10+
#[CoversClass(ArraySniff::class)]
1011
final class IgnoreDrupalArraysArrayLongLineDeclarationTest extends Base {
1112

1213
/**

tests/Ignore/IgnoreDrupalCommentingClassCommentShortTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Ignore;
66

7-
/**
8-
* @covers \Drupal\Sniffs\Commenting\ClassCommentSniff
9-
*/
7+
use Drupal\Sniffs\Commenting\ClassCommentSniff;
8+
use PHPUnit\Framework\Attributes\CoversClass;
9+
10+
#[CoversClass(ClassCommentSniff::class)]
1011
final class IgnoreDrupalCommentingClassCommentShortTest extends Base {
1112

1213
/**

tests/Ignore/IgnoreDrupalCommentingFunctionCommentTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Ignore;
66

7-
/**
8-
* @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\FunctionCommentSniff
9-
*/
7+
use PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\FunctionCommentSniff;
8+
use PHPUnit\Framework\Attributes\CoversClass;
9+
10+
#[CoversClass(FunctionCommentSniff::class)]
1011
final class IgnoreDrupalCommentingFunctionCommentTest extends Base {
1112

1213
/**

tests/Ignore/IgnoreDrupalCommentingTodoCommentTodoFormatTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Ignore;
66

7-
/**
8-
* @covers \Drupal\Sniffs\Commenting\TodoCommentSniff
9-
*/
7+
use Drupal\Sniffs\Commenting\TodoCommentSniff;
8+
use PHPUnit\Framework\Attributes\CoversClass;
9+
10+
#[CoversClass(TodoCommentSniff::class)]
1011
final class IgnoreDrupalCommentingTodoCommentTodoFormatTest extends Base {
1112

1213
/**

tests/Ignore/IgnoreDrupalCommentingVariableCommentMissingTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Ignore;
66

7-
/**
8-
* @covers \Drupal\Sniffs\Commenting\VariableCommentSniff
9-
*/
7+
use Drupal\Sniffs\Commenting\VariableCommentSniff;
8+
use PHPUnit\Framework\Attributes\CoversClass;
9+
10+
#[CoversClass(VariableCommentSniff::class)]
1011
final class IgnoreDrupalCommentingVariableCommentMissingTest extends Base {
1112

1213
public function testIgnored(): void {

tests/Ignore/IgnoreUnreachableTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Ignore;
66

7-
/**
8-
* @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\NonExecutableCodeSniff
9-
*/
7+
use PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\NonExecutableCodeSniff;
8+
use PHPUnit\Framework\Attributes\CoversClass;
9+
10+
#[CoversClass(NonExecutableCodeSniff::class)]
1011
final class IgnoreUnreachableTest extends Base {
1112

1213
public function testIgnored(): void {

tests/Sniffs/AlphabeticallySortedUsesTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Sniffs;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use SlevomatCodingStandard\Sniffs\Namespaces\AlphabeticallySortedUsesSniff;
89

9-
/**
10-
* @covers \SlevomatCodingStandard\Sniffs\Namespaces\AlphabeticallySortedUsesSniff
11-
*/
10+
#[CoversClass(AlphabeticallySortedUsesSniff::class)]
1211
final class AlphabeticallySortedUsesTest extends Base {
1312

1413
public function testNoError(): void {

tests/Sniffs/ClassStructureTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Sniffs;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use SlevomatCodingStandard\Sniffs\Classes\ClassStructureSniff;
89

9-
/**
10-
* @covers \SlevomatCodingStandard\Sniffs\Classes\ClassStructureSniff
11-
*/
10+
#[CoversClass(ClassStructureSniff::class)]
1211
final class ClassStructureTest extends Base {
1312

1413
public function testNoError(): void {

tests/Sniffs/FullyQualifiedGlobalFunctionsTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Sniffs;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use SlevomatCodingStandard\Sniffs\Namespaces\FullyQualifiedGlobalFunctionsSniff;
89

9-
/**
10-
* @covers \SlevomatCodingStandard\Sniffs\Namespaces\FullyQualifiedGlobalFunctionsSniff
11-
*/
10+
#[CoversClass(FullyQualifiedGlobalFunctionsSniff::class)]
1211
final class FullyQualifiedGlobalFunctionsTest extends Base {
1312

1413
public function testNoError(): void {

tests/Sniffs/FunctionClosingBraceSpacingBeforeCloseTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Sniffs;
66

7-
/**
8-
* @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\FunctionOpeningBraceSpaceSniff
9-
*/
7+
use PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\FunctionOpeningBraceSpaceSniff;
8+
use PHPUnit\Framework\Attributes\CoversClass;
9+
10+
#[CoversClass(FunctionOpeningBraceSpaceSniff::class)]
1011
final class FunctionClosingBraceSpacingBeforeCloseTest extends Base {
1112

1213
public function testNoError(): void {

tests/Sniffs/FunctionOpeningBraceSpaceSpacingAfterTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Sniffs;
66

7-
/**
8-
* @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\FunctionOpeningBraceSpaceSniff
9-
*/
7+
use PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\FunctionOpeningBraceSpaceSniff;
8+
use PHPUnit\Framework\Attributes\CoversClass;
9+
10+
#[CoversClass(FunctionOpeningBraceSpaceSniff::class)]
1011
final class FunctionOpeningBraceSpaceSpacingAfterTest extends Base {
1112

1213
public function testNoError(): void {

tests/Sniffs/FunctionsStaticClosureTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Sniffs;
66

7-
/**
8-
* @covers \SlevomatCodingStandard\Sniffs\Functions\StaticClosureSniff
9-
*/
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use SlevomatCodingStandard\Sniffs\Functions\StaticClosureSniff;
9+
10+
#[CoversClass(StaticClosureSniff::class)]
1011
final class FunctionsStaticClosureTest extends Base {
1112

1213
public function testNoError(): void {

tests/Sniffs/RequireMultiLineMethodSignatureTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Sniffs;
66

7-
/**
8-
* @covers \SlevomatCodingStandard\Sniffs\Classes\RequireMultiLineMethodSignatureSniff
9-
*/
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use SlevomatCodingStandard\Sniffs\Classes\RequireMultiLineMethodSignatureSniff;
9+
10+
#[CoversClass(RequireMultiLineMethodSignatureSniff::class)]
1011
final class RequireMultiLineMethodSignatureTest extends Base {
1112

1213
public function testNoError(): void {

tests/Sniffs/RequireNullSafeObjectOperatorTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Sniffs;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use SlevomatCodingStandard\Sniffs\ControlStructures\RequireNullSafeObjectOperatorSniff;
89

9-
/**
10-
* @covers \SlevomatCodingStandard\Sniffs\ControlStructures\RequireNullSafeObjectOperatorSniff
11-
*/
10+
#[CoversClass(RequireNullSafeObjectOperatorSniff::class)]
1211
final class RequireNullSafeObjectOperatorTest extends Base {
1312

1413
public function testNoError(): void {

tests/Sniffs/RequireTrailingCommaInCallTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Sniffs;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use SlevomatCodingStandard\Sniffs\Functions\RequireTrailingCommaInDeclarationSniff;
89

9-
/**
10-
* @covers \SlevomatCodingStandard\Sniffs\Functions\RequireTrailingCommaInDeclarationSniff
11-
*/
10+
#[CoversClass(RequireTrailingCommaInDeclarationSniff::class)]
1211
final class RequireTrailingCommaInCallTest extends Base {
1312

1413
public function testNoError(): void {

tests/Sniffs/RequireTrailingCommaInDeclarationTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Sniffs;
66

7-
/**
8-
* @covers \SlevomatCodingStandard\Sniffs\Classes\RequireMultiLineMethodSignatureSniff
9-
*/
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use SlevomatCodingStandard\Sniffs\Classes\RequireMultiLineMethodSignatureSniff;
9+
10+
#[CoversClass(RequireMultiLineMethodSignatureSniff::class)]
1011
final class RequireTrailingCommaInDeclarationTest extends Base {
1112

1213
public function testNoError(): void {

tests/Sniffs/ReturnTypeHintSpacingTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Sniffs;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSpacingSniff;
89

9-
/**
10-
* @covers \SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSpacingSniff
11-
*/
10+
#[CoversClass(ReturnTypeHintSpacingSniff::class)]
1211
final class ReturnTypeHintSpacingTest extends Base {
1312

1413
public function testNoError(): void {

tests/Sniffs/ReturnTypeHintTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Sniffs;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSniff;
89

910
/**
10-
* @covers \SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSniff
1111
* @see https://github.com/slevomat/coding-standard/blob/master/doc/type-hints.md#slevomatcodingstandardtypehintsreturntypehint-
1212
*/
13+
#[CoversClass(ReturnTypeHintSniff::class)]
1314
final class ReturnTypeHintTest extends Base {
1415

1516
public function testNoError(): void {
@@ -20,7 +21,7 @@ public function testNoError(): void {
2021
/**
2122
* Ensures traversables do not need to be fully documented.
2223
*
23-
* @covers \SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSniff::CODE_MISSING_TRAVERSABLE_TYPE_HINT_SPECIFICATION
24+
* @see \SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSniff::CODE_MISSING_TRAVERSABLE_TYPE_HINT_SPECIFICATION
2425
*/
2526
public function testIgnoreTraversable(): void {
2627
$report = self::checkFile(__DIR__ . '/fixtures/ReturnTypeHintIgnoreTraversable.php');

tests/Sniffs/StrictTypesTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Sniffs;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use SlevomatCodingStandard\Sniffs\TypeHints\DeclareStrictTypesSniff;
89

9-
/**
10-
* @covers \SlevomatCodingStandard\Sniffs\TypeHints\DeclareStrictTypesSniff
11-
*/
10+
#[CoversClass(DeclareStrictTypesSniff::class)]
1211
final class StrictTypesTest extends Base {
1312

1413
public function testNoError(): void {

tests/Sniffs/UnusedInheritedVariablePassedToClosureTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Sniffs;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use SlevomatCodingStandard\Sniffs\Functions\UnusedInheritedVariablePassedToClosureSniff;
89

9-
/**
10-
* @covers \SlevomatCodingStandard\Sniffs\Functions\UnusedInheritedVariablePassedToClosureSniff
11-
*/
10+
#[CoversClass(UnusedInheritedVariablePassedToClosureSniff::class)]
1211
final class UnusedInheritedVariablePassedToClosureTest extends Base {
1312

1413
public function testNoError(): void {

0 commit comments

Comments
 (0)