From 7bcda1eb711cb866b9372bbfb845854a671b88f7 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 23 Apr 2023 17:58:06 +0700 Subject: [PATCH] [Test] Reduce RunTestsInSeparateProcesses usage (#3667) * [Test] Remove RunTestsInSeparateProcesses usage * [ci-review] Rector Rectify * rename fixture classes * rename fixture * use FileCacheStorage for RenameClassRectorTest * Revert use FileCacheStorage for RenameClassRectorTest This reverts commit af7c37c44bd8dc9dc937044354d46fe63a10dbec. * rename class * rename fixture * another rename * rollback RunTestsInSeparateProcesses --------- Co-authored-by: GitHub Action --- .../VendorLocker/ParentClassMethodTypeOverrideGuard.php | 1 + .../PropertyRenameFactory/PropertyRenameFactoryTest.php | 2 -- .../Fixture/phpunit_rename.php.inc | 4 ++-- .../Fixture/phpunit_test_case_split.php.inc | 4 ++-- .../PseudoNamespaceToNamespaceRectorTest.php | 2 -- ...me_class.php.inc => rename_class_to_new_class.php.inc} | 8 ++++---- .../Fixture/rename_class_without_namespace.php.inc | 8 ++++---- .../Fixture/rename_generic_template_of_fixture.php.inc | 6 +++--- .../Name/RenameClassRector/config/configured_rule.php | 4 ++-- .../Fixture/{return_string.php.inc => fixture.php.inc} | 0 10 files changed, 18 insertions(+), 21 deletions(-) rename rules-tests/Renaming/Rector/Name/RenameClassRector/Fixture/{rename_class.php.inc => rename_class_to_new_class.php.inc} (70%) rename tests/Issues/DowngradeNullJson/Fixture/{return_string.php.inc => fixture.php.inc} (100%) diff --git a/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php b/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php index 43288c41759..e0c08c73e5d 100644 --- a/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php +++ b/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php @@ -42,6 +42,7 @@ public function getParentClassMethod(ClassMethod $classMethod): ?MethodReflectio if ($parentClassReflection->hasNativeMethod($methodName)) { return $parentClassReflection->getNativeMethod($methodName); } + $parentClassReflection = $parentClassReflection->getParentClass(); } diff --git a/rules-tests/Naming/ValueObjectFactory/PropertyRenameFactory/PropertyRenameFactoryTest.php b/rules-tests/Naming/ValueObjectFactory/PropertyRenameFactory/PropertyRenameFactoryTest.php index eef87529561..44d851b4d9a 100644 --- a/rules-tests/Naming/ValueObjectFactory/PropertyRenameFactory/PropertyRenameFactoryTest.php +++ b/rules-tests/Naming/ValueObjectFactory/PropertyRenameFactory/PropertyRenameFactoryTest.php @@ -8,7 +8,6 @@ use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\Property; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; use Rector\Core\PhpParser\Node\BetterNodeFinder; use Rector\FileSystemRector\Parser\FileInfoParser; use Rector\Naming\ExpectedNameResolver\MatchPropertyTypeExpectedNameResolver; @@ -16,7 +15,6 @@ use Rector\Naming\ValueObjectFactory\PropertyRenameFactory; use Rector\Testing\PHPUnit\AbstractTestCase; -#[RunTestsInSeparateProcesses] final class PropertyRenameFactoryTest extends AbstractTestCase { private PropertyRenameFactory $propertyRenameFactory; diff --git a/rules-tests/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/Fixture/phpunit_rename.php.inc b/rules-tests/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/Fixture/phpunit_rename.php.inc index dfe9556e965..e28cddfe856 100644 --- a/rules-tests/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/Fixture/phpunit_rename.php.inc +++ b/rules-tests/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/Fixture/phpunit_rename.php.inc @@ -2,7 +2,7 @@ namespace Rector\Tests\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector\Fixture; -class Fixture extends \PHPUnit_Framework_TestCase +class PhpUnit_Rename extends \PHPUnit_Framework_TestCase { public function create(\PHPUnit_Something $argument): \PHPUnit_Framework_Something { @@ -16,7 +16,7 @@ class Fixture extends \PHPUnit_Framework_TestCase namespace Rector\Tests\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector\Fixture; -class Fixture extends \PHPUnit\Framework\TestCase +class PhpUnit_Rename extends \PHPUnit\Framework\TestCase { public function create(\PHPUnit\Something $argument): \PHPUnit\Framework\Something { diff --git a/rules-tests/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/Fixture/phpunit_test_case_split.php.inc b/rules-tests/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/Fixture/phpunit_test_case_split.php.inc index 5ed285ca4b1..0d1f707fee8 100644 --- a/rules-tests/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/Fixture/phpunit_test_case_split.php.inc +++ b/rules-tests/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/Fixture/phpunit_test_case_split.php.inc @@ -2,7 +2,7 @@ namespace Rector\Tests\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector\Fixture; -class Fixture6 +class PhpunitTestCaseSplit { /** * @param \PHPUnit_Framework_TestCase $test @@ -20,7 +20,7 @@ class Fixture6 namespace Rector\Tests\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector\Fixture; -class Fixture6 +class PhpunitTestCaseSplit { /** * @param \PHPUnit\Framework\TestCase $test diff --git a/rules-tests/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/PseudoNamespaceToNamespaceRectorTest.php b/rules-tests/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/PseudoNamespaceToNamespaceRectorTest.php index 7b864caf3ba..7421c77bc0c 100644 --- a/rules-tests/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/PseudoNamespaceToNamespaceRectorTest.php +++ b/rules-tests/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/PseudoNamespaceToNamespaceRectorTest.php @@ -6,10 +6,8 @@ use Iterator; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -#[RunTestsInSeparateProcesses] final class PseudoNamespaceToNamespaceRectorTest extends AbstractRectorTestCase { #[DataProvider('provideData')] diff --git a/rules-tests/Renaming/Rector/Name/RenameClassRector/Fixture/rename_class.php.inc b/rules-tests/Renaming/Rector/Name/RenameClassRector/Fixture/rename_class_to_new_class.php.inc similarity index 70% rename from rules-tests/Renaming/Rector/Name/RenameClassRector/Fixture/rename_class.php.inc rename to rules-tests/Renaming/Rector/Name/RenameClassRector/Fixture/rename_class_to_new_class.php.inc index 3545d85df04..f517a8e7d1e 100644 --- a/rules-tests/Renaming/Rector/Name/RenameClassRector/Fixture/rename_class.php.inc +++ b/rules-tests/Renaming/Rector/Name/RenameClassRector/Fixture/rename_class_to_new_class.php.inc @@ -2,14 +2,14 @@ namespace MyNamespace; -class MyClass +class MylegacyClass { /** - * @return MyClass + * @return MylegacyClass */ - public function createSelf(): MyClass + public function createSelf(): MylegacyClass { - return new MyClass; + return new MylegacyClass; } } diff --git a/rules-tests/Renaming/Rector/Name/RenameClassRector/Fixture/rename_class_without_namespace.php.inc b/rules-tests/Renaming/Rector/Name/RenameClassRector/Fixture/rename_class_without_namespace.php.inc index 4c3b7713f42..efeafb54c78 100644 --- a/rules-tests/Renaming/Rector/Name/RenameClassRector/Fixture/rename_class_without_namespace.php.inc +++ b/rules-tests/Renaming/Rector/Name/RenameClassRector/Fixture/rename_class_without_namespace.php.inc @@ -17,14 +17,14 @@ class MyOldClass namespace MyNamespace; -class MyNewClass +class MyNewClass2 { /** - * @return \MyNamespace\MyNewClass + * @return \MyNamespace\MyNewClass2 */ - public function createSelf(): \MyNamespace\MyNewClass + public function createSelf(): \MyNamespace\MyNewClass2 { - return new \MyNamespace\MyNewClass; + return new \MyNamespace\MyNewClass2; } } diff --git a/rules-tests/Renaming/Rector/Name/RenameClassRector/Fixture/rename_generic_template_of_fixture.php.inc b/rules-tests/Renaming/Rector/Name/RenameClassRector/Fixture/rename_generic_template_of_fixture.php.inc index 1a14e009e04..3575c369253 100644 --- a/rules-tests/Renaming/Rector/Name/RenameClassRector/Fixture/rename_generic_template_of_fixture.php.inc +++ b/rules-tests/Renaming/Rector/Name/RenameClassRector/Fixture/rename_generic_template_of_fixture.php.inc @@ -2,17 +2,17 @@ namespace Rector\Tests\Renaming\Rector\Name\RenameClassRector\Fixture; -use MyNamespace\MyClass; +use MyNamespace\MylegacyClass; /** - * @template T of MyClass + * @template T of MylegacyClass */ interface MyServiceInterface { /** * @return T */ - public function get(): MyClass; + public function get(): MylegacyClass; } ?> diff --git a/rules-tests/Renaming/Rector/Name/RenameClassRector/config/configured_rule.php b/rules-tests/Renaming/Rector/Name/RenameClassRector/config/configured_rule.php index 3e962257ec3..6044e34f998 100644 --- a/rules-tests/Renaming/Rector/Name/RenameClassRector/config/configured_rule.php +++ b/rules-tests/Renaming/Rector/Name/RenameClassRector/config/configured_rule.php @@ -32,10 +32,10 @@ 'Twig_AbstractManualExtension' => AbstractManualExtension::class, 'Twig_Extension_Sandbox' => 'Twig\Extension\SandboxExtension', // Renaming class itself and its namespace - 'MyNamespace\MyClass' => 'MyNewNamespace\MyNewClass', + 'MyNamespace\MylegacyClass' => 'MyNewNamespace\MyNewClass', 'MyNamespace\MyTrait' => 'MyNewNamespace\MyNewTrait', 'MyNamespace\MyInterface' => 'MyNewNamespace\MyNewInterface', - 'MyOldClass' => 'MyNamespace\MyNewClass', + 'MyOldClass' => 'MyNamespace\MyNewClass2', 'AnotherMyOldClass' => 'AnotherMyNewClass', 'MyNamespace\AnotherMyClass' => 'MyNewClassWithoutNamespace', // test duplicated class - @see https://github.com/rectorphp/rector/issues/1438 diff --git a/tests/Issues/DowngradeNullJson/Fixture/return_string.php.inc b/tests/Issues/DowngradeNullJson/Fixture/fixture.php.inc similarity index 100% rename from tests/Issues/DowngradeNullJson/Fixture/return_string.php.inc rename to tests/Issues/DowngradeNullJson/Fixture/fixture.php.inc