Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions config/sets/composer-based.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@
use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DataProviderAnnotationToAttributeRector;
use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DependsAnnotationWithValueToAttributeRector;
use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\TestWithAnnotationToAttributeRector;
use Rector\PHPUnit\PHPUnit110\Rector\CallLike\AssertContainsOnlyMethodCallRector;
use Rector\PHPUnit\PHPUnit110\Rector\ClassMethod\MockObjectArgCreateStubToCreateMockRector;
use Rector\PHPUnit\PHPUnit120\Rector\Class_\AssertIsTypeMethodCallRector;
use Rector\PHPUnit\ValueObject\AnnotationWithValueToAttribute;

/**
* Annotation to attribute pairs bound to the PHPUnit version installed in the analysed project,
* as not every attribute exists in every PHPUnit version.
* Rules and configuration bound to the PHPUnit version installed in the analysed project,
* as not every attribute and method exists in every PHPUnit version.
*
* Thanks to the composer package constraint, these rules can be registered once here, instead of being
* repeated in every PHPUnit version set to cover a direct upgrade from an older version.
*/
return static function (RectorConfig $rectorConfig): void {
// each of these rules declares the "phpunit/phpunit" version its attributes were added in,
Expand All @@ -28,6 +34,13 @@
CoversAnnotationWithValueToAttributeRector::class,
RequiresAnnotationWithValueToAttributeRector::class,
DependsAnnotationWithValueToAttributeRector::class,

// stubs are required over mocks since PHPUnit 11.0
MockObjectArgCreateStubToCreateMockRector::class,

// deprecated in PHPUnit 11.5
AssertContainsOnlyMethodCallRector::class,
AssertIsTypeMethodCallRector::class,
]);

// both attributes were added in PHPUnit 10.0
Expand Down
16 changes: 6 additions & 10 deletions config/sets/phpunit110.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\PHPUnit\PHPUnit110\Rector\CallLike\AssertContainsOnlyMethodCallRector;
use Rector\PHPUnit\PHPUnit110\Rector\Class_\NamedArgumentForDataProviderRector;
use Rector\PHPUnit\PHPUnit110\Rector\ClassMethod\MockObjectArgCreateStubToCreateMockRector;
use Rector\PHPUnit\PHPUnit120\Rector\Class_\AssertIsTypeMethodCallRector;
use Rector\PHPUnit\Set\PHPUnitSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rules([
NamedArgumentForDataProviderRector::class,
MockObjectArgCreateStubToCreateMockRector::class,
// deprecated in PHPUnit 11.5, guarded by composer package constraint
AssertContainsOnlyMethodCallRector::class,
AssertIsTypeMethodCallRector::class,
]);
// MockObjectArgCreateStubToCreateMockRector, AssertContainsOnlyMethodCallRector
// and AssertIsTypeMethodCallRector are registered there, guarded by composer package constraint
$rectorConfig->sets([PHPUnitSetList::COMPOSER_BASED]);

$rectorConfig->rules([NamedArgumentForDataProviderRector::class]);
};
11 changes: 2 additions & 9 deletions config/sets/phpunit120.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\PHPUnit\PHPUnit110\Rector\CallLike\AssertContainsOnlyMethodCallRector;
use Rector\PHPUnit\PHPUnit120\Rector\Class_\AssertIsTypeMethodCallRector;
use Rector\PHPUnit\PHPUnit120\Rector\Class_\RemoveOverrideFinalConstructTestCaseRector;
use Rector\PHPUnit\Set\PHPUnitSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([PHPUnitSetList::PHPUNIT_MOCK_TO_STUB]);
$rectorConfig->sets([PHPUnitSetList::PHPUNIT_MOCK_TO_STUB, PHPUnitSetList::COMPOSER_BASED]);

$rectorConfig->rules([
RemoveOverrideFinalConstructTestCaseRector::class,
// deprecated in PHPUnit 11.5, repeated here for a direct 11.4 → 12.0 upgrade
AssertContainsOnlyMethodCallRector::class,
AssertIsTypeMethodCallRector::class,
]);
$rectorConfig->rules([RemoveOverrideFinalConstructTestCaseRector::class]);
};
11 changes: 4 additions & 7 deletions config/sets/phpunit130.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\PHPUnit\PHPUnit110\Rector\CallLike\AssertContainsOnlyMethodCallRector;
use Rector\PHPUnit\PHPUnit120\Rector\Class_\AssertIsTypeMethodCallRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rules([
// deprecated in PHPUnit 11.5, repeated here for a direct upgrade from an older version
AssertContainsOnlyMethodCallRector::class,
AssertIsTypeMethodCallRector::class,
]);
// AssertContainsOnlyMethodCallRector and AssertIsTypeMethodCallRector are registered there,
// guarded by composer package constraint
$rectorConfig->sets([PHPUnitSetList::COMPOSER_BASED]);

$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
// @see https://github.com/sebastianbergmann/phpunit/issues/6560
Expand Down
Loading