Skip to content

Commit

Permalink
Allow use of @precondition and @postcondition PHPUnit annotations
Browse files Browse the repository at this point in the history
New in PHPUnit 9.1
sebastianbergmann/phpunit#4148

Change-Id: Ie147e7446e8edf1febf56cab7f69e0c33584395d
  • Loading branch information
umherirrender committed Dec 13, 2024
1 parent 6939f62 commit 82f8c83
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions MediaWiki/Sniffs/Commenting/FunctionAnnotationsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class FunctionAnnotationsSniff implements Sniff {
// are listed above
'@afterclass' => '@afterClass',
'@beforeclass' => '@beforeClass',
'@precondition' => '@preCondition',
'@postcondition' => '@postCondition',
'@codecoverageignore' => '@codeCoverageIgnore',
'@covernothing' => '@coverNothing',
'@coversnothing' => '@coversNothing',
Expand Down
15 changes: 15 additions & 0 deletions MediaWiki/Sniffs/Commenting/PhpunitAnnotationsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class PhpunitAnnotationsSniff implements Sniff {
'@before' => true,
'@beforeClass' => true,

'@preCondition' => true,
'@postCondition' => true,

'@covers' => true,
'@cover' => [ '@covers', 'SingularCover' ],

Expand Down Expand Up @@ -107,6 +110,8 @@ class PhpunitAnnotationsSniff implements Sniff {
'@afterClass',
'@before',
'@beforeClass',
'@preCondition',
'@postCondition',
];

/**
Expand Down Expand Up @@ -134,6 +139,16 @@ class PhpunitAnnotationsSniff implements Sniff {
'message' => 'setUp functions (*SetUpBeforeClass)',
'code' => 'NotSetUpBeforeClassFunction',
],
'@preCondition' => [
'regex' => '/PreConditions$/',
'message' => 'assertPreConditions functions (*PreConditions)',
'code' => 'NotAssertPreConditionsFunction',
],
'@postCondition' => [
'regex' => '/PostConditions$/',
'message' => 'assertPostConditions functions (*PostConditions)',
'code' => 'NotAssertPostConditionsFunction',
],
'*' => [
'regex' => '/^(?:test|provide)|Provider$/',
'message' => 'test functions',
Expand Down

0 comments on commit 82f8c83

Please sign in to comment.