From 16b2b0376cdc6a90486795ebc1fc68be1775078a Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 19 Mar 2021 10:52:08 +0100 Subject: [PATCH] [PHPUnit] Decouple to own package (#5905) --- composer.json | 1 + config/config.php | 2 + ...mAssertionToNonAssertingTestRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 30 -- .../Fixture/just_mocks_test.php.inc | 38 -- .../Fixture/keep_assert.php.inc | 18 - .../Fixture/keep_assert_in_call.php.inc | 16 - .../keep_assert_in_static_call.php.inc | 18 - .../Fixture/keep_expected_exception.php.inc | 26 -- .../Fixture/keep_non_public.php.inc | 10 - .../Fixture/keep_non_test.php.inc | 10 - .../keep_with_parent_method_assert.php.inc | 13 - ...p_with_parent_method_static_assert.php.inc | 13 - .../Fixture/prophecy_assertions.php.inc | 58 --- .../Fixture/skip_existing_annotation.php.inc | 13 - .../Fixture/test_in_annotation.php.inc | 34 -- .../Source/AbstractClassWithAssert.php | 20 - .../Source/AbstractClassWithStaticAssert.php | 20 - .../Source/Denormalizer.php | 27 -- .../Source/DenormalizerInterface.php | 20 - .../ExceptionAnnotationRectorTest.php | 34 -- .../Fixture/constant_code.php.inc | 35 -- .../Fixture/fixture.php.inc | 33 -- .../Fixture/fixture2.php.inc | 37 -- .../Fixture/fixture3.php.inc | 29 -- .../Fixture/fixture4.php.inc | 63 ---- .../skip_method_with_null_php_doc.php.inc | 21 -- .../Source/SomeConstant.php | 13 - .../Fixture/different_return_values.php.inc | 74 ---- .../Fixture/expects_non_at_is_skipped.php.inc | 22 -- .../Fixture/handle_multiple_variables.php.inc | 65 ---- ...pty_array_if_no_return_expectation.php.inc | 48 --- ...ty_array_if_no_return_expectation2.php.inc | 48 --- .../Fixture/mixed.php.inc | 50 --- .../Fixture/mixed2.php.inc | 56 --- ...skip_different_method_expectations.php.inc | 39 -- .../skip_missing_return_expectation.php.inc | 37 -- ..._with_if_return_expectations_exist.php.inc | 30 -- .../Fixture/will_callbacks_are_kept.php.inc | 48 --- .../Fixture/will_return_only.php.inc | 56 --- .../Fixture/with_multiple_arguments.php.inc | 44 --- .../Fixture/with_only.php.inc | 56 --- ...eAtToConsecutiveExpectationsRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 27 -- .../RemoveEmptyTestMethodRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 40 -- .../Fixture/fixture2.php.inc | 38 -- .../TryCatchToExpectExceptionRectorTest.php | 34 -- .../AddProphecyTraitRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 32 -- .../Fixture/skip_if_already_added.php.inc | 16 - .../Fixture/skip_non_prophesize.php.inc | 15 - .../AddSeeTestAnnotationRectorTest.php | 34 -- .../Fixture/add_to_doc_block.php.inc | 34 -- .../Fixture/remove_non_existing_see.php.inc | 33 -- .../Fixture/skip_different_namespace.php.inc | 10 - .../Fixture/skip_existing.php.inc | 10 - .../Fixture/skip_simple_class_comment.php.inc | 10 - .../Fixture/surrounded_doc.php.inc | 34 -- .../Source/DifferentNamespaceTest.php | 10 - .../Source/SkipSimpleClassCommentTest.php | 10 - .../Source/SomeExistingTest.php | 10 - .../ArrayArgumentToDataProviderRectorTest.php | 33 -- .../Fixture/fixture.php.inc | 36 -- .../Fixture/two_arguments.php.inc | 34 -- .../Fixture/various_types.php.inc | 37 -- .../config/configured_rule.php | 22 -- ...ctClassMethodToSetUpTestCaseRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 36 -- .../Fixture/fixture.php.inc | 43 --- .../Fixture/multiple_data_providers.php.inc | 67 ---- .../Fixture/with_test_annotation.php.inc | 45 --- ...RemoveDataProviderTestPrefixRectorTest.php | 34 -- .../Fixture/before_list_hook.php.inc | 82 ---- .../Fixture/clear_it_all.php.inc | 70 ---- .../TestListenerToHooksRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 49 --- .../SimplifyForeachInstanceOfRectorTest.php | 34 -- ...ssertCompareToSpecificMethodRectorTest.php | 34 -- .../Fixture/count.php.inc | 35 -- .../Fixture/fixture.php.inc | 37 -- .../Fixture/get_class.php.inc | 35 -- ...rtComparisonToSpecificMethodRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 41 -- ...rameterToSpecificMethodsTypeRectorTest.php | 34 -- .../Fixture/combination.php.inc | 42 --- .../Fixture/refactor_canonize.php.inc | 36 -- .../Fixture/refactor_delta.php.inc | 45 --- .../Fixture/refactor_ignore_case.php.inc | 36 -- .../Fixture/remove_max_depth.php.inc | 33 -- .../AssertEqualsToSameRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 51 --- .../Fixture/fixture_2.php.inc | 51 --- .../Fixture/mark_test_incomplete.php.inc | 39 -- .../Fixture/mark_test_skipped.php.inc | 37 -- .../Fixture/skip.php.inc | 23 -- .../Fixture/skip_2.php.inc | 23 -- .../AssertFalseStrposToContainsRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 29 -- .../Fixture/skip_method_call.php.inc | 12 - .../Fixture/skip_static_call.php.inc | 11 - .../AssertInstanceOfComparisonRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 35 -- .../AssertIssetToSpecificMethodRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 33 -- .../AssertNotOperatorRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 31 -- .../AssertPropertyExistsRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 33 -- .../Fixture/fixture2.php.inc | 29 -- .../Fixture/skip_method_call.php.inc | 12 - .../Fixture/skip_static_call.php.inc | 11 - .../AssertRegExpRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 33 -- ...sertResourceToClosedResourceRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 35 -- .../Fixture/fixture_2.php.inc | 35 -- ...SameBoolNullToSpecificMethodRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 29 -- ...meTrueFalseToAssertTrueFalseRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 33 -- .../Fixture/skip_already.php.inc | 14 - ...InternalTypeToSpecificMethodRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 29 -- .../Fixture/skip_assert_false_test.php.inc | 15 - .../Fixture/third_argument.php.inc | 35 -- ...ertTrueFalseToSpecificMethodRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 61 --- .../Fixture/fixture2.php.inc | 33 -- .../Fixture/is_readable.php.inc | 31 -- .../Fixture/skip_method_call.php.inc | 12 - .../Fixture/skip_static_call.php.inc | 11 - .../CreateMockToCreateStubRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 35 -- .../Fixture/skip_non_phpunit.php.inc | 11 - .../Fixture/skip_sonata_expects.php.inc | 17 - .../Fixture/skip_with_expects.php.inc | 16 - .../DelegateExceptionArgumentsRectorTest.php | 34 -- .../Fixture/message.php.inc | 38 -- .../Fixture/regexp.php.inc | 24 -- .../Fixture/self_nested.php.inc | 37 -- .../ExplicitPhpErrorApiRectorTest.php | 34 -- .../Fixture/php_deprecation.php.inc | 31 -- .../Fixture/php_error.php.inc | 31 -- .../Fixture/php_notice.php.inc | 31 -- .../Fixture/php_warning.php.inc | 31 -- .../Fixture/fixture.php.inc | 29 -- .../Fixture/get_mock_only.php.inc | 28 -- ...ckBuilderGetMockToCreateMockRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 37 -- .../Fixture/keep.php.inc | 16 - .../RemoveExpectAnyFromMockRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 35 -- ...rtArraySubsetWithDmsPolyfillRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 39 -- .../Fixture/skip_iterable.php.inc | 13 - .../Fixture/skip_iterable_get.php.inc | 20 - .../Fixture/string_or_false.php.inc | 55 --- .../Fixture/string_or_null.php.inc | 49 --- .../SpecificAssertContainsRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 37 -- .../Fixture/skip_partial_arguments.php.inc | 16 - .../Fixture/skip_strings.php.inc | 14 - .../Fixture/skip_with_identity_check.php.inc | 16 - ...ssertContainsWithoutIdentityRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 33 -- .../SpecificAssertInternalTypeRectorTest.php | 34 -- .../Fixture/will.php.inc | 74 ---- .../Fixture/with.php.inc | 35 -- .../UseSpecificWillMethodRectorTest.php | 34 -- .../Fixture/fixture.php.inc | 46 --- .../Fixture/skip_already_array.php.inc | 17 - .../Source/ClassWithMethodOfTwoArguments.php | 13 - .../WithConsecutiveArgToArrayRectorTest.php | 34 -- .../GetMockRector/Fixture/fixture.php.inc | 27 -- .../Fixture/get_mock_multi.php.inc | 27 -- .../Fixture/skip_build_mock.php.inc | 12 - .../GetMockRector/Fixture/static_call.php.inc | 27 -- .../GetMockRector/GetMockRectorTest.php | 34 -- .../TestClassResolver/Source/SeeSomeClass.php | 10 - .../Source/SeeSomeClassTest.php | 11 - .../TestClassResolverTest.php | 49 --- .../ComposerAutoloadedDirectoryProvider.php | 106 ------ .../NodeAnalyzer/ExpectationAnalyzer.php | 175 --------- .../NodeAnalyzer/TestsNodeAnalyzer.php | 110 ------ .../NodeFactory/ArgumentShiftingFactory.php | 24 -- .../PHPUnit/NodeFactory/AssertCallFactory.php | 21 -- .../ConsecutiveAssertionFactory.php | 184 --------- .../DataProviderClassMethodFactory.php | 50 --- .../ExpectExceptionCodeFactory.php | 54 --- .../NodeFactory/ExpectExceptionFactory.php | 41 -- .../ExpectExceptionMessageFactory.php | 61 --- .../ExpectExceptionMessageRegExpFactory.php | 74 ---- .../ExpectExceptionMethodCallFactory.php | 115 ------ .../NodeFactory/SetUpClassMethodFactory.php | 60 --- .../PHPUnit/NodeManipulator/ArgumentMover.php | 23 -- .../ParamAndArgFromArrayResolver.php | 139 ------- .../SetUpClassMethodNodeManipulator.php | 48 --- .../NodeManipulator/StmtManipulator.php | 32 -- .../PhpDoc/PhpDocValueToNodeMapper.php | 46 --- ...rformAssertionToNonAssertingTestRector.php | 327 ---------------- .../ClassMethod/ExceptionAnnotationRector.php | 126 ------- ...grateAtToConsecutiveExpectationsRector.php | 209 ----------- .../RemoveEmptyTestMethodRector.php | 89 ----- .../TryCatchToExpectExceptionRector.php | 200 ---------- .../Rector/Class_/AddProphecyTraitRector.php | 133 ------- .../Class_/AddSeeTestAnnotationRector.php | 213 ----------- .../ArrayArgumentToDataProviderRector.php | 350 ------------------ ...structClassMethodToSetUpTestCaseRector.php | 146 -------- .../RemoveDataProviderTestPrefixRector.php | 154 -------- .../Class_/TestListenerToHooksRector.php | 170 --------- .../SimplifyForeachInstanceOfRector.php | 108 ------ .../AssertCompareToSpecificMethodRector.php | 154 -------- ...AssertComparisonToSpecificMethodRector.php | 179 --------- ...lsParameterToSpecificMethodsTypeRector.php | 175 --------- .../MethodCall/AssertEqualsToSameRector.php | 111 ------ .../AssertFalseStrposToContainsRector.php | 122 ------ .../AssertInstanceOfComparisonRector.php | 115 ------ .../AssertIssetToSpecificMethodRector.php | 145 -------- .../MethodCall/AssertNotOperatorRector.php | 95 ----- .../MethodCall/AssertPropertyExistsRector.php | 132 ------- .../Rector/MethodCall/AssertRegExpRector.php | 166 --------- .../AssertResourceToClosedResourceRector.php | 89 ----- ...sertSameBoolNullToSpecificMethodRector.php | 116 ------ ...rtSameTrueFalseToAssertTrueFalseRector.php | 111 ------ ...alseInternalTypeToSpecificMethodRector.php | 143 ------- .../AssertTrueFalseToSpecificMethodRector.php | 199 ---------- .../CreateMockToCreateStubRector.php | 136 ------- .../DelegateExceptionArgumentsRector.php | 106 ------ .../MethodCall/ExplicitPhpErrorApiRector.php | 146 -------- ...etMockBuilderGetMockToCreateMockRector.php | 88 ----- .../RemoveExpectAnyFromMockRector.php | 108 ------ ...AssertArraySubsetWithDmsPolyfillRector.php | 92 ----- .../SpecificAssertContainsRector.php | 117 ------ ...ficAssertContainsWithoutIdentityRector.php | 119 ------ .../SpecificAssertInternalTypeRector.php | 129 ------- .../UseSpecificWillMethodRector.php | 168 --------- .../WithConsecutiveArgToArrayRector.php | 229 ------------ .../Rector/StaticCall/GetMockRector.php | 78 ---- .../PHPUnitTestCaseClassesProvider.php | 61 --- .../TestClassResolver/TestClassResolver.php | 113 ------ .../ArrayArgumentToDataProvider.php | 58 --- .../ValueObject/BinaryOpWithAssertMethod.php | 45 --- .../ValueObject/ConstantWithAssertMethods.php | 45 --- .../DataProviderClassMethodRecipe.php | 42 --- rules/PHPUnit/ValueObject/ExpectationMock.php | 98 ----- .../ValueObject/ExpectationMockCollection.php | 131 ------- .../FunctionNameWithAssertMethods.php | 45 --- rules/PHPUnit/ValueObject/ParamAndArg.php | 37 -- stubs/PHPUnit/Framework/TestListener.php | 14 - stubs/PHPUnit/PHPUnit_Framework_TestCase.php | 12 - stubs/Prophecy/PhpUnit/ProphecyTrait.php | 14 - 252 files changed, 3 insertions(+), 13627 deletions(-) delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/AddDoesNotPerformAssertionToNonAssertingTestRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/just_mocks_test.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_assert.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_assert_in_call.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_assert_in_static_call.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_expected_exception.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_non_public.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_non_test.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_with_parent_method_assert.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_with_parent_method_static_assert.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/prophecy_assertions.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/skip_existing_annotation.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/test_in_annotation.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Source/AbstractClassWithAssert.php delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Source/AbstractClassWithStaticAssert.php delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Source/Denormalizer.php delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Source/DenormalizerInterface.php delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/ExceptionAnnotationRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/constant_code.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/fixture2.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/fixture3.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/fixture4.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/skip_method_with_null_php_doc.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Source/SomeConstant.php delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/different_return_values.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/expects_non_at_is_skipped.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/handle_multiple_variables.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/missing_with_is_replaced_by_empty_array_if_no_return_expectation.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/missing_with_is_replaced_by_empty_array_if_no_return_expectation2.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/mixed.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/mixed2.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/skip_different_method_expectations.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/skip_missing_return_expectation.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/skip_missing_with_if_return_expectations_exist.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/will_callbacks_are_kept.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/will_return_only.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/with_multiple_arguments.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/with_only.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/MigrateAtToConsecutiveExpectationsRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/RemoveEmptyTestMethodRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/RemoveEmptyTestMethodRector/RemoveEmptyTestMethodRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/TryCatchToExpectExceptionRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/TryCatchToExpectExceptionRector/Fixture/fixture2.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/ClassMethod/TryCatchToExpectExceptionRector/TryCatchToExpectExceptionRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/Class_/AddProphecyTraitRector/AddProphecyTraitRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/Class_/AddProphecyTraitRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/AddProphecyTraitRector/Fixture/skip_if_already_added.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/AddProphecyTraitRector/Fixture/skip_non_prophesize.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/AddSeeTestAnnotationRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Fixture/add_to_doc_block.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Fixture/remove_non_existing_see.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Fixture/skip_different_namespace.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Fixture/skip_existing.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Fixture/skip_simple_class_comment.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Fixture/surrounded_doc.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Source/DifferentNamespaceTest.php delete mode 100644 rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Source/SkipSimpleClassCommentTest.php delete mode 100644 rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Source/SomeExistingTest.php delete mode 100644 rules-tests/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector/ArrayArgumentToDataProviderRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector/Fixture/two_arguments.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector/Fixture/various_types.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector/config/configured_rule.php delete mode 100644 rules-tests/PHPUnit/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector/ConstructClassMethodToSetUpTestCaseRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector/Fixture/multiple_data_providers.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector/Fixture/with_test_annotation.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector/RemoveDataProviderTestPrefixRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/Class_/TestListenerToHooksRector/Fixture/before_list_hook.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/TestListenerToHooksRector/Fixture/clear_it_all.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Class_/TestListenerToHooksRector/TestListenerToHooksRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/Foreach_/SimplifyForeachInstanceOfRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/Foreach_/SimplifyForeachInstanceOfRector/SimplifyForeachInstanceOfRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector/AssertCompareToSpecificMethodRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/count.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/get_class.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertComparisonToSpecificMethodRector/AssertComparisonToSpecificMethodRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertComparisonToSpecificMethodRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/AssertEqualsParameterToSpecificMethodsTypeRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/combination.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/refactor_canonize.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/refactor_delta.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/refactor_ignore_case.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/remove_max_depth.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/AssertEqualsToSameRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/fixture_2.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/mark_test_incomplete.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/mark_test_skipped.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/skip.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/skip_2.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertFalseStrposToContainsRector/AssertFalseStrposToContainsRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertFalseStrposToContainsRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertFalseStrposToContainsRector/Fixture/skip_method_call.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertFalseStrposToContainsRector/Fixture/skip_static_call.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertInstanceOfComparisonRector/AssertInstanceOfComparisonRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertInstanceOfComparisonRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertIssetToSpecificMethodRector/AssertIssetToSpecificMethodRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertIssetToSpecificMethodRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertNotOperatorRector/AssertNotOperatorRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertNotOperatorRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/AssertPropertyExistsRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/Fixture/fixture2.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/Fixture/skip_method_call.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/Fixture/skip_static_call.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertRegExpRector/AssertRegExpRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertRegExpRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertResourceToClosedResourceRector/AssertResourceToClosedResourceRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertResourceToClosedResourceRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertResourceToClosedResourceRector/Fixture/fixture_2.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector/AssertSameBoolNullToSpecificMethodRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector/AssertSameTrueFalseToAssertTrueFalseRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector/Fixture/skip_already.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector/AssertTrueFalseInternalTypeToSpecificMethodRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector/Fixture/skip_assert_false_test.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector/Fixture/third_argument.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/AssertTrueFalseToSpecificMethodRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/fixture2.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/is_readable.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/skip_method_call.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/skip_static_call.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector/CreateMockToCreateStubRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector/Fixture/skip_non_phpunit.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector/Fixture/skip_sonata_expects.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector/Fixture/skip_with_expects.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector/DelegateExceptionArgumentsRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector/Fixture/message.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector/Fixture/regexp.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector/Fixture/self_nested.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/ExplicitPhpErrorApiRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/Fixture/php_deprecation.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/Fixture/php_error.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/Fixture/php_notice.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/Fixture/php_warning.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector/Fixture/get_mock_only.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector/GetMockBuilderGetMockToCreateMockRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/RemoveExpectAnyFromMockRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/RemoveExpectAnyFromMockRector/Fixture/keep.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/RemoveExpectAnyFromMockRector/RemoveExpectAnyFromMockRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector/ReplaceAssertArraySubsetWithDmsPolyfillRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/skip_iterable.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/skip_iterable_get.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/string_or_false.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/string_or_null.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/SpecificAssertContainsRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/Fixture/skip_partial_arguments.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/Fixture/skip_strings.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/Fixture/skip_with_identity_check.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/SpecificAssertContainsWithoutIdentityRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertInternalTypeRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertInternalTypeRector/SpecificAssertInternalTypeRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/UseSpecificWillMethodRector/Fixture/will.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/UseSpecificWillMethodRector/Fixture/with.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/UseSpecificWillMethodRector/UseSpecificWillMethodRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/WithConsecutiveArgToArrayRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/WithConsecutiveArgToArrayRector/Fixture/skip_already_array.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/WithConsecutiveArgToArrayRector/Source/ClassWithMethodOfTwoArguments.php delete mode 100644 rules-tests/PHPUnit/Rector/MethodCall/WithConsecutiveArgToArrayRector/WithConsecutiveArgToArrayRectorTest.php delete mode 100644 rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/Fixture/get_mock_multi.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/Fixture/skip_build_mock.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/Fixture/static_call.php.inc delete mode 100644 rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/GetMockRectorTest.php delete mode 100644 rules-tests/PHPUnit/TestClassResolver/Source/SeeSomeClass.php delete mode 100644 rules-tests/PHPUnit/TestClassResolver/Source/SeeSomeClassTest.php delete mode 100644 rules-tests/PHPUnit/TestClassResolver/TestClassResolverTest.php delete mode 100644 rules/PHPUnit/Composer/ComposerAutoloadedDirectoryProvider.php delete mode 100644 rules/PHPUnit/NodeAnalyzer/ExpectationAnalyzer.php delete mode 100644 rules/PHPUnit/NodeAnalyzer/TestsNodeAnalyzer.php delete mode 100644 rules/PHPUnit/NodeFactory/ArgumentShiftingFactory.php delete mode 100644 rules/PHPUnit/NodeFactory/AssertCallFactory.php delete mode 100644 rules/PHPUnit/NodeFactory/ConsecutiveAssertionFactory.php delete mode 100644 rules/PHPUnit/NodeFactory/DataProviderClassMethodFactory.php delete mode 100644 rules/PHPUnit/NodeFactory/ExpectExceptionCodeFactory.php delete mode 100644 rules/PHPUnit/NodeFactory/ExpectExceptionFactory.php delete mode 100644 rules/PHPUnit/NodeFactory/ExpectExceptionMessageFactory.php delete mode 100644 rules/PHPUnit/NodeFactory/ExpectExceptionMessageRegExpFactory.php delete mode 100644 rules/PHPUnit/NodeFactory/ExpectExceptionMethodCallFactory.php delete mode 100644 rules/PHPUnit/NodeFactory/SetUpClassMethodFactory.php delete mode 100644 rules/PHPUnit/NodeManipulator/ArgumentMover.php delete mode 100644 rules/PHPUnit/NodeManipulator/ParamAndArgFromArrayResolver.php delete mode 100644 rules/PHPUnit/NodeManipulator/SetUpClassMethodNodeManipulator.php delete mode 100644 rules/PHPUnit/NodeManipulator/StmtManipulator.php delete mode 100644 rules/PHPUnit/PhpDoc/PhpDocValueToNodeMapper.php delete mode 100644 rules/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector.php delete mode 100644 rules/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector.php delete mode 100644 rules/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector.php delete mode 100644 rules/PHPUnit/Rector/ClassMethod/RemoveEmptyTestMethodRector.php delete mode 100644 rules/PHPUnit/Rector/ClassMethod/TryCatchToExpectExceptionRector.php delete mode 100644 rules/PHPUnit/Rector/Class_/AddProphecyTraitRector.php delete mode 100644 rules/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector.php delete mode 100644 rules/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector.php delete mode 100644 rules/PHPUnit/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php delete mode 100644 rules/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector.php delete mode 100644 rules/PHPUnit/Rector/Class_/TestListenerToHooksRector.php delete mode 100644 rules/PHPUnit/Rector/Foreach_/SimplifyForeachInstanceOfRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/AssertComparisonToSpecificMethodRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/AssertFalseStrposToContainsRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/AssertInstanceOfComparisonRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/AssertIssetToSpecificMethodRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/AssertNotOperatorRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/AssertRegExpRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/AssertResourceToClosedResourceRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/RemoveExpectAnyFromMockRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/SpecificAssertInternalTypeRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/UseSpecificWillMethodRector.php delete mode 100644 rules/PHPUnit/Rector/MethodCall/WithConsecutiveArgToArrayRector.php delete mode 100644 rules/PHPUnit/Rector/StaticCall/GetMockRector.php delete mode 100644 rules/PHPUnit/TestClassResolver/PHPUnitTestCaseClassesProvider.php delete mode 100644 rules/PHPUnit/TestClassResolver/TestClassResolver.php delete mode 100644 rules/PHPUnit/ValueObject/ArrayArgumentToDataProvider.php delete mode 100644 rules/PHPUnit/ValueObject/BinaryOpWithAssertMethod.php delete mode 100644 rules/PHPUnit/ValueObject/ConstantWithAssertMethods.php delete mode 100644 rules/PHPUnit/ValueObject/DataProviderClassMethodRecipe.php delete mode 100644 rules/PHPUnit/ValueObject/ExpectationMock.php delete mode 100644 rules/PHPUnit/ValueObject/ExpectationMockCollection.php delete mode 100644 rules/PHPUnit/ValueObject/FunctionNameWithAssertMethods.php delete mode 100644 rules/PHPUnit/ValueObject/ParamAndArg.php delete mode 100644 stubs/PHPUnit/Framework/TestListener.php delete mode 100644 stubs/PHPUnit/PHPUnit_Framework_TestCase.php delete mode 100644 stubs/Prophecy/PhpUnit/ProphecyTrait.php diff --git a/composer.json b/composer.json index ba2a5168f72..00b8ff0ca19 100644 --- a/composer.json +++ b/composer.json @@ -44,6 +44,7 @@ "rector/rector-symfony": "dev-main", "rector/rector-nette": "dev-main", "rector/rector-laravel": "dev-main", + "rector/rector-phpunit": "dev-main", "sebastian/diff": "^4.0.4", "symfony/console": "^4.4.8|^5.1", "symfony/dependency-injection": "^5.1", diff --git a/config/config.php b/config/config.php index 54c1b7355e5..3e5af65c6c0 100644 --- a/config/config.php +++ b/config/config.php @@ -15,10 +15,12 @@ return static function (ContainerConfigurator $containerConfigurator): void { $containerConfigurator->import(__DIR__ . '/../vendor/rector/rector-symfony/config/config.php', null, 'not_found'); $containerConfigurator->import(__DIR__ . '/../vendor/rector/rector-nette/config/config.php', null, 'not_found'); $containerConfigurator->import(__DIR__ . '/../vendor/rector/rector-laravel/config/config.php', null, 'not_found'); + $containerConfigurator->import(__DIR__ . '/../vendor/rector/rector-phpunit/config/config.php', null, 'not_found'); // rector sub-package $containerConfigurator->import(__DIR__ . '/../../rector-symfony/config/config.php', null, 'not_found'); $containerConfigurator->import(__DIR__ . '/../../rector-nette/config/config.php', null, 'not_found'); $containerConfigurator->import(__DIR__ . '/../../rector-laravel/config/config.php', null, 'not_found'); + $containerConfigurator->import(__DIR__ . '/../../rector-phpunit/config/config.php', null, 'not_found'); // require only in dev $containerConfigurator->import(__DIR__ . '/../utils/compiler/config/config.php', null, 'not_found'); diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/AddDoesNotPerformAssertionToNonAssertingTestRectorTest.php b/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/AddDoesNotPerformAssertionToNonAssertingTestRectorTest.php deleted file mode 100644 index b06ca45b8fe..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/AddDoesNotPerformAssertionToNonAssertingTestRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AddDoesNotPerformAssertionToNonAssertingTestRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/fixture.php.inc deleted file mode 100644 index 35539607702..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,30 +0,0 @@ - ------ - diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/just_mocks_test.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/just_mocks_test.php.inc deleted file mode 100644 index 5de96e1c697..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/just_mocks_test.php.inc +++ /dev/null @@ -1,38 +0,0 @@ -expects()->isAllowed('yes', 'vote'); - } -} - -?> ------ -expects()->isAllowed('yes', 'vote'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_assert.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_assert.php.inc deleted file mode 100644 index 9088128e718..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_assert.php.inc +++ /dev/null @@ -1,18 +0,0 @@ -assertNotNull(5); - } - - public function testStatic() - { - $nothing = 5; - self::assertNotNull(5); - } -} diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_assert_in_call.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_assert_in_call.php.inc deleted file mode 100644 index dc472e13cab..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_assert_in_call.php.inc +++ /dev/null @@ -1,16 +0,0 @@ -doElsewhere(5); - } - - private function doElsewhere($value) - { - $this->assertNotNull($value); - } -} diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_assert_in_static_call.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_assert_in_static_call.php.inc deleted file mode 100644 index 52cd14f30e4..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_assert_in_static_call.php.inc +++ /dev/null @@ -1,18 +0,0 @@ -expectException('Throwable'); - throw new InvalidArgumentException(); - } - - public function testSetExpectedException() - { - $this->setExpectedException('Throwable'); - } -} diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_non_public.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_non_public.php.inc deleted file mode 100644 index c400f2ecf08..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_non_public.php.inc +++ /dev/null @@ -1,10 +0,0 @@ -doAssertThis(); - } -} diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_with_parent_method_static_assert.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_with_parent_method_static_assert.php.inc deleted file mode 100644 index 9c4b99fe021..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/keep_with_parent_method_static_assert.php.inc +++ /dev/null @@ -1,13 +0,0 @@ -doAssertThis(); - } -} diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/prophecy_assertions.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/prophecy_assertions.php.inc deleted file mode 100644 index f9e902c40ff..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/prophecy_assertions.php.inc +++ /dev/null @@ -1,58 +0,0 @@ -prophesize(DenormalizerInterface::class); - $denormalizer - ->denormalize($fixedData, $type) - ->shouldBeCalled(); - - (new Denormalizer($denormalizer))->handle($badData, $type); - } -} - -?> ------ -prophesize(DenormalizerInterface::class); - $denormalizer - ->denormalize($fixedData, $type) - ->shouldBeCalled(); - - (new Denormalizer($denormalizer))->handle($badData, $type); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/skip_existing_annotation.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/skip_existing_annotation.php.inc deleted file mode 100644 index 62f0236c52f..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/skip_existing_annotation.php.inc +++ /dev/null @@ -1,13 +0,0 @@ - ------ - diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Source/AbstractClassWithAssert.php b/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Source/AbstractClassWithAssert.php deleted file mode 100644 index ce903addae3..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Source/AbstractClassWithAssert.php +++ /dev/null @@ -1,20 +0,0 @@ -anotherMethod(); - } - - private function anotherMethod() - { - $this->assertTrue(true); - } -} diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Source/AbstractClassWithStaticAssert.php b/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Source/AbstractClassWithStaticAssert.php deleted file mode 100644 index feee053b42a..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Source/AbstractClassWithStaticAssert.php +++ /dev/null @@ -1,20 +0,0 @@ -denormalizer = $denormalizer; - } - - public function handle(array $data, string $type): ?array - { - try { - return $this->denormalizer->denormalize($data, $type); - } catch (\Throwable $throwable) { - return null; - } - } -} diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Source/DenormalizerInterface.php b/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Source/DenormalizerInterface.php deleted file mode 100644 index 94d31e8e3e1..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Source/DenormalizerInterface.php +++ /dev/null @@ -1,20 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return ExceptionAnnotationRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/constant_code.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/constant_code.php.inc deleted file mode 100644 index abeeca4b0bf..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/constant_code.php.inc +++ /dev/null @@ -1,35 +0,0 @@ - ------ -expectExceptionCode(SomeConstant::ERROR_CODE); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/fixture.php.inc deleted file mode 100644 index 27da457fa11..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,33 +0,0 @@ - ------ -expectException('FooException'); - // some code - - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/fixture2.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/fixture2.php.inc deleted file mode 100644 index 14ec01ba64d..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/fixture2.php.inc +++ /dev/null @@ -1,37 +0,0 @@ - ------ -expectException('Phpml\Exception\InvalidArgumentException'); - $this->expectExceptionMessage('Invalid operator "~=" provided'); - Comparison::compare(1, 1, '~='); - - // extra line - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/fixture3.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/fixture3.php.inc deleted file mode 100644 index 0bcd2469dfb..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/fixture3.php.inc +++ /dev/null @@ -1,29 +0,0 @@ - ------ -expectException(\Exception::class); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/fixture4.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/fixture4.php.inc deleted file mode 100644 index abe5a2879a4..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/fixture4.php.inc +++ /dev/null @@ -1,63 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Rector\Tests\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector\Fixture; - -use PHPUnit\Framework\TestCase; - -class ExceptionMessageTest extends TestCase -{ - /** - * @expectedException \Exception - */ - public function testLiteralMessage(): void - { - throw new \Exception('A literal exception message'); - } - - /** - * @expectedException \Exception - */ - public function testPartialMessageBegin(): void - { - throw new \Exception('A partial exception message'); - } -} - -?> ------ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Rector\Tests\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector\Fixture; - -use PHPUnit\Framework\TestCase; - -class ExceptionMessageTest extends TestCase -{ - public function testLiteralMessage(): void - { - $this->expectException(\Exception::class); - throw new \Exception('A literal exception message'); - } - - public function testPartialMessageBegin(): void - { - $this->expectException(\Exception::class); - throw new \Exception('A partial exception message'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/skip_method_with_null_php_doc.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/skip_method_with_null_php_doc.php.inc deleted file mode 100644 index 3dd8feb7375..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Fixture/skip_method_with_null_php_doc.php.inc +++ /dev/null @@ -1,21 +0,0 @@ -expectException('Exception'); - throw new \Exception('A literal exception message'); - } - - // test - - public function testPartialMessageBegin(): void - { - throw new \Exception('A partial exception message'); - } -} diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Source/SomeConstant.php b/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Source/SomeConstant.php deleted file mode 100644 index 01134c8bb62..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector/Source/SomeConstant.php +++ /dev/null @@ -1,13 +0,0 @@ -createMock(Foo::class); - $mock - ->expects($this->at(0)) - ->method('someMethod') - ->willReturn('1'); - $reference = '2'; - $mock - ->expects($this->at(1)) - ->method('someMethod') - ->willReturnReference($reference); - $mock - ->expects($this->at(2)) - ->method('someMethod') - ->willReturnMap(['foo' => 'bar']); - $mock - ->expects($this->at(3)) - ->method('someMethod') - ->willReturnArgument(1); - $mock - ->expects($this->at(4)) - ->method('someMethod') - ->willReturnCallback(static function () { - return null; - }); - $mock - ->expects($this->at(5)) - ->method('someMethod') - ->willReturnSelf(); - $mock - ->expects($this->at(6)) - ->method('someMethod') - ->willThrowException(new \Exception()); - } -} - -?> ------ -createMock(Foo::class); - $reference = '2'; - $mock->method('someMethod')->willReturnOnConsecutiveCalls('1', new \PHPUnit\Framework\MockObject\Stub\ReturnReference($reference), $this->returnValueMap(['foo' => 'bar']), $this->returnArgument(1), $this->returnCallback(static function () { - return null; - }), $this->returnSelf(), $this->throwException(new \Exception())); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/expects_non_at_is_skipped.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/expects_non_at_is_skipped.php.inc deleted file mode 100644 index 47827cd549e..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/expects_non_at_is_skipped.php.inc +++ /dev/null @@ -1,22 +0,0 @@ -createMock(Foo::class); - $mock - ->expects($this->exactly(1)) - ->method('someMethod'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/handle_multiple_variables.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/handle_multiple_variables.php.inc deleted file mode 100644 index 86d7566a452..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/handle_multiple_variables.php.inc +++ /dev/null @@ -1,65 +0,0 @@ -createMock(Foo::class); - $mock - ->expects($this->at(0)) - ->with('0') - ->method('someMethod') - ->willReturn('1'); - $mock - ->expects($this->at(1)) - ->with('1') - ->method('someMethod') - ->willReturn('2'); - - $mock2 = $this->createMock(Foo::class); - $mock2 - ->expects($this->at(0)) - ->with('0') - ->method('someMethod') - ->willReturn('1'); - $mock2 - ->expects($this->at(1)) - ->with('1') - ->method('someMethod') - ->willReturn('2'); - } -} - -?> ------ -createMock(Foo::class); - $mock->method('someMethod')->withConsecutive(['0'], ['1'])->willReturnOnConsecutiveCalls('1', '2'); - - $mock2 = $this->createMock(Foo::class); - $mock2->method('someMethod')->withConsecutive(['0'], ['1'])->willReturnOnConsecutiveCalls('1', '2'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/missing_with_is_replaced_by_empty_array_if_no_return_expectation.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/missing_with_is_replaced_by_empty_array_if_no_return_expectation.php.inc deleted file mode 100644 index d20cc5fd44b..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/missing_with_is_replaced_by_empty_array_if_no_return_expectation.php.inc +++ /dev/null @@ -1,48 +0,0 @@ -createMock(Foo::class); - $mock - ->expects($this->at(0)) - ->with('0') - ->method('someMethod'); - $mock - ->expects($this->at(2)) - ->with('2') - ->method('someMethod'); - } -} - -?> ------ -createMock(Foo::class); - $mock->method('someMethod')->withConsecutive(['0'], [], ['2']); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/missing_with_is_replaced_by_empty_array_if_no_return_expectation2.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/missing_with_is_replaced_by_empty_array_if_no_return_expectation2.php.inc deleted file mode 100644 index 2bcdf35fade..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/missing_with_is_replaced_by_empty_array_if_no_return_expectation2.php.inc +++ /dev/null @@ -1,48 +0,0 @@ -createMock(Foo::class); - $mock - ->expects($this->at(1)) - ->with('1') - ->method('someMethod'); - $mock - ->expects($this->at(2)) - ->with('2') - ->method('someMethod'); - } -} - -?> ------ -createMock(Foo::class); - $mock->method('someMethod')->withConsecutive([], ['1'], ['2']); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/mixed.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/mixed.php.inc deleted file mode 100644 index cd2f38a15a4..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/mixed.php.inc +++ /dev/null @@ -1,50 +0,0 @@ -createMock(Foo::class); - $mock - ->expects($this->at(0)) - ->with(0) - ->method('someMethod') - ->willReturn('0'); - $mock - ->expects($this->at(1)) - ->with(1) - ->method('someMethod') - ->willReturn('1'); - } -} - -?> ------ -createMock(Foo::class); - $mock->method('someMethod')->withConsecutive([0], [1])->willReturnOnConsecutiveCalls('0', '1'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/mixed2.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/mixed2.php.inc deleted file mode 100644 index 49bbb9c0bf6..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/mixed2.php.inc +++ /dev/null @@ -1,56 +0,0 @@ -createMock(Foo::class); - $mock - ->expects($this->exactly(2)) - ->method('someMethod'); - $mock - ->expects($this->at(0)) - ->with(0) - ->method('someMethod') - ->willReturn('0'); - $mock - ->expects($this->at(1)) - ->with(1) - ->method('someMethod') - ->willReturn('1'); - } -} - -?> ------ -createMock(Foo::class); - $mock - ->expects($this->exactly(2)) - ->method('someMethod'); - $mock->method('someMethod')->withConsecutive([0], [1])->willReturnOnConsecutiveCalls('0', '1'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/skip_different_method_expectations.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/skip_different_method_expectations.php.inc deleted file mode 100644 index 7d5b409c250..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/skip_different_method_expectations.php.inc +++ /dev/null @@ -1,39 +0,0 @@ -createMock(Foo::class); - $mock - ->expects($this->at(0)) - ->method('someMethod') - ->willReturn('1'); - - $mock - ->expects($this->at(1)) - ->with('1') - ->method('someOtherMethod'); - - $mock - ->expects($this->at(2)) - ->with('2') - ->method('someMethod') - ->willReturn('3'); - } -} - -?> - diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/skip_missing_return_expectation.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/skip_missing_return_expectation.php.inc deleted file mode 100644 index 625ae3a50b5..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/skip_missing_return_expectation.php.inc +++ /dev/null @@ -1,37 +0,0 @@ -createMock(Foo::class); - $mock - ->expects($this->at(0)) - ->method('someMethod') - ->willReturn('1'); - - $mock - ->expects($this->at(1)) - ->method('someMethod'); - - $mock - ->expects($this->at(2)) - ->method('someMethod') - ->willReturn('3'); - } -} - -?> - diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/skip_missing_with_if_return_expectations_exist.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/skip_missing_with_if_return_expectations_exist.php.inc deleted file mode 100644 index 00ce18bb2c7..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/skip_missing_with_if_return_expectations_exist.php.inc +++ /dev/null @@ -1,30 +0,0 @@ -createMock(Foo::class); - $mock - ->expects($this->at(0)) - ->with('0') - ->method('someMethod') - ->willReturn('1'); - - $mock - ->expects($this->at(2)) - ->with('2') - ->method('someMethod') - ->willReturn('3'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/will_callbacks_are_kept.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/will_callbacks_are_kept.php.inc deleted file mode 100644 index dbd9dca5c3c..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/will_callbacks_are_kept.php.inc +++ /dev/null @@ -1,48 +0,0 @@ -createMock(Foo::class); - $mock - ->expects($this->at(0)) - ->method('someMethod') - ->will($this->throwException(new \Exception())); - $mock - ->expects($this->at(1)) - ->method('someMethod') - ->will($this->returnValue('1')); - } -} - -?> ------ -createMock(Foo::class); - $mock->method('someMethod')->willReturnOnConsecutiveCalls($this->throwException(new \Exception()), $this->returnValue('1')); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/will_return_only.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/will_return_only.php.inc deleted file mode 100644 index 023685e2b01..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/will_return_only.php.inc +++ /dev/null @@ -1,56 +0,0 @@ -createMock(Foo::class); - $mock - ->expects($this->at(0)) - ->method('someMethod') - ->willReturn('0'); - $mock - ->expects($this->at(1)) - ->method('someMethod') - ->willReturn('1'); - $mock - ->expects($this->at(2)) - ->method('someMethod') - ->willReturn('2'); - $mock - ->expects($this->at(3)) - ->method('someMethod') - ->willReturn(null); - } -} - -?> ------ -createMock(Foo::class); - $mock->method('someMethod')->willReturnOnConsecutiveCalls('0', '1', '2', null); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/with_multiple_arguments.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/with_multiple_arguments.php.inc deleted file mode 100644 index 2f34f5ec489..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/with_multiple_arguments.php.inc +++ /dev/null @@ -1,44 +0,0 @@ -createMock(Foo::class); - $mock - ->expects($this->at(0)) - ->with('0', '1') - ->method('someMethod'); - } -} - -?> ------ -createMock(Foo::class); - $mock->method('someMethod')->withConsecutive(['0', '1']); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/with_only.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/with_only.php.inc deleted file mode 100644 index 10af8f36e91..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/Fixture/with_only.php.inc +++ /dev/null @@ -1,56 +0,0 @@ -createMock(Foo::class); - $mock - ->expects($this->at(0)) - ->with('0') - ->method('someMethod'); - $mock - ->expects($this->at(1)) - ->with('1') - ->method('someMethod'); - $mock - ->expects($this->at(2)) - ->with('2') - ->method('someMethod'); - $mock - ->expects($this->at(3)) - ->with(null) - ->method('someMethod'); - } -} - -?> ------ -createMock(Foo::class); - $mock->method('someMethod')->withConsecutive(['0'], ['1'], ['2'], [null]); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/MigrateAtToConsecutiveExpectationsRectorTest.php b/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/MigrateAtToConsecutiveExpectationsRectorTest.php deleted file mode 100644 index cd5f52aa47b..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector/MigrateAtToConsecutiveExpectationsRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return MigrateAtToConsecutiveExpectationsRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/RemoveEmptyTestMethodRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/RemoveEmptyTestMethodRector/Fixture/fixture.php.inc deleted file mode 100644 index 382a84ac0c7..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/RemoveEmptyTestMethodRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,27 +0,0 @@ - ------ - diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/RemoveEmptyTestMethodRector/RemoveEmptyTestMethodRectorTest.php b/rules-tests/PHPUnit/Rector/ClassMethod/RemoveEmptyTestMethodRector/RemoveEmptyTestMethodRectorTest.php deleted file mode 100644 index f2158e211ad..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/RemoveEmptyTestMethodRector/RemoveEmptyTestMethodRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return RemoveEmptyTestMethodRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/TryCatchToExpectExceptionRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/TryCatchToExpectExceptionRector/Fixture/fixture.php.inc deleted file mode 100644 index 71a811a4e7f..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/TryCatchToExpectExceptionRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,40 +0,0 @@ -run(); - } catch (Throwable $exception) { - $this->assertInstanceOf(RuntimeException::class, $exception); - $this->assertSame('There was an error executing the following script', $exception->getMessage()); - $this->assertContains('There was an error executing the following script', $exception->getMessage()); - } - } -} - -?> ------ -expectException(RuntimeException::class); - $this->expectExceptionMessage('There was an error executing the following script'); - $this->expectExceptionMessageRegExp('#There was an error executing the following script#'); - $someService->run(); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/TryCatchToExpectExceptionRector/Fixture/fixture2.php.inc b/rules-tests/PHPUnit/Rector/ClassMethod/TryCatchToExpectExceptionRector/Fixture/fixture2.php.inc deleted file mode 100644 index b4f25a72e29..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/TryCatchToExpectExceptionRector/Fixture/fixture2.php.inc +++ /dev/null @@ -1,38 +0,0 @@ -run(); - $someService->moreCalls(); - } catch (Throwable $exception) { - $this->assertSame(1000, $exception->getCode()); - $this->assertInstanceOf(RuntimeException::class, $exception); - $this->assertEquals('There was an error executing the following script', $exception->getMessage()); - } - } -} - -?> ------ -expectExceptionCode(1000); - $this->expectException(RuntimeException::class); - $this->expectExceptionMessage('There was an error executing the following script'); - $someService->run(); - $someService->moreCalls(); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/ClassMethod/TryCatchToExpectExceptionRector/TryCatchToExpectExceptionRectorTest.php b/rules-tests/PHPUnit/Rector/ClassMethod/TryCatchToExpectExceptionRector/TryCatchToExpectExceptionRectorTest.php deleted file mode 100644 index 54761d7ec90..00000000000 --- a/rules-tests/PHPUnit/Rector/ClassMethod/TryCatchToExpectExceptionRector/TryCatchToExpectExceptionRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return TryCatchToExpectExceptionRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/Class_/AddProphecyTraitRector/AddProphecyTraitRectorTest.php b/rules-tests/PHPUnit/Rector/Class_/AddProphecyTraitRector/AddProphecyTraitRectorTest.php deleted file mode 100644 index c02dd3f600b..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/AddProphecyTraitRector/AddProphecyTraitRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AddProphecyTraitRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/Class_/AddProphecyTraitRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/Class_/AddProphecyTraitRector/Fixture/fixture.php.inc deleted file mode 100644 index 0aa5b357ebf..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/AddProphecyTraitRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,32 +0,0 @@ -prophesize(\AnInterface::class); - } -} - -?> ------ -prophesize(\AnInterface::class); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/Class_/AddProphecyTraitRector/Fixture/skip_if_already_added.php.inc b/rules-tests/PHPUnit/Rector/Class_/AddProphecyTraitRector/Fixture/skip_if_already_added.php.inc deleted file mode 100644 index c399e8fe838..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/AddProphecyTraitRector/Fixture/skip_if_already_added.php.inc +++ /dev/null @@ -1,16 +0,0 @@ -prophesize(\AnInterface::class); - } -} diff --git a/rules-tests/PHPUnit/Rector/Class_/AddProphecyTraitRector/Fixture/skip_non_prophesize.php.inc b/rules-tests/PHPUnit/Rector/Class_/AddProphecyTraitRector/Fixture/skip_non_prophesize.php.inc deleted file mode 100644 index 5b489ceb5fb..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/AddProphecyTraitRector/Fixture/skip_non_prophesize.php.inc +++ /dev/null @@ -1,15 +0,0 @@ -prophesize(\AnInterface::class); - } -} diff --git a/rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/AddSeeTestAnnotationRectorTest.php b/rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/AddSeeTestAnnotationRectorTest.php deleted file mode 100644 index 3a87ab0e942..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/AddSeeTestAnnotationRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AddSeeTestAnnotationRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Fixture/add_to_doc_block.php.inc b/rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Fixture/add_to_doc_block.php.inc deleted file mode 100644 index e0cb7a2ec69..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Fixture/add_to_doc_block.php.inc +++ /dev/null @@ -1,34 +0,0 @@ - ------ - diff --git a/rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Fixture/remove_non_existing_see.php.inc b/rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Fixture/remove_non_existing_see.php.inc deleted file mode 100644 index e339a02093a..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Fixture/remove_non_existing_see.php.inc +++ /dev/null @@ -1,33 +0,0 @@ - ------ - diff --git a/rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Fixture/skip_different_namespace.php.inc b/rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Fixture/skip_different_namespace.php.inc deleted file mode 100644 index 3a403f29536..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Fixture/skip_different_namespace.php.inc +++ /dev/null @@ -1,10 +0,0 @@ - ------ - diff --git a/rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Source/DifferentNamespaceTest.php b/rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Source/DifferentNamespaceTest.php deleted file mode 100644 index 65ea743d7b9..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector/Source/DifferentNamespaceTest.php +++ /dev/null @@ -1,10 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function provideConfigFilePath(): string - { - return __DIR__ . '/config/configured_rule.php'; - } -} diff --git a/rules-tests/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector/Fixture/fixture.php.inc deleted file mode 100644 index 6fdbb0d0351..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,36 +0,0 @@ -doTestMultiple([1, 2, 3]); - } -} - -?> ------ -doTestSingle($variable); - } - public function provideDataForTest(): \Iterator - { - yield [1]; - yield [2]; - yield [3]; - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector/Fixture/two_arguments.php.inc b/rules-tests/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector/Fixture/two_arguments.php.inc deleted file mode 100644 index fd6bb00a531..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector/Fixture/two_arguments.php.inc +++ /dev/null @@ -1,34 +0,0 @@ -doTestMultiple([['before', 'after']]); - } -} - -?> ------ -doTestSingle($variable, $variable2); - } - public function provideDataForTest(): \Iterator - { - yield [['before', 'after']]; - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector/Fixture/various_types.php.inc b/rules-tests/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector/Fixture/various_types.php.inc deleted file mode 100644 index f4f8fbb3a91..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector/Fixture/various_types.php.inc +++ /dev/null @@ -1,37 +0,0 @@ -doTestMultiple([1, '2', 3.5]); - } -} - -?> ------ -doTestSingle($variable); - } - public function provideDataForTest(): \Iterator - { - yield [1]; - yield ['2']; - yield [3.5]; - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector/config/configured_rule.php b/rules-tests/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector/config/configured_rule.php deleted file mode 100644 index 799c4b90b76..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector/config/configured_rule.php +++ /dev/null @@ -1,22 +0,0 @@ -services(); - - $services->set(ArrayArgumentToDataProviderRector::class) - ->call('configure', [[ - ArrayArgumentToDataProviderRector::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS => ValueObjectInliner::inline([ - new ArrayArgumentToDataProvider( - 'PHPUnit\Framework\TestCase', - 'doTestMultiple', - 'doTestSingle', - 'variable' - ), - ]), - ]]); -}; diff --git a/rules-tests/PHPUnit/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector/ConstructClassMethodToSetUpTestCaseRectorTest.php b/rules-tests/PHPUnit/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector/ConstructClassMethodToSetUpTestCaseRectorTest.php deleted file mode 100644 index dca19ae19e4..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector/ConstructClassMethodToSetUpTestCaseRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return ConstructClassMethodToSetUpTestCaseRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector/Fixture/fixture.php.inc deleted file mode 100644 index cb14a3404e0..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,36 +0,0 @@ -someValue = 1000; - parent::__construct($name, $data, $dataName); - } -} - -?> ------ -someValue = 1000; - } - private $someValue; -} - -?> diff --git a/rules-tests/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector/Fixture/fixture.php.inc deleted file mode 100644 index d4b85dd4f6d..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,43 +0,0 @@ - ------ - diff --git a/rules-tests/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector/Fixture/multiple_data_providers.php.inc b/rules-tests/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector/Fixture/multiple_data_providers.php.inc deleted file mode 100644 index c0730aae409..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector/Fixture/multiple_data_providers.php.inc +++ /dev/null @@ -1,67 +0,0 @@ - ------ - diff --git a/rules-tests/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector/Fixture/with_test_annotation.php.inc b/rules-tests/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector/Fixture/with_test_annotation.php.inc deleted file mode 100644 index bf4817c4dd6..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector/Fixture/with_test_annotation.php.inc +++ /dev/null @@ -1,45 +0,0 @@ - ------ - diff --git a/rules-tests/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector/RemoveDataProviderTestPrefixRectorTest.php b/rules-tests/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector/RemoveDataProviderTestPrefixRectorTest.php deleted file mode 100644 index dc9e3053d75..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector/RemoveDataProviderTestPrefixRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return RemoveDataProviderTestPrefixRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/Class_/TestListenerToHooksRector/Fixture/before_list_hook.php.inc b/rules-tests/PHPUnit/Rector/Class_/TestListenerToHooksRector/Fixture/before_list_hook.php.inc deleted file mode 100644 index cb4fe56faca..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/TestListenerToHooksRector/Fixture/before_list_hook.php.inc +++ /dev/null @@ -1,82 +0,0 @@ - ------ - diff --git a/rules-tests/PHPUnit/Rector/Class_/TestListenerToHooksRector/Fixture/clear_it_all.php.inc b/rules-tests/PHPUnit/Rector/Class_/TestListenerToHooksRector/Fixture/clear_it_all.php.inc deleted file mode 100644 index 6a8ae85ef50..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/TestListenerToHooksRector/Fixture/clear_it_all.php.inc +++ /dev/null @@ -1,70 +0,0 @@ - ------ - diff --git a/rules-tests/PHPUnit/Rector/Class_/TestListenerToHooksRector/TestListenerToHooksRectorTest.php b/rules-tests/PHPUnit/Rector/Class_/TestListenerToHooksRector/TestListenerToHooksRectorTest.php deleted file mode 100644 index 751b30bf198..00000000000 --- a/rules-tests/PHPUnit/Rector/Class_/TestListenerToHooksRector/TestListenerToHooksRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return TestListenerToHooksRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/Foreach_/SimplifyForeachInstanceOfRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/Foreach_/SimplifyForeachInstanceOfRector/Fixture/fixture.php.inc deleted file mode 100644 index 34d646200dc..00000000000 --- a/rules-tests/PHPUnit/Rector/Foreach_/SimplifyForeachInstanceOfRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,49 +0,0 @@ -assertInstanceOf(\SplFileInfo::class, $foo); - } - - foreach ($foos as $foo) { - self::assertInstanceOf(\SplFileInfo::class, $foo); - } - - foreach ($foos as $bar => $foo) { - $this->assertInstanceOf(\SplFileInfo::class, $bar); - } - - foreach ($foos as $foo) { - $this->assertInstanceOf(\SplFileInfo::class, $foos); - } - } -} - -?> ------ -assertContainsOnlyInstancesOf(\SplFileInfo::class, $foos); - - self::assertContainsOnlyInstancesOf(\SplFileInfo::class, $foos); - - foreach ($foos as $bar => $foo) { - $this->assertInstanceOf(\SplFileInfo::class, $bar); - } - - foreach ($foos as $foo) { - $this->assertInstanceOf(\SplFileInfo::class, $foos); - } - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/Foreach_/SimplifyForeachInstanceOfRector/SimplifyForeachInstanceOfRectorTest.php b/rules-tests/PHPUnit/Rector/Foreach_/SimplifyForeachInstanceOfRector/SimplifyForeachInstanceOfRectorTest.php deleted file mode 100644 index 5032a602cec..00000000000 --- a/rules-tests/PHPUnit/Rector/Foreach_/SimplifyForeachInstanceOfRector/SimplifyForeachInstanceOfRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return SimplifyForeachInstanceOfRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector/AssertCompareToSpecificMethodRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector/AssertCompareToSpecificMethodRectorTest.php deleted file mode 100644 index 4f41dacb280..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector/AssertCompareToSpecificMethodRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AssertCompareToSpecificMethodRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/count.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/count.php.inc deleted file mode 100644 index e064db97d57..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/count.php.inc +++ /dev/null @@ -1,35 +0,0 @@ -assertSame(5, count($something)); - $this->assertEquals(10, iterator_count($something)); - - $count = 92; - $this->assertNotEquals($count, sizeof($something), 'third argument'); - } -} - -?> ------ -assertCount(5, $something); - $this->assertCount(10, $something); - - $count = 92; - $this->assertNotCount($count, $something, 'third argument'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/fixture.php.inc deleted file mode 100644 index a5f7fb00954..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,37 +0,0 @@ -assertEquals('string', gettype($something)); - $this->assertEquals('string', $something['property']()); - $this->assertNotSame($foo[1]->result, count($this->results)); - $this->assertSame(1, $count); - $this->assertNotSame(2, $foo->count()); - $this->assertEquals($count, $foo->sizeof); - } -} - -?> ------ -assertInternalType('string', $something); - $this->assertEquals('string', $something['property']()); - $this->assertNotCount($foo[1]->result, $this->results); - $this->assertSame(1, $count); - $this->assertNotSame(2, $foo->count()); - $this->assertEquals($count, $foo->sizeof); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/get_class.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/get_class.php.inc deleted file mode 100644 index 6c96a81b825..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/get_class.php.inc +++ /dev/null @@ -1,35 +0,0 @@ -assertSame(get_class($something), 'stdClass'); - self::assertSame('stdClass', get_class($something)); - } -} - -?> ------ -assertInstanceOf('stdClass', $something); - self::assertInstanceOf('stdClass', $something); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertComparisonToSpecificMethodRector/AssertComparisonToSpecificMethodRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/AssertComparisonToSpecificMethodRector/AssertComparisonToSpecificMethodRectorTest.php deleted file mode 100644 index 465330a06b4..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertComparisonToSpecificMethodRector/AssertComparisonToSpecificMethodRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AssertComparisonToSpecificMethodRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertComparisonToSpecificMethodRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertComparisonToSpecificMethodRector/Fixture/fixture.php.inc deleted file mode 100644 index 3c8d2c0cdd7..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertComparisonToSpecificMethodRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,41 +0,0 @@ -assertFalse($expected === $anything); - $this->assertTrue(count($something) > 2); - $this->assertTrue($something[0]['foo'] > $something[1]['foo']); - $this->assertTrue(__DIR__ <> $something, 'message'); - $this->assertTrue(1.0 === $something); - $this->assertFalse(true === in_array('foo', ['bar', 'baz'], true)); - $this->assertTrue('string' != gettype($foo)); - $this->assertTrue(['foo', 'bar'] == $something); - } -} - -?> ------ -assertNotSame($expected, $anything); - $this->assertGreaterThan(2, count($something)); - $this->assertGreaterThan($something[1]['foo'], $something[0]['foo']); - $this->assertNotEquals(__DIR__, $something, 'message'); - $this->assertSame(1.0, $something); - $this->assertNotSame(true, in_array('foo', ['bar', 'baz'], true)); - $this->assertNotEquals('string', gettype($foo)); - $this->assertEquals(['foo', 'bar'], $something); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/AssertEqualsParameterToSpecificMethodsTypeRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/AssertEqualsParameterToSpecificMethodsTypeRectorTest.php deleted file mode 100644 index 71b1c351eb0..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/AssertEqualsParameterToSpecificMethodsTypeRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AssertEqualsParameterToSpecificMethodsTypeRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/combination.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/combination.php.inc deleted file mode 100644 index 488def8f302..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/combination.php.inc +++ /dev/null @@ -1,42 +0,0 @@ -assertEquals('string', $value, 'message', 100.0, 50, true, true); - } -} - -?> ------ -assertEquals('string', $value, 'message'); - $this->assertEqualsIgnoringCase('string', $value, 'message'); - $this->assertEqualsCanonicalizing('string', $value, 'message'); - $this->assertEqualsWithDelta('string', $value, 100.0, 'message'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/refactor_canonize.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/refactor_canonize.php.inc deleted file mode 100644 index 1aaf694ae08..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/refactor_canonize.php.inc +++ /dev/null @@ -1,36 +0,0 @@ -assertEquals('string', $value, 'message', 0.0, 10, true); - } -} - -?> ------ -assertEquals('string', $value, 'message'); - $this->assertEqualsCanonicalizing('string', $value, 'message'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/refactor_delta.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/refactor_delta.php.inc deleted file mode 100644 index a3a13bd748d..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/refactor_delta.php.inc +++ /dev/null @@ -1,45 +0,0 @@ -assertEquals('string', $value, 'message', 5.0); - - $this->assertEquals('string', $value, 'message', 0.0); - - $this->assertEquals('string', $value, 'message', 20.0); - } -} - -?> ------ -assertEquals('string', $value, 'message'); - $this->assertEqualsWithDelta('string', $value, 5.0, 'message'); - - $this->assertEquals('string', $value, 'message'); - - $this->assertEquals('string', $value, 'message'); - $this->assertEqualsWithDelta('string', $value, 20.0, 'message'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/refactor_ignore_case.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/refactor_ignore_case.php.inc deleted file mode 100644 index 39691a25549..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/refactor_ignore_case.php.inc +++ /dev/null @@ -1,36 +0,0 @@ -assertEquals('string', $value, 'message', 0.0, 10, false, true); - } -} - -?> ------ -assertEquals('string', $value, 'message'); - $this->assertEqualsIgnoringCase('string', $value, 'message'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/remove_max_depth.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/remove_max_depth.php.inc deleted file mode 100644 index 1cda9028aeb..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector/Fixture/remove_max_depth.php.inc +++ /dev/null @@ -1,33 +0,0 @@ -assertEquals('string', $value, 'message', 0.0, 20); - } -} - -?> ------ -assertEquals('string', $value, 'message'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/AssertEqualsToSameRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/AssertEqualsToSameRectorTest.php deleted file mode 100644 index 52c4bcd0846..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/AssertEqualsToSameRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AssertEqualsToSameRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/fixture.php.inc deleted file mode 100644 index 686e10a1f49..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,51 +0,0 @@ -assertEquals($expectedInt, $int); - - $float = 1.1; - $expectedFloat = 1.1; - $this->assertEquals($expectedFloat, $float); - - $string = 'abc'; - $expectedString = 'abc'; - $this->assertEquals($expectedString, $string); - } -} - -?> ------ -assertSame($expectedInt, $int); - - $float = 1.1; - $expectedFloat = 1.1; - $this->assertSame($expectedFloat, $float); - - $string = 'abc'; - $expectedString = 'abc'; - $this->assertSame($expectedString, $string); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/fixture_2.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/fixture_2.php.inc deleted file mode 100644 index 65084984fb7..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/fixture_2.php.inc +++ /dev/null @@ -1,51 +0,0 @@ - ------ - diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/mark_test_incomplete.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/mark_test_incomplete.php.inc deleted file mode 100644 index a751b31d461..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/mark_test_incomplete.php.inc +++ /dev/null @@ -1,39 +0,0 @@ -markTestIncomplete('incomplete'); - - $this->assertEquals('foo', 'foo'); - $this->assertEquals(123, 123); - $this->assertEquals(1.23, 1.23); - } -} - -?> ------ -markTestIncomplete('incomplete'); - - $this->assertSame('foo', 'foo'); - $this->assertSame(123, 123); - $this->assertSame(1.23, 1.23); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/mark_test_skipped.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/mark_test_skipped.php.inc deleted file mode 100644 index 7244fb044e5..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/mark_test_skipped.php.inc +++ /dev/null @@ -1,37 +0,0 @@ -markTestSkipped('skipped'); - $this->assertEquals('foo', 'foo'); - $this->assertEquals(123, 123); - $this->assertEquals(1.23, 1.23); - } -} - -?> ------ -markTestSkipped('skipped'); - $this->assertSame('foo', 'foo'); - $this->assertSame(123, 123); - $this->assertSame(1.23, 1.23); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/skip.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/skip.php.inc deleted file mode 100644 index dc914d30407..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/skip.php.inc +++ /dev/null @@ -1,23 +0,0 @@ -assertEquals($expectedNull, $null); - - $bool = true; - $expectedBool = true; - $this->assertEquals($expectedBool, $bool); - - $array = []; - $expectedArray = []; - $this->assertEquals($expectedArray, $array); - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/skip_2.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/skip_2.php.inc deleted file mode 100644 index 25ab58fb09f..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector/Fixture/skip_2.php.inc +++ /dev/null @@ -1,23 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AssertFalseStrposToContainsRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertFalseStrposToContainsRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertFalseStrposToContainsRector/Fixture/fixture.php.inc deleted file mode 100644 index af522e1d8c7..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertFalseStrposToContainsRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,29 +0,0 @@ -assertNotFalse(strpos($node, 'foo')); - $this->assertFalse(stripos($node, 'foo'), 'message'); - } -} - -?> ------ -assertContains('foo', $node); - $this->assertNotContains('foo', $node, 'message'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertFalseStrposToContainsRector/Fixture/skip_method_call.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertFalseStrposToContainsRector/Fixture/skip_method_call.php.inc deleted file mode 100644 index 9ae85d0c94b..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertFalseStrposToContainsRector/Fixture/skip_method_call.php.inc +++ /dev/null @@ -1,12 +0,0 @@ -someMethod()); - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertFalseStrposToContainsRector/Fixture/skip_static_call.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertFalseStrposToContainsRector/Fixture/skip_static_call.php.inc deleted file mode 100644 index 301e24db8d4..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertFalseStrposToContainsRector/Fixture/skip_static_call.php.inc +++ /dev/null @@ -1,11 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AssertInstanceOfComparisonRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertInstanceOfComparisonRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertInstanceOfComparisonRector/Fixture/fixture.php.inc deleted file mode 100644 index 8b3926032af..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertInstanceOfComparisonRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,35 +0,0 @@ -assertTrue($something instanceof Foo); - $this->assertFalse($something instanceof \Namespaced\Foo); - $this->assertTrue($something instanceof Bar\Baz); - } -} - -?> ------ -assertInstanceOf(\Rector\Tests\PHPUnit\Rector\MethodCall\AssertInstanceOfComparisonRector\Fixture\Foo::class, $something); - $this->assertNotInstanceOf(\Namespaced\Foo::class, $something); - $this->assertInstanceOf(\Foo\Bar\Baz::class, $something); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertIssetToSpecificMethodRector/AssertIssetToSpecificMethodRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/AssertIssetToSpecificMethodRector/AssertIssetToSpecificMethodRectorTest.php deleted file mode 100644 index 9d638908da7..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertIssetToSpecificMethodRector/AssertIssetToSpecificMethodRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AssertIssetToSpecificMethodRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertIssetToSpecificMethodRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertIssetToSpecificMethodRector/Fixture/fixture.php.inc deleted file mode 100644 index 7cc45fdf7a4..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertIssetToSpecificMethodRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,33 +0,0 @@ -assertTrue(isset($node->value1)); - $this->assertFalse(isset($node->value2), 'message'); - $this->assertTrue(isset($node['value1']), 'message'); - $this->assertFalse(isset($node['value2'])); - } -} - -?> ------ -assertObjectHasAttribute('value1', $node); - $this->assertObjectNotHasAttribute('value2', $node, 'message'); - $this->assertArrayHasKey('value1', $node, 'message'); - $this->assertArrayNotHasKey('value2', $node); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertNotOperatorRector/AssertNotOperatorRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/AssertNotOperatorRector/AssertNotOperatorRectorTest.php deleted file mode 100644 index f7fe476a6ba..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertNotOperatorRector/AssertNotOperatorRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AssertNotOperatorRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertNotOperatorRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertNotOperatorRector/Fixture/fixture.php.inc deleted file mode 100644 index 9876342f242..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertNotOperatorRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,31 +0,0 @@ -assertFalse(! ($something === false)); - $this->assertTrue(! $something); - self::assertTrue(! $something); - } -} - -?> ------ -assertTrue($something === false); - $this->assertFalse($something); - self::assertFalse($something); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/AssertPropertyExistsRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/AssertPropertyExistsRectorTest.php deleted file mode 100644 index 4ee37e61fd0..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/AssertPropertyExistsRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AssertPropertyExistsRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/Fixture/fixture.php.inc deleted file mode 100644 index d8407c5689b..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,33 +0,0 @@ -assertTrue(property_exists(new \stdClass(), 'property')); - $this->assertFalse(property_exists(new \Namespaced\stdClass, 'property'), 'message'); - } -} - -?> ------ -assertClassHasAttribute('property', 'stdClass'); - $this->assertClassNotHasAttribute('property', 'Namespaced\stdClass', 'message'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/Fixture/fixture2.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/Fixture/fixture2.php.inc deleted file mode 100644 index ad9f92e1572..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/Fixture/fixture2.php.inc +++ /dev/null @@ -1,29 +0,0 @@ -assertFalse(property_exists($response, 'property')); - } -} - -?> ------ -assertObjectNotHasAttribute('property', $response); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/Fixture/skip_method_call.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/Fixture/skip_method_call.php.inc deleted file mode 100644 index 2c88b818d9d..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/Fixture/skip_method_call.php.inc +++ /dev/null @@ -1,12 +0,0 @@ -someMethod()); - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/Fixture/skip_static_call.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/Fixture/skip_static_call.php.inc deleted file mode 100644 index 64d5318bf63..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector/Fixture/skip_static_call.php.inc +++ /dev/null @@ -1,11 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AssertRegExpRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertRegExpRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertRegExpRector/Fixture/fixture.php.inc deleted file mode 100644 index 563da2850bc..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertRegExpRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,33 +0,0 @@ -assertSame(1, preg_match('/^Message for ".*"\.$/', $string), $message); - $this->assertEquals(false, preg_match('/^Message for ".*"\.$/', $string), $message); - $this->assertNotEquals(true, preg_match('/^Message for ".*"\.$/', $string, $matches), $message); - $this->assertNotSame(0, preg_match('/^Message for ".*"\.$/', $string), $message); - } -} - -?> ------ -assertRegExp('/^Message for ".*"\.$/', $string, $message); - $this->assertNotRegExp('/^Message for ".*"\.$/', $string, $message); - $this->assertNotRegExp('/^Message for ".*"\.$/', $string, $message); - $this->assertRegExp('/^Message for ".*"\.$/', $string, $message); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertResourceToClosedResourceRector/AssertResourceToClosedResourceRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/AssertResourceToClosedResourceRector/AssertResourceToClosedResourceRectorTest.php deleted file mode 100644 index e762ce8abbe..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertResourceToClosedResourceRector/AssertResourceToClosedResourceRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AssertResourceToClosedResourceRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertResourceToClosedResourceRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertResourceToClosedResourceRector/Fixture/fixture.php.inc deleted file mode 100644 index 996ecb2cd5b..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertResourceToClosedResourceRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,35 +0,0 @@ -assertIsResource($handler); - - fclose($handler); - $this->assertIsNotResource($handler); - } -} - -?> ------ -assertIsResource($handler); - - fclose($handler); - $this->assertIsClosedResource($handler); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertResourceToClosedResourceRector/Fixture/fixture_2.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertResourceToClosedResourceRector/Fixture/fixture_2.php.inc deleted file mode 100644 index 33b54368014..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertResourceToClosedResourceRector/Fixture/fixture_2.php.inc +++ /dev/null @@ -1,35 +0,0 @@ - ------ - diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector/AssertSameBoolNullToSpecificMethodRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector/AssertSameBoolNullToSpecificMethodRectorTest.php deleted file mode 100644 index 203a64610f3..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector/AssertSameBoolNullToSpecificMethodRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AssertSameBoolNullToSpecificMethodRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector/Fixture/fixture.php.inc deleted file mode 100644 index 9c452ee6b12..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,29 +0,0 @@ -assertSame(NULL, 'something'); - $this->assertNotSame(false, 'something', 'message'); - } -} - -?> ------ -assertNull('something'); - $this->assertNotFalse('something', 'message'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector/AssertSameTrueFalseToAssertTrueFalseRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector/AssertSameTrueFalseToAssertTrueFalseRectorTest.php deleted file mode 100644 index 71a5b7fd1a8..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector/AssertSameTrueFalseToAssertTrueFalseRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AssertSameTrueFalseToAssertTrueFalseRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector/Fixture/fixture.php.inc deleted file mode 100644 index 34dd79207c1..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,33 +0,0 @@ -assertSame(true, $value); - } -} - -?> ------ -assertTrue($value); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector/Fixture/skip_already.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector/Fixture/skip_already.php.inc deleted file mode 100644 index 7044f5dd9fc..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector/Fixture/skip_already.php.inc +++ /dev/null @@ -1,14 +0,0 @@ -assertTrue($value); - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector/AssertTrueFalseInternalTypeToSpecificMethodRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector/AssertTrueFalseInternalTypeToSpecificMethodRectorTest.php deleted file mode 100644 index 2b80c929b69..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector/AssertTrueFalseInternalTypeToSpecificMethodRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AssertTrueFalseInternalTypeToSpecificMethodRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector/Fixture/fixture.php.inc deleted file mode 100644 index 10d37fafdba..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,29 +0,0 @@ -assertTrue(\is_string($something)); - $this->assertFalse(\is_array($something)); - } -} - -?> ------ -assertInternalType('string', $something); - $this->assertNotInternalType('array', $something); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector/Fixture/skip_assert_false_test.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector/Fixture/skip_assert_false_test.php.inc deleted file mode 100644 index ad671f955eb..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector/Fixture/skip_assert_false_test.php.inc +++ /dev/null @@ -1,15 +0,0 @@ -someMethod()); - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector/Fixture/third_argument.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector/Fixture/third_argument.php.inc deleted file mode 100644 index bb2a980d683..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector/Fixture/third_argument.php.inc +++ /dev/null @@ -1,35 +0,0 @@ -assertTrue(is_integer($something), 'third argument'); - $this->assertFalse(is_bool($something), 'third argument'); - - $this->assertTrue(is_file($something)); - $this->assertFalse(is_null($something), 'second argument'); - } -} - -?> ------ -assertInternalType('integer', $something, 'third argument'); - $this->assertNotInternalType('bool', $something, 'third argument'); - - $this->assertTrue(is_file($something)); - $this->assertFalse(is_null($something), 'second argument'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/AssertTrueFalseToSpecificMethodRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/AssertTrueFalseToSpecificMethodRectorTest.php deleted file mode 100644 index b058adc88cb..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/AssertTrueFalseToSpecificMethodRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return AssertTrueFalseToSpecificMethodRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/fixture.php.inc deleted file mode 100644 index b98113e388c..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,61 +0,0 @@ -assertTrue(array_key_exists('...', ['...']), 'argument'); - $this->assertTrue(in_array('...', ['...'], true), 'argument'); - - $this->assertFalse(is_readable('...')); - $this->assertTrue(empty('...')); - $this->assertFalse(file_exists('...')); - $this->assertTrue(is_dir('...')); - $this->assertFalse(is_infinite('...')); - $this->assertTrue(is_nan('...')); - $this->assertFalse(is_null('...')); - $this->assertTrue(is_writable('...')); - $this->assertFalse(array_search('...', ['...']), 'argument'); - $this->assertTrue(is_a($anything, 'Foo'), 'argument'); - $this->assertFalse(is_a($anything, Foo::class, true), 'argument'); - } -} - -?> ------ -assertArrayHasKey('...', ['...'], 'argument'); - $this->assertContains('...', ['...'], 'argument'); - - $this->assertNotIsReadable('...'); - $this->assertEmpty('...'); - $this->assertFileNotExists('...'); - $this->assertDirectoryExists('...'); - $this->assertFinite('...'); - $this->assertNan('...'); - $this->assertNotNull('...'); - $this->assertIsWritable('...'); - $this->assertNotContains('...', ['...'], 'argument'); - $this->assertInstanceOf('Foo', $anything, 'argument'); - $this->assertNotInstanceOf(Foo::class, $anything, 'argument'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/fixture2.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/fixture2.php.inc deleted file mode 100644 index 65a3e499c5f..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/fixture2.php.inc +++ /dev/null @@ -1,33 +0,0 @@ -assertTrue(\array_search($foo, $this->bar->toArray())); - $this->assertNotFalse(\array_search($foo, $this->bar->toArray())); - } -} - -?> ------ -assertContains($foo, $this->bar->toArray()); - $this->assertContains($foo, $this->bar->toArray()); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/is_readable.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/is_readable.php.inc deleted file mode 100644 index 77d7dc4bca5..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/is_readable.php.inc +++ /dev/null @@ -1,31 +0,0 @@ -assertTrue(is_readable($readmeFile), sprintf('Cannot read "%s".', $readmeFile)); - } -} - -?> ------ -assertIsReadable($readmeFile, sprintf('Cannot read "%s".', $readmeFile)); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/skip_method_call.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/skip_method_call.php.inc deleted file mode 100644 index d5e0ada521e..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/skip_method_call.php.inc +++ /dev/null @@ -1,12 +0,0 @@ -someMethod()); - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/skip_static_call.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/skip_static_call.php.inc deleted file mode 100644 index 7bef60b47a0..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector/Fixture/skip_static_call.php.inc +++ /dev/null @@ -1,11 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return CreateMockToCreateStubRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector/Fixture/fixture.php.inc deleted file mode 100644 index 9cc4a0f3050..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,35 +0,0 @@ -createMock(\Exception::class); - $stub->method('getMessage') - ->willReturn('a message'); - } -} - -?> ------ -createStub(\Exception::class); - $stub->method('getMessage') - ->willReturn('a message'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector/Fixture/skip_non_phpunit.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector/Fixture/skip_non_phpunit.php.inc deleted file mode 100644 index 71f57f7297c..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector/Fixture/skip_non_phpunit.php.inc +++ /dev/null @@ -1,11 +0,0 @@ -createMock(\Exception::class); - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector/Fixture/skip_sonata_expects.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector/Fixture/skip_sonata_expects.php.inc deleted file mode 100644 index 70034fe699d..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector/Fixture/skip_sonata_expects.php.inc +++ /dev/null @@ -1,17 +0,0 @@ -createMock(DatagridInterface::class); - - $datagrid->expects($this->once()) - ->method('getPager') - ->willReturn($pager); - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector/Fixture/skip_with_expects.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector/Fixture/skip_with_expects.php.inc deleted file mode 100644 index 601098e8b1d..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector/Fixture/skip_with_expects.php.inc +++ /dev/null @@ -1,16 +0,0 @@ -createMock(\Exception::class); - $mock->expects($this->once()) - ->method('getMessage') - ->willReturn('a message'); - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector/DelegateExceptionArgumentsRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector/DelegateExceptionArgumentsRectorTest.php deleted file mode 100644 index 544bd76a5db..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector/DelegateExceptionArgumentsRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return DelegateExceptionArgumentsRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector/Fixture/message.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector/Fixture/message.php.inc deleted file mode 100644 index ef9534752f8..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector/Fixture/message.php.inc +++ /dev/null @@ -1,38 +0,0 @@ -setExpectedException('SomeException'); - // with message - $this->setExpectedException('SomeException', $message); - // with code - self::setExpectedException('SomeException', $message, 101); - } -} - -?> ------ -expectException('SomeException'); - // with message - $this->expectException('SomeException'); - $this->expectExceptionMessage($message); - // with code - self::expectException('SomeException'); - self::expectExceptionMessage($message); - self::expectExceptionCode(101); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector/Fixture/regexp.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector/Fixture/regexp.php.inc deleted file mode 100644 index df9f04cc99d..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector/Fixture/regexp.php.inc +++ /dev/null @@ -1,24 +0,0 @@ - ------ - diff --git a/rules-tests/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector/Fixture/self_nested.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector/Fixture/self_nested.php.inc deleted file mode 100644 index 1f7a9f43e81..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector/Fixture/self_nested.php.inc +++ /dev/null @@ -1,37 +0,0 @@ -setExpectedException('SomeException', $message); - } else { - $this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage); - } - } -} - -?> ------ -expectException('SomeException'); - $this->expectExceptionMessage($message); - } else { - $this->expectException('InvalidArgumentException'); - $this->expectExceptionMessage($expectedExceptionMessage); - } - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/ExplicitPhpErrorApiRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/ExplicitPhpErrorApiRectorTest.php deleted file mode 100644 index f1acdab4973..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/ExplicitPhpErrorApiRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return ExplicitPhpErrorApiRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/Fixture/php_deprecation.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/Fixture/php_deprecation.php.inc deleted file mode 100644 index edcbbcd6fe5..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/Fixture/php_deprecation.php.inc +++ /dev/null @@ -1,31 +0,0 @@ -expectException(\PHPUnit\Framework\TestCase\Deprecated::class); - } -} - -?> ------ -expectDeprecation(); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/Fixture/php_error.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/Fixture/php_error.php.inc deleted file mode 100644 index 5d6574ce1d8..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/Fixture/php_error.php.inc +++ /dev/null @@ -1,31 +0,0 @@ -expectException(\PHPUnit\Framework\TestCase\Error::class); - } -} - -?> ------ -expectError(); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/Fixture/php_notice.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/Fixture/php_notice.php.inc deleted file mode 100644 index 35008ada55a..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/Fixture/php_notice.php.inc +++ /dev/null @@ -1,31 +0,0 @@ -expectException(\PHPUnit\Framework\TestCase\Notice::class); - } -} - -?> ------ -expectNotice(); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/Fixture/php_warning.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/Fixture/php_warning.php.inc deleted file mode 100644 index 86f343586e6..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector/Fixture/php_warning.php.inc +++ /dev/null @@ -1,31 +0,0 @@ -expectException(\PHPUnit\Framework\TestCase\Warning::class); - } -} - -?> ------ -expectWarning(); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector/Fixture/fixture.php.inc deleted file mode 100644 index 2410276dc3d..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,29 +0,0 @@ -getMockBuilder('SomeClass') - ->disableOriginalConstructor() - ->getMock(); - } -} - -?> ------ -createMock('SomeClass'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector/Fixture/get_mock_only.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector/Fixture/get_mock_only.php.inc deleted file mode 100644 index e960d4d9850..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector/Fixture/get_mock_only.php.inc +++ /dev/null @@ -1,28 +0,0 @@ -getMockBuilder('SomeClass') - ->getMock(); - } -} - -?> ------ -createMock('SomeClass'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector/GetMockBuilderGetMockToCreateMockRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector/GetMockBuilderGetMockToCreateMockRectorTest.php deleted file mode 100644 index 7f90d2ff96c..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector/GetMockBuilderGetMockToCreateMockRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return GetMockBuilderGetMockToCreateMockRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/RemoveExpectAnyFromMockRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/RemoveExpectAnyFromMockRector/Fixture/fixture.php.inc deleted file mode 100644 index 6f25862c6f0..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/RemoveExpectAnyFromMockRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,37 +0,0 @@ -createMock('SomeClass'); - $translator->expects($this->any()) - ->method('trans') - ->willReturn('translated max {{ max }}!'); - } -} - -?> ------ -createMock('SomeClass'); - $translator - ->method('trans') - ->willReturn('translated max {{ max }}!'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/RemoveExpectAnyFromMockRector/Fixture/keep.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/RemoveExpectAnyFromMockRector/Fixture/keep.php.inc deleted file mode 100644 index 53cce162f14..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/RemoveExpectAnyFromMockRector/Fixture/keep.php.inc +++ /dev/null @@ -1,16 +0,0 @@ -createMock('Keep'); - $translator->expects($this->once()) - ->method('trans') - ->willReturn('translated max {{ max }}!'); - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/RemoveExpectAnyFromMockRector/RemoveExpectAnyFromMockRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/RemoveExpectAnyFromMockRector/RemoveExpectAnyFromMockRectorTest.php deleted file mode 100644 index d39e663eb7e..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/RemoveExpectAnyFromMockRector/RemoveExpectAnyFromMockRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return RemoveExpectAnyFromMockRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector/Fixture/fixture.php.inc deleted file mode 100644 index 19622e2ce31..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,35 +0,0 @@ - 0], ['bar' => '0'], true); - - $this->assertArraySubset(['bar' => 0], ['bar' => '0'], true); - } -} - -?> ------ - 0], ['bar' => '0'], true); - - \DMS\PHPUnitExtensions\ArraySubset\Assert::assertArraySubset(['bar' => 0], ['bar' => '0'], true); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector/ReplaceAssertArraySubsetWithDmsPolyfillRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector/ReplaceAssertArraySubsetWithDmsPolyfillRectorTest.php deleted file mode 100644 index 0c3367ea850..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector/ReplaceAssertArraySubsetWithDmsPolyfillRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return ReplaceAssertArraySubsetWithDmsPolyfillRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/fixture.php.inc deleted file mode 100644 index 31331c35e43..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,39 +0,0 @@ -assertContains('foo', 'foo bar'); - $this->assertNotContains('foo', 'foo bar'); - - self::assertContains('foo', 'foo bar'); - self::assertNotContains('foo', 'foo bar'); - } -} - -?> ------ -assertStringContainsString('foo', 'foo bar'); - $this->assertStringNotContainsString('foo', 'foo bar'); - - self::assertStringContainsString('foo', 'foo bar'); - self::assertStringNotContainsString('foo', 'foo bar'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/skip_iterable.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/skip_iterable.php.inc deleted file mode 100644 index ba68b70fc77..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/skip_iterable.php.inc +++ /dev/null @@ -1,13 +0,0 @@ -assertContains('foo', $items); - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/skip_iterable_get.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/skip_iterable_get.php.inc deleted file mode 100644 index 4daa12297b2..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/skip_iterable_get.php.inc +++ /dev/null @@ -1,20 +0,0 @@ -getItems([]); - $this->assertContains('foo', $items[1]); - } - - public function getItems(array $array): array - { - return $array; - } -} - diff --git a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/string_or_false.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/string_or_false.php.inc deleted file mode 100644 index c52bd26eab5..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/string_or_false.php.inc +++ /dev/null @@ -1,55 +0,0 @@ -assertContains('foo', $this->getStringOrFalse()); - } - - /** - * @return false|string - */ - public function getStringOrFalse() - { - if (mt_rand(0, 1)) { - return 'string'; - } - - return false; - } -} - -?> ------ -assertStringContainsString('foo', $this->getStringOrFalse()); - } - - /** - * @return false|string - */ - public function getStringOrFalse() - { - if (mt_rand(0, 1)) { - return 'string'; - } - - return false; - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/string_or_null.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/string_or_null.php.inc deleted file mode 100644 index 263f82d4d96..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/Fixture/string_or_null.php.inc +++ /dev/null @@ -1,49 +0,0 @@ -assertContains('foo', $this->getStringOrNull()); - } - - public function getStringOrNull(): ?string - { - if (mt_rand(0, 1)) { - return 'string'; - } - - return null; - } -} - -?> ------ -assertStringContainsString('foo', $this->getStringOrNull()); - } - - public function getStringOrNull(): ?string - { - if (mt_rand(0, 1)) { - return 'string'; - } - - return null; - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/SpecificAssertContainsRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/SpecificAssertContainsRectorTest.php deleted file mode 100644 index 16bce6ad1ce..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector/SpecificAssertContainsRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return SpecificAssertContainsRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/Fixture/fixture.php.inc deleted file mode 100644 index f86423d2aa7..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,37 +0,0 @@ -assertContains(new stdClass(), $objects, 'message', false, false); - $this->assertNotContains(new stdClass(), $objects, 'message', false, false); - } -} - -?> ------ -assertContainsEquals(new stdClass(), $objects, 'message'); - $this->assertNotContainsEquals(new stdClass(), $objects, 'message'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/Fixture/skip_partial_arguments.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/Fixture/skip_partial_arguments.php.inc deleted file mode 100644 index c91b4579e30..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/Fixture/skip_partial_arguments.php.inc +++ /dev/null @@ -1,16 +0,0 @@ -assertContains(new stdClass(), $objects, 'message', false); - $this->assertNotContains(new stdClass(), $objects, 'message', false); - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/Fixture/skip_strings.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/Fixture/skip_strings.php.inc deleted file mode 100644 index a57ab0a44f5..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/Fixture/skip_strings.php.inc +++ /dev/null @@ -1,14 +0,0 @@ -assertContains('foo', 'foo bar', 'message', false, false); - $this->assertNotContains('foo', 'foo bar', 'message', false, false); - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/Fixture/skip_with_identity_check.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/Fixture/skip_with_identity_check.php.inc deleted file mode 100644 index 4f293647adb..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/Fixture/skip_with_identity_check.php.inc +++ /dev/null @@ -1,16 +0,0 @@ -assertContains(new stdClass(), $objects, 'message', false, true); - $this->assertNotContains(new stdClass(), $objects, 'message', false, true); - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/SpecificAssertContainsWithoutIdentityRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/SpecificAssertContainsWithoutIdentityRectorTest.php deleted file mode 100644 index aa550735bf7..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector/SpecificAssertContainsWithoutIdentityRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return SpecificAssertContainsWithoutIdentityRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertInternalTypeRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertInternalTypeRector/Fixture/fixture.php.inc deleted file mode 100644 index 81da91da912..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertInternalTypeRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,33 +0,0 @@ -assertInternalType('string', $value); - $this->assertInternalType('array', $value); - $this->assertNotInternalType('bool', $value, 'message'); - $this->assertNotInternalType('boolean', $value, 'message'); - $this->assertNotInternalType('callable', $value, 'message'); - } -} - -?> ------ -assertIsString($value); - $this->assertIsArray($value); - $this->assertIsNotBool($value, 'message'); - $this->assertIsNotBool($value, 'message'); - $this->assertIsNotCallable($value, 'message'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertInternalTypeRector/SpecificAssertInternalTypeRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertInternalTypeRector/SpecificAssertInternalTypeRectorTest.php deleted file mode 100644 index bf4695c6c26..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/SpecificAssertInternalTypeRector/SpecificAssertInternalTypeRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return SpecificAssertInternalTypeRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/UseSpecificWillMethodRector/Fixture/will.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/UseSpecificWillMethodRector/Fixture/will.php.inc deleted file mode 100644 index a3c1fcc632b..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/UseSpecificWillMethodRector/Fixture/will.php.inc +++ /dev/null @@ -1,74 +0,0 @@ -getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock(); - $translator->expects($this->any()) - ->method('trans') - ->will($this->returnValue('translated max {{ max }}!')); - - $translator->expects($this->any()) - ->will($this->returnSelf()); - - $translator->expects($this->any()) - ->will($this->returnArgument(2)); - - $translator->expects($this->any()) - ->will($this->returnCallback("str_rot13")); - - $translator->expects($this->any()) - ->will($this->returnValueMap(["a", "b", "c", "d"])); - - $translator->expects($this->any()) - ->WILL($this->returnValue(1)); - - $translator->expects($this->any()) - ->will($this->ReturnVALUE(2)); - - $translator->expects($this->any()) - ->will($this->throwException(new \InvalidArgumentException())); - } -} - -?> ------ -getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock(); - $translator->expects($this->any()) - ->method('trans') - ->willReturn('translated max {{ max }}!'); - - $translator->expects($this->any())->willReturnSelf(); - - $translator->expects($this->any()) - ->willReturnArgument(2); - - $translator->expects($this->any()) - ->willReturnCallback("str_rot13"); - - $translator->expects($this->any()) - ->willReturnMap(["a", "b", "c", "d"]); - - $translator->expects($this->any()) - ->willReturn(1); - - $translator->expects($this->any()) - ->willReturn(2); - - $translator->expects($this->any()) - ->willThrowException(new \InvalidArgumentException()); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/UseSpecificWillMethodRector/Fixture/with.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/UseSpecificWillMethodRector/Fixture/with.php.inc deleted file mode 100644 index 2737704e58d..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/UseSpecificWillMethodRector/Fixture/with.php.inc +++ /dev/null @@ -1,35 +0,0 @@ -getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock(); - $translator->expects($this->any()) - ->method('trans') - ->with($this->equalTo('old max {{ max }}!')) - ->with($this->equalTo($log), $this->equalTo($parameters)); - } -} - -?> ------ -getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock(); - $translator->expects($this->any()) - ->method('trans') - ->with('old max {{ max }}!') - ->with($log, $parameters); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/UseSpecificWillMethodRector/UseSpecificWillMethodRectorTest.php b/rules-tests/PHPUnit/Rector/MethodCall/UseSpecificWillMethodRector/UseSpecificWillMethodRectorTest.php deleted file mode 100644 index d113ebac663..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/UseSpecificWillMethodRector/UseSpecificWillMethodRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return UseSpecificWillMethodRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/WithConsecutiveArgToArrayRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/WithConsecutiveArgToArrayRector/Fixture/fixture.php.inc deleted file mode 100644 index 4da193e4526..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/WithConsecutiveArgToArrayRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,46 +0,0 @@ -createMock(SomeClass::class); - $someClassMock->expects($this->exactly(2)) - ->method('run') - ->withConsecutive(1, 2, 3, 5); - } -} - -?> ------ -createMock(SomeClass::class); - $someClassMock->expects($this->exactly(2)) - ->method('run')->withConsecutive([1, 2], [3, 5]); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/MethodCall/WithConsecutiveArgToArrayRector/Fixture/skip_already_array.php.inc b/rules-tests/PHPUnit/Rector/MethodCall/WithConsecutiveArgToArrayRector/Fixture/skip_already_array.php.inc deleted file mode 100644 index ceb92f55cbf..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/WithConsecutiveArgToArrayRector/Fixture/skip_already_array.php.inc +++ /dev/null @@ -1,17 +0,0 @@ -createMock(ClassWithMethodOfTwoArguments::class); - $someClassMock->expects($this->exactly(2)) - ->method('run') - ->withConsecutive([1, 2, 3, 5]); - } -} diff --git a/rules-tests/PHPUnit/Rector/MethodCall/WithConsecutiveArgToArrayRector/Source/ClassWithMethodOfTwoArguments.php b/rules-tests/PHPUnit/Rector/MethodCall/WithConsecutiveArgToArrayRector/Source/ClassWithMethodOfTwoArguments.php deleted file mode 100644 index b71021ef8a2..00000000000 --- a/rules-tests/PHPUnit/Rector/MethodCall/WithConsecutiveArgToArrayRector/Source/ClassWithMethodOfTwoArguments.php +++ /dev/null @@ -1,13 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return WithConsecutiveArgToArrayRector::class; - } -} diff --git a/rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/Fixture/fixture.php.inc b/rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/Fixture/fixture.php.inc deleted file mode 100644 index d957d353749..00000000000 --- a/rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,27 +0,0 @@ -getMock('SomeClass'); - } -} - -?> ------ -createMock('SomeClass'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/Fixture/get_mock_multi.php.inc b/rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/Fixture/get_mock_multi.php.inc deleted file mode 100644 index 61665420678..00000000000 --- a/rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/Fixture/get_mock_multi.php.inc +++ /dev/null @@ -1,27 +0,0 @@ -getMock('LDUser', [], [], '', false); - } -} - -?> ------ -createMock('LDUser'); - } -} - -?> diff --git a/rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/Fixture/skip_build_mock.php.inc b/rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/Fixture/skip_build_mock.php.inc deleted file mode 100644 index 2538d12a31b..00000000000 --- a/rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/Fixture/skip_build_mock.php.inc +++ /dev/null @@ -1,12 +0,0 @@ -buildMock() - ->getMock(); - } -} diff --git a/rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/Fixture/static_call.php.inc b/rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/Fixture/static_call.php.inc deleted file mode 100644 index 57d8a6afe19..00000000000 --- a/rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/Fixture/static_call.php.inc +++ /dev/null @@ -1,27 +0,0 @@ - ------ - diff --git a/rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/GetMockRectorTest.php b/rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/GetMockRectorTest.php deleted file mode 100644 index 9ce6cc0af32..00000000000 --- a/rules-tests/PHPUnit/Rector/StaticCall/GetMockRector/GetMockRectorTest.php +++ /dev/null @@ -1,34 +0,0 @@ -doTestFileInfo($fileInfo); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return GetMockRector::class; - } -} diff --git a/rules-tests/PHPUnit/TestClassResolver/Source/SeeSomeClass.php b/rules-tests/PHPUnit/TestClassResolver/Source/SeeSomeClass.php deleted file mode 100644 index 3ca9bddad99..00000000000 --- a/rules-tests/PHPUnit/TestClassResolver/Source/SeeSomeClass.php +++ /dev/null @@ -1,10 +0,0 @@ -bootKernel(RectorKernel::class); - $this->testClassResolver = $this->getService(TestClassResolver::class); - } - - /** - * @dataProvider provideData() - */ - public function test(string $rectorClass, string $expectedTestClass): void - { - $testClass = $this->testClassResolver->resolveFromClassName($rectorClass); - $this->assertSame($expectedTestClass, $testClass); - } - - /** - * @return Iterator - */ - public function provideData(): Iterator - { - yield [SeeSomeClass::class, SeeSomeClassTest::class]; - yield [TypedPropertyRector::class, TypedPropertyRectorTest::class]; - yield [DowngradeTypedPropertyRector::class, DowngradeTypedPropertyRectorTest::class]; - } -} diff --git a/rules/PHPUnit/Composer/ComposerAutoloadedDirectoryProvider.php b/rules/PHPUnit/Composer/ComposerAutoloadedDirectoryProvider.php deleted file mode 100644 index ceca3cf8b92..00000000000 --- a/rules/PHPUnit/Composer/ComposerAutoloadedDirectoryProvider.php +++ /dev/null @@ -1,106 +0,0 @@ -composerFilePath = getcwd() . '/composer.json'; - $this->smartFileSystem = $smartFileSystem; - } - - /** - * @return string[]|mixed[] - */ - public function provide(): array - { - if (StaticPHPUnitEnvironment::isPHPUnitRun()) { - return [getcwd() . '/src', getcwd() . '/tests', getcwd() . '/packages-tests', getcwd() . '/rules-tests']; - } - - $composerJson = $this->loadComposerJsonArray(); - $autoloadDirectories = []; - - foreach (self::AUTOLOAD_SECTIONS as $autoloadSection) { - if (! isset($composerJson[$autoloadSection])) { - continue; - } - - $sectionDirectories = $this->collectDirectoriesFromAutoload($composerJson[$autoloadSection]); - $autoloadDirectories[] = $sectionDirectories; - } - - return Arrays::flatten($autoloadDirectories); - } - - /** - * @return mixed[] - */ - private function loadComposerJsonArray(): array - { - if (! file_exists($this->composerFilePath)) { - return []; - } - - $composerFileContent = $this->smartFileSystem->readFile($this->composerFilePath); - - return Json::decode($composerFileContent, Json::FORCE_ARRAY); - } - - /** - * @param string[] $composerJsonAutoload - * @return string[] - */ - private function collectDirectoriesFromAutoload(array $composerJsonAutoload): array - { - $autoloadDirectories = []; - - if (isset($composerJsonAutoload['psr-4'])) { - /** @var string[] $psr4 */ - $psr4 = $composerJsonAutoload['psr-4']; - $autoloadDirectories = array_merge($autoloadDirectories, $psr4); - } - - if (isset($composerJsonAutoload['classmap'])) { - /** @var string[] $classmap */ - $classmap = $composerJsonAutoload['classmap']; - - foreach ($classmap as $singleClassmap) { - $singleClassmap = getcwd() . '/' . $singleClassmap; - - // skip file, we look only for directories - if (file_exists($singleClassmap)) { - continue; - } - - $autoloadDirectories[] = $singleClassmap; - } - } - - return array_values($autoloadDirectories); - } -} diff --git a/rules/PHPUnit/NodeAnalyzer/ExpectationAnalyzer.php b/rules/PHPUnit/NodeAnalyzer/ExpectationAnalyzer.php deleted file mode 100644 index e785ee136fa..00000000000 --- a/rules/PHPUnit/NodeAnalyzer/ExpectationAnalyzer.php +++ /dev/null @@ -1,175 +0,0 @@ -testsNodeAnalyzer = $testsNodeAnalyzer; - $this->consecutiveAssertionFactory = $consecutiveAssertionFactory; - } - - /** - * @param Expression[] $stmts - */ - public function getExpectationsFromExpressions(array $stmts): ExpectationMockCollection - { - $expectationMockCollection = new ExpectationMockCollection(); - foreach ($stmts as $stmt) { - /** @var MethodCall $expr */ - $expr = $stmt->expr; - $method = $this->getMethod($expr); - if (! $this->testsNodeAnalyzer->isPHPUnitMethodName($method, 'method')) { - continue; - } - - /** @var MethodCall $expects */ - $expects = $this->getExpects($method->var, $method); - if (! $this->isValidExpectsCall($expects)) { - continue; - } - - $expectsArg = $expects->args[0]; - /** @var MethodCall $expectsValue */ - $expectsValue = $expectsArg->value; - if (! $this->isValidAtCall($expectsValue)) { - continue; - } - - $atArg = $expectsValue->args[0]; - $atValue = $atArg->value; - if (! $atValue instanceof LNumber) { - continue; - } - if (! $expects->var instanceof Variable) { - continue; - } - - $expectationMockCollection->add( - new ExpectationMock( - $expects->var, - $method->args, - $atValue->value, - $this->getWill($expr), - $this->getWithArgs($method->var), - $stmt - ) - ); - } - - return $expectationMockCollection; - } - - public function isValidExpectsCall(MethodCall $methodCall): bool - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodName($methodCall, 'expects')) { - return false; - } - - if (count($methodCall->args) !== 1) { - return false; - } - - return true; - } - - public function isValidAtCall(MethodCall $methodCall): bool - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodName($methodCall, 'at')) { - return false; - } - - if (count($methodCall->args) !== 1) { - return false; - } - - return true; - } - - private function getMethod(MethodCall $methodCall): MethodCall - { - if ($this->testsNodeAnalyzer->isPHPUnitMethodNames( - $methodCall, - self::PROCESSABLE_WILL_STATEMENTS - ) && $methodCall->var instanceof MethodCall) { - return $methodCall->var; - } - - return $methodCall; - } - - private function getWill(MethodCall $methodCall): ?Expr - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames($methodCall, self::PROCESSABLE_WILL_STATEMENTS)) { - return null; - } - - return $this->consecutiveAssertionFactory->createWillReturn($methodCall); - } - - private function getExpects(Expr $expr, MethodCall $methodCall): Expr - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodName($expr, 'with')) { - return $methodCall->var; - } - if (! $expr instanceof MethodCall) { - return $methodCall->var; - } - return $expr->var; - } - - /** - * @return array - */ - private function getWithArgs(Expr $expr): array - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodName($expr, 'with')) { - return [null]; - } - if (! $expr instanceof MethodCall) { - return [null]; - } - return array_map(static function (Arg $arg): Expr { - return $arg->value; - }, $expr->args); - } -} diff --git a/rules/PHPUnit/NodeAnalyzer/TestsNodeAnalyzer.php b/rules/PHPUnit/NodeAnalyzer/TestsNodeAnalyzer.php deleted file mode 100644 index 53374bb8bda..00000000000 --- a/rules/PHPUnit/NodeAnalyzer/TestsNodeAnalyzer.php +++ /dev/null @@ -1,110 +0,0 @@ -nodeTypeResolver = $nodeTypeResolver; - $this->nodeNameResolver = $nodeNameResolver; - $this->phpDocInfoFactory = $phpDocInfoFactory; - - $this->testCaseObjectTypes = [ - new ObjectType('PHPUnit\Framework\TestCase'), - new ObjectType('PHPUnit_Framework_TestCase'), - ]; - } - - public function isInTestClass(Node $node): bool - { - $classLike = $node->getAttribute(AttributeKey::CLASS_NODE); - if (! $classLike instanceof ClassLike) { - return false; - } - - return $this->nodeTypeResolver->isObjectTypes($classLike, $this->testCaseObjectTypes); - } - - public function isTestClassMethod(ClassMethod $classMethod): bool - { - if (! $classMethod->isPublic()) { - return false; - } - - if ($this->nodeNameResolver->isName($classMethod, 'test*')) { - return true; - } - - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); - return $phpDocInfo->hasByName('test'); - } - - public function isPHPUnitMethodName(Node $node, string $name): bool - { - if (! $this->isPHPUnitTestCaseCall($node)) { - return false; - } - - /** @var StaticCall|MethodCall $node */ - return $this->nodeNameResolver->isName($node->name, $name); - } - - public function isPHPUnitTestCaseCall(Node $node): bool - { - if (! $this->isInTestClass($node)) { - return false; - } - - return $node instanceof MethodCall || $node instanceof StaticCall; - } - - /** - * @param string[] $names - */ - public function isPHPUnitMethodNames(Node $node, array $names): bool - { - if (! $this->isPHPUnitTestCaseCall($node)) { - return false; - } - - /** @var MethodCall|StaticCall $node */ - return $this->nodeNameResolver->isNames($node->name, $names); - } -} diff --git a/rules/PHPUnit/NodeFactory/ArgumentShiftingFactory.php b/rules/PHPUnit/NodeFactory/ArgumentShiftingFactory.php deleted file mode 100644 index 6bfc1097292..00000000000 --- a/rules/PHPUnit/NodeFactory/ArgumentShiftingFactory.php +++ /dev/null @@ -1,24 +0,0 @@ -name = new Identifier($methodName); - foreach (array_keys($methodCall->args) as $i) { - // keep first arg - if ($i === 0) { - continue; - } - - unset($methodCall->args[$i]); - } - } -} diff --git a/rules/PHPUnit/NodeFactory/AssertCallFactory.php b/rules/PHPUnit/NodeFactory/AssertCallFactory.php deleted file mode 100644 index 1add7eba97a..00000000000 --- a/rules/PHPUnit/NodeFactory/AssertCallFactory.php +++ /dev/null @@ -1,21 +0,0 @@ -var, $name) : new StaticCall($node->class, $name); - } -} diff --git a/rules/PHPUnit/NodeFactory/ConsecutiveAssertionFactory.php b/rules/PHPUnit/NodeFactory/ConsecutiveAssertionFactory.php deleted file mode 100644 index 397b19dc44e..00000000000 --- a/rules/PHPUnit/NodeFactory/ConsecutiveAssertionFactory.php +++ /dev/null @@ -1,184 +0,0 @@ - - */ - private const REPLACE_WILL_MAP = [ - 'willReturnMap' => 'returnValueMap', - 'willReturnArgument' => 'returnArgument', - 'willReturnCallback' => 'returnCallback', - 'willThrowException' => 'throwException', - ]; - - public function createAssertionFromExpectationMockCollection( - ExpectationMockCollection $expectationMockCollection - ): MethodCall { - $expectationMocks = $expectationMockCollection->getExpectationMocks(); - - $variable = $expectationMocks[0]->getExpectationVariable(); - $methodArguments = $expectationMocks[0]->getMethodArguments(); - - $expectationMocks = $this->sortExpectationMocksByIndex($expectationMocks); - - if (! $expectationMockCollection->hasReturnValues()) { - return $this->createWithConsecutive( - $this->createMethod($variable, $methodArguments), - $this->createWithArgs($expectationMocks) - ); - } - - if ($expectationMockCollection->hasWithValues()) { - return $this->createWillReturnOnConsecutiveCalls( - $this->createWithConsecutive( - $this->createMethod($variable, $methodArguments), - $this->createWithArgs($expectationMocks) - ), - $this->createReturnArgs($expectationMocks) - ); - } - - return $this->createWillReturnOnConsecutiveCalls( - $this->createMethod($variable, $methodArguments), - $this->createReturnArgs($expectationMocks) - ); - } - - /** - * @param Arg[] $args - */ - public function createWillReturnOnConsecutiveCalls(Expr $expr, array $args): MethodCall - { - return $this->createMethodCall($expr, 'willReturnOnConsecutiveCalls', $args); - } - - /** - * @param Arg[] $args - */ - public function createMethod(Expr $expr, array $args): MethodCall - { - return $this->createMethodCall($expr, 'method', $args); - } - - /** - * @param Arg[] $args - */ - public function createWithConsecutive(Expr $expr, array $args): MethodCall - { - return $this->createMethodCall($expr, 'withConsecutive', $args); - } - - public function createWillReturn(MethodCall $methodCall): Expr - { - if (! $methodCall->name instanceof Identifier) { - return $methodCall; - } - - $methodCallName = $methodCall->name->name; - if ($methodCallName === 'will') { - return $methodCall->args[0]->value; - } - - if ($methodCallName === 'willReturnSelf') { - return $this->createWillReturnSelf(); - } - - if ($methodCallName === 'willReturnReference') { - return $this->createWillReturnReference($methodCall); - } - - if (array_key_exists($methodCallName, self::REPLACE_WILL_MAP)) { - return $this->createMappedWillReturn($methodCallName, $methodCall); - } - - return $methodCall->args[0]->value; - } - - /** - * @param ExpectationMock[] $expectationMocks - * @return Arg[] - */ - private function createReturnArgs(array $expectationMocks): array - { - return array_map(static function (ExpectationMock $expectationMock): Arg { - return new Arg($expectationMock->getReturn() ?: new ConstFetch(new Name('null'))); - }, $expectationMocks); - } - - /** - * @param ExpectationMock[] $expectationMocks - * @return Arg[] - */ - private function createWithArgs(array $expectationMocks): array - { - return array_map(static function (ExpectationMock $expectationMock): Arg { - $arrayItems = array_map(static function (?Expr $expr): ArrayItem { - return new ArrayItem($expr ?: new ConstFetch(new Name('null'))); - }, $expectationMock->getWithArguments()); - return new Arg(new Array_($arrayItems)); - }, $expectationMocks); - } - - private function createWillReturnSelf(): MethodCall - { - return $this->createMethodCall(new Variable('this'), 'returnSelf', []); - } - - private function createWillReturnReference(MethodCall $methodCall): New_ - { - return new New_( - new FullyQualified('PHPUnit\Framework\MockObject\Stub\ReturnReference'), - [new Arg($methodCall->args[0]->value)] - ); - } - - private function createMappedWillReturn(string $methodCallName, MethodCall $methodCall): MethodCall - { - return $this->createMethodCall( - new Variable('this'), - self::REPLACE_WILL_MAP[$methodCallName], - [new Arg($methodCall->args[0]->value)] - ); - } - - /** - * @param Arg[] $args - */ - private function createMethodCall(Expr $expr, string $name, array $args): MethodCall - { - return new MethodCall($expr, new Identifier($name), $args); - } - - /** - * @param ExpectationMock[] $expectationMocks - * @return ExpectationMock[] - */ - private function sortExpectationMocksByIndex(array $expectationMocks): array - { - usort( - $expectationMocks, - static function (ExpectationMock $expectationMockA, ExpectationMock $expectationMockB): int { - return $expectationMockA->getIndex() > $expectationMockB->getIndex() ? 1 : -1; - } - ); - return $expectationMocks; - } -} diff --git a/rules/PHPUnit/NodeFactory/DataProviderClassMethodFactory.php b/rules/PHPUnit/NodeFactory/DataProviderClassMethodFactory.php deleted file mode 100644 index b2a9b013689..00000000000 --- a/rules/PHPUnit/NodeFactory/DataProviderClassMethodFactory.php +++ /dev/null @@ -1,50 +0,0 @@ -getMethodName()); - $methodBuilder->makePublic(); - - $classMethod = $methodBuilder->getNode(); - - foreach ($dataProviderClassMethodRecipe->getArgs() as $arg) { - $value = $arg->value; - if (! $value instanceof Array_) { - continue; - } - - foreach ($value->items as $arrayItem) { - if (! $arrayItem instanceof ArrayItem) { - continue; - } - - $returnStatement = new Yield_(new Array_([new ArrayItem($arrayItem->value)])); - $classMethod->stmts[] = new Expression($returnStatement); - } - } - - $this->decorateClassMethodWithReturnTypeAndTag($classMethod); - - return $classMethod; - } - - private function decorateClassMethodWithReturnTypeAndTag(ClassMethod $classMethod): void - { - $classMethod->returnType = new FullyQualified('Iterator'); - } -} diff --git a/rules/PHPUnit/NodeFactory/ExpectExceptionCodeFactory.php b/rules/PHPUnit/NodeFactory/ExpectExceptionCodeFactory.php deleted file mode 100644 index ba71f03ea72..00000000000 --- a/rules/PHPUnit/NodeFactory/ExpectExceptionCodeFactory.php +++ /dev/null @@ -1,54 +0,0 @@ -nodeNameResolver = $nodeNameResolver; - $this->argumentShiftingFactory = $argumentShiftingFactory; - } - - public function create(MethodCall $methodCall, Variable $exceptionVariable): ?MethodCall - { - if (! $this->nodeNameResolver->isLocalMethodCallsNamed($methodCall, ['assertSame', 'assertEquals'])) { - return null; - } - - $secondArgument = $methodCall->args[1]->value; - if (! $secondArgument instanceof MethodCall) { - return null; - } - - // looking for "$exception->getMessage()" - if (! $this->nodeNameResolver->areNamesEqual($secondArgument->var, $exceptionVariable)) { - return null; - } - - if (! $this->nodeNameResolver->isName($secondArgument->name, 'getCode')) { - return null; - } - - $this->argumentShiftingFactory->removeAllButFirstArgMethodCall($methodCall, 'expectExceptionCode'); - return $methodCall; - } -} diff --git a/rules/PHPUnit/NodeFactory/ExpectExceptionFactory.php b/rules/PHPUnit/NodeFactory/ExpectExceptionFactory.php deleted file mode 100644 index a8fed4b0067..00000000000 --- a/rules/PHPUnit/NodeFactory/ExpectExceptionFactory.php +++ /dev/null @@ -1,41 +0,0 @@ -nodeNameResolver = $nodeNameResolver; - } - - public function create(MethodCall $methodCall, Variable $variable): ?MethodCall - { - if (! $this->nodeNameResolver->isLocalMethodCallNamed($methodCall, 'assertInstanceOf')) { - return null; - } - - $argumentVariableName = $this->nodeNameResolver->getName($methodCall->args[1]->value); - if ($argumentVariableName === null) { - return null; - } - - // is na exception variable - if (! $this->nodeNameResolver->isName($variable, $argumentVariableName)) { - return null; - } - - return new MethodCall($methodCall->var, 'expectException', [$methodCall->args[0]]); - } -} diff --git a/rules/PHPUnit/NodeFactory/ExpectExceptionMessageFactory.php b/rules/PHPUnit/NodeFactory/ExpectExceptionMessageFactory.php deleted file mode 100644 index 377210a401f..00000000000 --- a/rules/PHPUnit/NodeFactory/ExpectExceptionMessageFactory.php +++ /dev/null @@ -1,61 +0,0 @@ -nodeNameResolver = $nodeNameResolver; - $this->argumentShiftingFactory = $argumentShiftingFactory; - $this->nodeComparator = $nodeComparator; - } - - public function create(MethodCall $methodCall, Variable $exceptionVariable): ?MethodCall - { - if (! $this->nodeNameResolver->isLocalMethodCallsNamed($methodCall, ['assertSame', 'assertEquals'])) { - return null; - } - - $secondArgument = $methodCall->args[1]->value; - if (! $secondArgument instanceof MethodCall) { - return null; - } - - if (! $this->nodeComparator->areNodesEqual($secondArgument->var, $exceptionVariable)) { - return null; - } - - if (! $this->nodeNameResolver->isName($secondArgument->name, 'getMessage')) { - return null; - } - - $this->argumentShiftingFactory->removeAllButFirstArgMethodCall($methodCall, 'expectExceptionMessage'); - return $methodCall; - } -} diff --git a/rules/PHPUnit/NodeFactory/ExpectExceptionMessageRegExpFactory.php b/rules/PHPUnit/NodeFactory/ExpectExceptionMessageRegExpFactory.php deleted file mode 100644 index 6b027ba2cc1..00000000000 --- a/rules/PHPUnit/NodeFactory/ExpectExceptionMessageRegExpFactory.php +++ /dev/null @@ -1,74 +0,0 @@ -nodeNameResolver = $nodeNameResolver; - $this->argumentShiftingFactory = $argumentShiftingFactory; - $this->nodeComparator = $nodeComparator; - } - - public function create(MethodCall $methodCall, Variable $exceptionVariable): ?MethodCall - { - if (! $this->nodeNameResolver->isLocalMethodCallNamed($methodCall, 'assertContains')) { - return null; - } - - $secondArgument = $methodCall->args[1]->value; - if (! $secondArgument instanceof MethodCall) { - return null; - } - - // looking for "$exception->getMessage()" - if (! $this->nodeComparator->areNodesEqual($secondArgument->var, $exceptionVariable)) { - return null; - } - - if (! $this->nodeNameResolver->isName($secondArgument->name, 'getMessage')) { - return null; - } - - $this->argumentShiftingFactory->removeAllButFirstArgMethodCall( - $methodCall, - 'expectExceptionMessageRegExp' - ); - - // put regex between "#...#" to create match - if ($methodCall->args[0]->value instanceof String_) { - /** @var String_ $oldString */ - $oldString = $methodCall->args[0]->value; - $methodCall->args[0]->value = new String_('#' . preg_quote($oldString->value, '#') . '#'); - } - - return $methodCall; - } -} diff --git a/rules/PHPUnit/NodeFactory/ExpectExceptionMethodCallFactory.php b/rules/PHPUnit/NodeFactory/ExpectExceptionMethodCallFactory.php deleted file mode 100644 index 04db7be6ea2..00000000000 --- a/rules/PHPUnit/NodeFactory/ExpectExceptionMethodCallFactory.php +++ /dev/null @@ -1,115 +0,0 @@ -nodeFactory = $nodeFactory; - $this->phpDocValueToNodeMapper = $phpDocValueToNodeMapper; - $this->staticTypeMapper = $staticTypeMapper; - $this->currentNodeProvider = $currentNodeProvider; - } - - /** - * @param PhpDocTagNode[] $phpDocTagNodes - * @return Expression[] - */ - public function createFromTagValueNodes(array $phpDocTagNodes, string $methodName): array - { - $methodCallExpressions = []; - foreach ($phpDocTagNodes as $genericTagValueNode) { - $methodCall = $this->createMethodCall($genericTagValueNode, $methodName); - $methodCallExpressions[] = new Expression($methodCall); - } - - return $methodCallExpressions; - } - - private function createMethodCall(PhpDocTagNode $phpDocTagNode, string $methodName): MethodCall - { - if ($phpDocTagNode->value instanceof PHPUnitExpectedExceptionTagValueNode) { - $value = $this->resolveExpectedValue($phpDocTagNode->value); - $methodCall = $this->nodeFactory->createMethodCall('this', $methodName); - $methodCall->args[] = new Arg($value); - - return $methodCall; - } - - if (! $phpDocTagNode->value instanceof GenericTagValueNode) { - throw new ShouldNotHappenException(); - } - - $node = $this->phpDocValueToNodeMapper->mapGenericTagValueNode($phpDocTagNode->value); - return $this->nodeFactory->createMethodCall('this', $methodName, [new Arg($node)]); - } - - private function resolveExpectedValue( - PHPUnitExpectedExceptionTagValueNode $phpUnitExpectedExceptionTagValueNode - ): Expr { - $expectedTypeNode = $phpUnitExpectedExceptionTagValueNode->getTypeNode(); - - $currentNode = $this->currentNodeProvider->getNode(); - if (! $currentNode instanceof Node) { - throw new ShouldNotHappenException(); - } - - $expectedType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($expectedTypeNode, $currentNode); - $expectedNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($expectedType); - - if ($expectedNode instanceof Name) { - return $this->nodeFactory->createClassConstFetchFromName($expectedNode, 'class'); - } - - if ($expectedTypeNode instanceof IdentifierTypeNode) { - $className = ltrim($expectedTypeNode->name, '\\'); - return BuilderHelpers::normalizeValue($className); - } - - throw new ShouldNotHappenException(); - } -} diff --git a/rules/PHPUnit/NodeFactory/SetUpClassMethodFactory.php b/rules/PHPUnit/NodeFactory/SetUpClassMethodFactory.php deleted file mode 100644 index ba9866ddb26..00000000000 --- a/rules/PHPUnit/NodeFactory/SetUpClassMethodFactory.php +++ /dev/null @@ -1,60 +0,0 @@ -phpUnitTypeDeclarationDecorator = $phpUnitTypeDeclarationDecorator; - $this->stmtManipulator = $stmtManipulator; - $this->setUpFactory = $setUpFactory; - } - - /** - * @param Stmt[]|Expr[] $stmts - */ - public function createSetUpMethod(array $stmts): ClassMethod - { - $stmts = $this->stmtManipulator->normalizeStmts($stmts); - - $classMethodBuilder = new MethodBuilder(MethodName::SET_UP); - $classMethodBuilder->makeProtected(); - - $classMethodBuilder->addStmt($this->setUpFactory->createParentStaticCall()); - $classMethodBuilder->addStmts($stmts); - - $classMethod = $classMethodBuilder->getNode(); - $this->phpUnitTypeDeclarationDecorator->decorate($classMethod); - - return $classMethod; - } -} diff --git a/rules/PHPUnit/NodeManipulator/ArgumentMover.php b/rules/PHPUnit/NodeManipulator/ArgumentMover.php deleted file mode 100644 index d0e89637e63..00000000000 --- a/rules/PHPUnit/NodeManipulator/ArgumentMover.php +++ /dev/null @@ -1,23 +0,0 @@ -args; - array_shift($methodArguments); - - $node->args = $methodArguments; - } -} diff --git a/rules/PHPUnit/NodeManipulator/ParamAndArgFromArrayResolver.php b/rules/PHPUnit/NodeManipulator/ParamAndArgFromArrayResolver.php deleted file mode 100644 index 40eddf50f09..00000000000 --- a/rules/PHPUnit/NodeManipulator/ParamAndArgFromArrayResolver.php +++ /dev/null @@ -1,139 +0,0 @@ -nodeTypeResolver = $nodeTypeResolver; - $this->typeFactory = $typeFactory; - } - - /** - * @return ParamAndArg[] - */ - public function resolve(Array_ $array, string $variableName): array - { - $isNestedArray = $this->isNestedArray($array); - if ($isNestedArray) { - return $this->collectParamAndArgsFromNestedArray($array, $variableName); - } - - $itemsStaticType = $this->resolveItemStaticType($array, $isNestedArray); - return $this->collectParamAndArgsFromNonNestedArray($array, $variableName, $itemsStaticType); - } - - private function isNestedArray(Array_ $array): bool - { - foreach ($array->items as $arrayItem) { - if (! $arrayItem instanceof ArrayItem) { - continue; - } - - if ($arrayItem->value instanceof Array_) { - return true; - } - } - - return false; - } - - /** - * @return ParamAndArg[] - */ - private function collectParamAndArgsFromNestedArray(Array_ $array, string $variableName): array - { - $paramAndArgs = []; - $i = 1; - - foreach ($array->items as $arrayItem) { - if (! $arrayItem instanceof ArrayItem) { - continue; - } - - $nestedArray = $arrayItem->value; - if (! $nestedArray instanceof Array_) { - continue; - } - - foreach ($nestedArray->items as $nestedArrayItem) { - if (! $nestedArrayItem instanceof ArrayItem) { - continue; - } - - $variable = new Variable($variableName . ($i === 1 ? '' : $i)); - - $itemsStaticType = $this->nodeTypeResolver->getStaticType($nestedArrayItem->value); - $paramAndArgs[] = new ParamAndArg($variable, $itemsStaticType); - ++$i; - } - } - return $paramAndArgs; - } - - private function resolveItemStaticType(Array_ $array, bool $isNestedArray): Type - { - $staticTypes = []; - if (! $isNestedArray) { - foreach ($array->items as $arrayItem) { - if (! $arrayItem instanceof ArrayItem) { - continue; - } - - $staticTypes[] = $this->nodeTypeResolver->getStaticType($arrayItem->value); - } - } - - return $this->typeFactory->createMixedPassedOrUnionType($staticTypes); - } - - /** - * @return ParamAndArg[] - */ - private function collectParamAndArgsFromNonNestedArray( - Array_ $array, - string $variableName, - Type $itemsStaticType - ): array { - $i = 1; - $paramAndArgs = []; - - foreach ($array->items as $arrayItem) { - if (! $arrayItem instanceof ArrayItem) { - continue; - } - - $variable = new Variable($variableName . ($i === 1 ? '' : $i)); - - $paramAndArgs[] = new ParamAndArg($variable, $itemsStaticType); - ++$i; - - if (! $arrayItem->value instanceof Array_) { - break; - } - } - - return $paramAndArgs; - } -} diff --git a/rules/PHPUnit/NodeManipulator/SetUpClassMethodNodeManipulator.php b/rules/PHPUnit/NodeManipulator/SetUpClassMethodNodeManipulator.php deleted file mode 100644 index 0793f9f43d1..00000000000 --- a/rules/PHPUnit/NodeManipulator/SetUpClassMethodNodeManipulator.php +++ /dev/null @@ -1,48 +0,0 @@ -setUpClassMethodFactory = $setUpClassMethodFactory; - $this->stmtManipulator = $stmtManipulator; - } - - /** - * @param Stmt[]|Expr[] $stmts - */ - public function decorateOrCreate(Class_ $class, array $stmts): void - { - $stmts = $this->stmtManipulator->normalizeStmts($stmts); - - $setUpClassMethod = $class->getMethod(MethodName::SET_UP); - - if ($setUpClassMethod === null) { - $setUpClassMethod = $this->setUpClassMethodFactory->createSetUpMethod($stmts); - $class->stmts = array_merge([$setUpClassMethod], $class->stmts); - } else { - $setUpClassMethod->stmts = array_merge((array) $setUpClassMethod->stmts, $stmts); - } - } -} diff --git a/rules/PHPUnit/NodeManipulator/StmtManipulator.php b/rules/PHPUnit/NodeManipulator/StmtManipulator.php deleted file mode 100644 index e20d3e0135d..00000000000 --- a/rules/PHPUnit/NodeManipulator/StmtManipulator.php +++ /dev/null @@ -1,32 +0,0 @@ -nodeFactory = $nodeFactory; - $this->reflectionProvider = $reflectionProvider; - } - - public function mapGenericTagValueNode(GenericTagValueNode $genericTagValueNode): Expr - { - if (Strings::contains($genericTagValueNode->value, '::')) { - [$class, $constant] = explode('::', $genericTagValueNode->value); - return $this->nodeFactory->createShortClassConstFetch($class, $constant); - } - - $reference = ltrim($genericTagValueNode->value, '\\'); - - if ($this->reflectionProvider->hasClass($reference)) { - return $this->nodeFactory->createClassConstReference($reference); - } - - return new String_($reference); - } -} diff --git a/rules/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector.php b/rules/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector.php deleted file mode 100644 index 93054ef8455..00000000000 --- a/rules/PHPUnit/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector.php +++ /dev/null @@ -1,327 +0,0 @@ -fileInfoParser = $fileInfoParser; - $this->classMethodReflectionFactory = $classMethodReflectionFactory; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Tests without assertion will have @doesNotPerformAssertion', - [ - new CodeSample( - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; - -class SomeClass extends TestCase -{ - public function test() - { - $nothing = 5; - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; - -class SomeClass extends TestCase -{ - /** - * @doesNotPerformAssertions - */ - public function test() - { - $nothing = 5; - } -} -CODE_SAMPLE - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [ClassMethod::class]; - } - - /** - * @param ClassMethod $node - */ - public function refactor(Node $node): ?Node - { - $this->classMethodNestingLevel = 0; - - if ($this->shouldSkipClassMethod($node)) { - return null; - } - - $this->addDoesNotPerformAssertions($node); - - return $node; - } - - private function shouldSkipClassMethod(ClassMethod $classMethod): bool - { - if (! $this->testsNodeAnalyzer->isInTestClass($classMethod)) { - return true; - } - - if (! $this->testsNodeAnalyzer->isTestClassMethod($classMethod)) { - return true; - } - - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); - if ($phpDocInfo->hasByTypes( - [PHPUnitDoesNotPerformAssertionTagNode::class, PHPUnitExpectedExceptionTagValueNode::class] - )) { - return true; - } - - return $this->containsAssertCall($classMethod); - } - - private function addDoesNotPerformAssertions(ClassMethod $classMethod): void - { - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); - $phpDocInfo->addPhpDocTagNode(new PHPUnitDoesNotPerformAssertionTagNode()); - } - - private function containsAssertCall(ClassMethod $classMethod): bool - { - ++$this->classMethodNestingLevel; - - // probably no assert method in the end - if ($this->classMethodNestingLevel > self::MAX_LOOKING_FOR_ASSERT_METHOD_CALL_NESTING_LEVEL) { - return false; - } - - $cacheHash = md5($this->print($classMethod)); - if (isset($this->containsAssertCallByClassMethod[$cacheHash])) { - return $this->containsAssertCallByClassMethod[$cacheHash]; - } - - // A. try "->assert" shallow search first for performance - $hasDirectAssertCall = $this->hasDirectAssertCall($classMethod); - if ($hasDirectAssertCall) { - $this->containsAssertCallByClassMethod[$cacheHash] = $hasDirectAssertCall; - return true; - } - - // B. look for nested calls - $hasNestedAssertCall = $this->hasNestedAssertCall($classMethod); - $this->containsAssertCallByClassMethod[$cacheHash] = $hasNestedAssertCall; - - return $hasNestedAssertCall; - } - - private function hasDirectAssertCall(ClassMethod $classMethod): bool - { - return (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (Node $node): bool { - if ($node instanceof MethodCall) { - return $this->isNames($node->name, [ - // phpunit - '*assert', - 'assert*', - 'expectException*', - 'setExpectedException*', - ]); - } - if ($node instanceof StaticCall) { - return $this->isNames($node->name, [ - // phpunit - '*assert', - 'assert*', - 'expectException*', - 'setExpectedException*', - ]); - } - return false; - }); - } - - private function hasNestedAssertCall(ClassMethod $classMethod): bool - { - $currentClassMethod = $classMethod; - - // over and over the same method :/ - return (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (Node $node) use ( - $currentClassMethod - ): bool { - if (! $node instanceof MethodCall && ! $node instanceof StaticCall) { - return false; - } - - $classMethod = $this->findClassMethod($node); - - // skip circular self calls - if ($currentClassMethod === $classMethod) { - return false; - } - - if ($classMethod !== null) { - return $this->containsAssertCall($classMethod); - } - - return false; - }); - } - - /** - * @param MethodCall|StaticCall $node - */ - private function findClassMethod(Node $node): ?ClassMethod - { - if ($node instanceof MethodCall) { - $classMethod = $this->nodeRepository->findClassMethodByMethodCall($node); - if ($classMethod !== null) { - return $classMethod; - } - } elseif ($node instanceof StaticCall) { - $classMethod = $this->nodeRepository->findClassMethodByStaticCall($node); - if ($classMethod !== null) { - return $classMethod; - } - } - - // in 3rd-party code - return $this->findClassMethodByParsingReflection($node); - } - - /** - * @param MethodCall|StaticCall $node - */ - private function findClassMethodByParsingReflection(Node $node): ?ClassMethod - { - $methodName = $this->getName($node->name); - if ($methodName === null) { - return null; - } - - if ($node instanceof MethodCall) { - $objectType = $this->getObjectType($node->var); - } else { - // StaticCall - $objectType = $this->getObjectType($node->class); - } - - $reflectionMethod = $this->classMethodReflectionFactory->createFromPHPStanTypeAndMethodName( - $objectType, - $methodName - ); - - if (! $reflectionMethod instanceof ReflectionMethod) { - return null; - } - - $fileName = $reflectionMethod->getFileName(); - if (! $fileName) { - return null; - } - if (! file_exists($fileName)) { - return null; - } - - return $this->findClassMethodInFile($fileName, $methodName); - } - - private function findClassMethodInFile(string $fileName, string $methodName): ?ClassMethod - { - // skip already anayzed method to prevent cycling - if (isset($this->analyzedMethodsInFileName[$fileName][$methodName])) { - return $this->analyzedMethodsInFileName[$fileName][$methodName]; - } - - $smartFileInfo = new SmartFileInfo($fileName); - $examinedMethodNodes = $this->fileInfoParser->parseFileInfoToNodesAndDecorate($smartFileInfo); - - /** @var ClassMethod|null $examinedClassMethod */ - $examinedClassMethod = $this->betterNodeFinder->findFirst( - $examinedMethodNodes, - function (Node $node) use ($methodName): bool { - if (! $node instanceof ClassMethod) { - return false; - } - - return $this->isName($node, $methodName); - } - ); - - $this->analyzedMethodsInFileName[$fileName][$methodName] = $examinedClassMethod; - - return $examinedClassMethod; - } -} diff --git a/rules/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector.php b/rules/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector.php deleted file mode 100644 index 1dc6215e9ff..00000000000 --- a/rules/PHPUnit/Rector/ClassMethod/ExceptionAnnotationRector.php +++ /dev/null @@ -1,126 +0,0 @@ - - */ - private const ANNOTATION_TO_METHOD = [ - 'expectedExceptionMessageRegExp' => 'expectExceptionMessageRegExp', - 'expectedExceptionMessage' => 'expectExceptionMessage', - 'expectedExceptionCode' => 'expectExceptionCode', - 'expectedException' => 'expectException', - ]; - - /** - * @var ExpectExceptionMethodCallFactory - */ - private $expectExceptionMethodCallFactory; - - /** - * @var PhpDocTagRemover - */ - private $phpDocTagRemover; - - /** - * @var TestsNodeAnalyzer - */ - private $testsNodeAnalyzer; - - public function __construct( - ExpectExceptionMethodCallFactory $expectExceptionMethodCallFactory, - PhpDocTagRemover $phpDocTagRemover, - TestsNodeAnalyzer $testsNodeAnalyzer - ) { - $this->expectExceptionMethodCallFactory = $expectExceptionMethodCallFactory; - $this->phpDocTagRemover = $phpDocTagRemover; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Changes `@expectedException annotations to `expectException*()` methods', - [ - new CodeSample( - <<<'CODE_SAMPLE' -/** - * @expectedException Exception - * @expectedExceptionMessage Message - */ -public function test() -{ - // tested code -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -public function test() -{ - $this->expectException('Exception'); - $this->expectExceptionMessage('Message'); - // tested code -} -CODE_SAMPLE - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [ClassMethod::class]; - } - - /** - * @param ClassMethod $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isInTestClass($node)) { - return null; - } - - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); - - foreach (self::ANNOTATION_TO_METHOD as $annotationName => $methodName) { - if (! $phpDocInfo->hasByName($annotationName)) { - continue; - } - - $methodCallExpressions = $this->expectExceptionMethodCallFactory->createFromTagValueNodes( - $phpDocInfo->getTagsByName($annotationName), - $methodName, - ); - $node->stmts = array_merge($methodCallExpressions, (array) $node->stmts); - - $this->phpDocTagRemover->removeByName($phpDocInfo, $annotationName); - } - - return $node; - } -} diff --git a/rules/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector.php b/rules/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector.php deleted file mode 100644 index 373e6bba031..00000000000 --- a/rules/PHPUnit/Rector/ClassMethod/MigrateAtToConsecutiveExpectationsRector.php +++ /dev/null @@ -1,209 +0,0 @@ -consecutiveAssertionFactory = $consecutiveAssertionFactory; - $this->expectationAnalyzer = $expectationAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Migrates deprecated $this->at to $this->withConsecutive and $this->willReturnOnConsecutiveCalls', - [ - new CodeSample( - <<<'CODE_SAMPLE' -$mock = $this->createMock(Foo::class); -$mock->expects($this->at(0))->with('0')->method('someMethod')->willReturn('1'); -$mock->expects($this->at(1))->with('1')->method('someMethod')->willReturn('2'); -CODE_SAMPLE -, - <<<'CODE_SAMPLE' -$mock = $this->createMock(Foo::class); -$mock->method('someMethod')->withConsecutive(['0'], ['1'])->willReturnOnConsecutiveCalls('1', '2'); -CODE_SAMPLE - - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [ClassMethod::class]; - } - - /** - * @param ClassMethod $node - */ - public function refactor(Node $node): ?Node - { - $stmts = $node->stmts; - if ($stmts === null) { - return null; - } - - $expressions = array_filter($stmts, function (Stmt $expr): bool { - return $expr instanceof Expression && $expr->expr instanceof MethodCall; - }); - - $expectationMockCollection = $this->expectationAnalyzer->getExpectationsFromExpressions($expressions); - - if (! $expectationMockCollection->hasExpectationMocks()) { - return null; - } - - $expectationCollections = $this->groupExpectationCollectionsByVariableName($expectationMockCollection); - foreach ($expectationCollections as $expectationCollection) { - $this->replaceExpectationNodes($expectationCollection); - } - - return $node; - } - - private function buildNewExpectation(ExpectationMockCollection $expectationMockCollection): MethodCall - { - $expectationMockCollection = $this->fillMissingAtIndexes($expectationMockCollection); - return $this->consecutiveAssertionFactory->createAssertionFromExpectationMockCollection( - $expectationMockCollection - ); - } - - private function fillMissingAtIndexes( - ExpectationMockCollection $expectationMockCollection - ): ExpectationMockCollection { - $variable = $expectationMockCollection->getExpectationMocks()[0] - ->getExpectationVariable(); - - // 0,1,2,3,4 - // min = 0 ; max = 4 ; count = 5 - // OK - - // 1,2,3,4 - // min = 1 ; max = 4 ; count = 4 - // ADD 0 - - // OR - - // 3 - // min = 3; max = 3 ; count = 1 - // 0,1,2 - if ($expectationMockCollection->getLowestAtIndex() !== 0) { - for ($i = 0; $i < $expectationMockCollection->getLowestAtIndex(); ++$i) { - $expectationMockCollection->add(new ExpectationMock($variable, [], $i, null, [], null)); - } - } - - // 0,1,2,4 - // min = 0 ; max = 4 ; count = 4 - // ADD 3 - if ($expectationMockCollection->isMissingAtIndexBetweenHighestAndLowest()) { - $existingIndexes = array_column($expectationMockCollection->getExpectationMocks(), 'index'); - for ($i = 1; $i < $expectationMockCollection->getHighestAtIndex(); ++$i) { - if (! in_array($i, $existingIndexes, true)) { - $expectationMockCollection->add(new ExpectationMock($variable, [], $i, null, [], null)); - } - } - } - return $expectationMockCollection; - } - - private function replaceExpectationNodes(ExpectationMockCollection $expectationMockCollection): void - { - if ($this->shouldSkipReplacement($expectationMockCollection)) { - return; - } - - $endLines = array_map(static function (ExpectationMock $expectationMock): int { - $originalExpression = $expectationMock->getOriginalExpression(); - return $originalExpression instanceof Expression ? $originalExpression->getEndLine() : 0; - }, $expectationMockCollection->getExpectationMocks()); - $max = max($endLines); - - foreach ($expectationMockCollection->getExpectationMocks() as $expectationMock) { - $originalExpression = $expectationMock->getOriginalExpression(); - if (! $originalExpression instanceof Expression) { - continue; - } - if ($max > $originalExpression->getEndLine()) { - $this->removeNode($originalExpression); - } else { - $originalExpression->expr = $this->buildNewExpectation($expectationMockCollection); - } - } - } - - private function shouldSkipReplacement(ExpectationMockCollection $expectationMockCollection): bool - { - if (! $expectationMockCollection->hasReturnValues()) { - return false; - } - - if (! $expectationMockCollection->isExpectedMethodAlwaysTheSame()) { - return true; - } - - if ($expectationMockCollection->hasMissingAtIndexes()) { - return true; - } - return $expectationMockCollection->hasMissingReturnValues(); - } - - /** - * @return ExpectationMockCollection[] - */ - private function groupExpectationCollectionsByVariableName( - ExpectationMockCollection $expectationMockCollection - ): array { - $groupedByVariable = []; - foreach ($expectationMockCollection->getExpectationMocks() as $expectationMock) { - $variable = $expectationMock->getExpectationVariable(); - if (! is_string($variable->name)) { - continue; - } - if (! isset($groupedByVariable[$variable->name])) { - $groupedByVariable[$variable->name] = new ExpectationMockCollection(); - } - $groupedByVariable[$variable->name]->add($expectationMock); - } - - return array_values($groupedByVariable); - } -} diff --git a/rules/PHPUnit/Rector/ClassMethod/RemoveEmptyTestMethodRector.php b/rules/PHPUnit/Rector/ClassMethod/RemoveEmptyTestMethodRector.php deleted file mode 100644 index 3bef239558d..00000000000 --- a/rules/PHPUnit/Rector/ClassMethod/RemoveEmptyTestMethodRector.php +++ /dev/null @@ -1,89 +0,0 @@ -testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition('Remove empty test methods', [ - new CodeSample( - <<<'CODE_SAMPLE' -class SomeTest extends \PHPUnit\Framework\TestCase -{ - /** - * testGetTranslatedModelField method - * - * @return void - */ - public function testGetTranslatedModelField() - { - } -} -CODE_SAMPLE -, - <<<'CODE_SAMPLE' -class SomeTest extends \PHPUnit\Framework\TestCase -{ -} -CODE_SAMPLE - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [ClassMethod::class]; - } - - /** - * @param ClassMethod $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isInTestClass($node)) { - return null; - } - - if (! $this->isName($node->name, 'test*')) { - return null; - } - - if ($node->stmts === null) { - return null; - } - - if ($node->stmts !== []) { - return null; - } - - $this->removeNode($node); - - return null; - } -} diff --git a/rules/PHPUnit/Rector/ClassMethod/TryCatchToExpectExceptionRector.php b/rules/PHPUnit/Rector/ClassMethod/TryCatchToExpectExceptionRector.php deleted file mode 100644 index f2962357058..00000000000 --- a/rules/PHPUnit/Rector/ClassMethod/TryCatchToExpectExceptionRector.php +++ /dev/null @@ -1,200 +0,0 @@ -testsNodeAnalyzer = $testsNodeAnalyzer; - $this->expectExceptionCodeFactory = $expectExceptionCodeFactory; - $this->expectExceptionMessageRegExpFactory = $expectExceptionMessageRegExpFactory; - $this->expectExceptionFactory = $expectExceptionFactory; - $this->expectExceptionMessageFactory = $expectExceptionMessageFactory; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition('Turns try/catch to expectException() call', [ - new CodeSample( - <<<'CODE_SAMPLE' -try { - $someService->run(); -} catch (Throwable $exception) { - $this->assertInstanceOf(RuntimeException::class, $e); - $this->assertContains('There was an error executing the following script', $e->getMessage()); -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -$this->expectException(RuntimeException::class); -$this->expectExceptionMessage('There was an error executing the following script'); -$someService->run(); -CODE_SAMPLE - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [ClassMethod::class]; - } - - /** - * @param ClassMethod $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isInTestClass($node)) { - return null; - } - - if ($node->stmts === null) { - return null; - } - - $proccesed = []; - foreach ($node->stmts as $key => $stmt) { - if (! $stmt instanceof TryCatch) { - continue; - } - - $proccesed = $this->processTryCatch($stmt); - if ($proccesed === null) { - continue; - } - - /** @var int $key */ - $this->nodeRemover->removeStmt($node, $key); - } - - $node->stmts = array_merge($node->stmts, (array) $proccesed); - - return $node; - } - - /** - * @return Expression[]|null - */ - private function processTryCatch(TryCatch $tryCatch): ?array - { - $exceptionVariable = $this->matchSingleExceptionVariable($tryCatch); - if (! $exceptionVariable instanceof Variable) { - return null; - } - - // we look for: - // - instance of $exceptionVariableName - // - assert same string to $exceptionVariableName->getMessage() - // - assert same string to $exceptionVariableName->getCode() - $newMethodCalls = []; - - foreach ($tryCatch->catches[0]->stmts as $catchedStmt) { - // not a match - if (! $catchedStmt instanceof Expression) { - return null; - } - - if (! $catchedStmt->expr instanceof MethodCall) { - continue; - } - - $methodCallNode = $catchedStmt->expr; - - $newMethodCalls[] = $this->expectExceptionMessageFactory->create($methodCallNode, $exceptionVariable); - $newMethodCalls[] = $this->expectExceptionFactory->create($methodCallNode, $exceptionVariable); - $newMethodCalls[] = $this->expectExceptionCodeFactory->create($methodCallNode, $exceptionVariable); - $newMethodCalls[] = $this->expectExceptionMessageRegExpFactory->create($methodCallNode, $exceptionVariable); - } - - $newMethodCalls = array_filter($newMethodCalls); - $newExpressions = $this->wrapInExpressions($newMethodCalls); - - // return all statements - foreach ($tryCatch->stmts as $stmt) { - if (! $stmt instanceof Expression) { - return null; - } - - $newExpressions[] = $stmt; - } - - return $newExpressions; - } - - private function matchSingleExceptionVariable(TryCatch $tryCatch): ?Variable - { - if (count($tryCatch->catches) !== 1) { - return null; - } - - return $tryCatch->catches[0]->var; - } - - /** - * @param MethodCall[] $methodCalls - * @return Expression[] - */ - private function wrapInExpressions(array $methodCalls): array - { - $expressions = []; - foreach ($methodCalls as $methodCall) { - $expressions[] = new Expression($methodCall); - } - - return $expressions; - } -} diff --git a/rules/PHPUnit/Rector/Class_/AddProphecyTraitRector.php b/rules/PHPUnit/Rector/Class_/AddProphecyTraitRector.php deleted file mode 100644 index 0f555d24c0d..00000000000 --- a/rules/PHPUnit/Rector/Class_/AddProphecyTraitRector.php +++ /dev/null @@ -1,133 +0,0 @@ -classInsertManipulator = $classInsertManipulator; - $this->classManipulator = $classManipulator; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Add Prophecy trait for method using $this->prophesize()', - [ - new CodeSample( - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; - -final class ExampleTest extends TestCase -{ - public function testOne(): void - { - $prophecy = $this->prophesize(\AnInterface::class); - } -} -CODE_SAMPLE -, - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; -use Prophecy\PhpUnit\ProphecyTrait; - -final class ExampleTest extends TestCase -{ - use ProphecyTrait; - - public function testOne(): void - { - $prophecy = $this->prophesize(\AnInterface::class); - } -} -CODE_SAMPLE - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * @param Class_ $node - */ - public function refactor(Node $node): ?Node - { - if ($this->shouldSkipClass($node)) { - return null; - } - - $this->classInsertManipulator->addAsFirstTrait($node, self::PROPHECY_TRAIT); - - return $node; - } - - private function shouldSkipClass(Class_ $class): bool - { - if (! $this->testsNodeAnalyzer->isInTestClass($class)) { - return true; - } - - $hasProphesizeMethodCall = $this->hasProphesizeMethodCall($class); - if (! $hasProphesizeMethodCall) { - return true; - } - - return $this->classManipulator->hasTrait($class, self::PROPHECY_TRAIT); - } - - private function hasProphesizeMethodCall(Class_ $class): bool - { - return (bool) $this->betterNodeFinder->findFirst($class, function (Node $node): bool { - return $this->nodeNameResolver->isLocalMethodCallNamed($node, 'prophesize'); - }); - } -} diff --git a/rules/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector.php b/rules/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector.php deleted file mode 100644 index 6a0e7239375..00000000000 --- a/rules/PHPUnit/Rector/Class_/AddSeeTestAnnotationRector.php +++ /dev/null @@ -1,213 +0,0 @@ -testClassResolver = $testClassResolver; - $this->reflectionProvider = $reflectionProvider; - $this->phpDocTagRemover = $phpDocTagRemover; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Add @see annotation test of the class for faster jump to test. Make it FQN, so it stays in the annotation, not in the PHP source code.', - [ - new CodeSample( - <<<'CODE_SAMPLE' -class SomeService -{ -} - -use PHPUnit\Framework\TestCase; - -class SomeServiceTest extends TestCase -{ -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -/** - * @see \SomeServiceTest - */ -class SomeService -{ -} - -use PHPUnit\Framework\TestCase; - -class SomeServiceTest extends TestCase -{ -} -CODE_SAMPLE - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * @param Class_ $node - */ - public function refactor(Node $node): ?Node - { - $testCaseClassName = $this->testClassResolver->resolveFromClass($node); - if ($testCaseClassName === null) { - return null; - } - - if ($this->shouldSkipClass($node, $testCaseClassName)) { - return null; - } - - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); - if ($this->hasAlreadySeeAnnotation($phpDocInfo, $testCaseClassName)) { - return null; - } - - $this->removeNonExistingClassSeeAnnotation($phpDocInfo); - - $newSeeTagNode = $this->createSeePhpDocTagNode($testCaseClassName); - $phpDocInfo->addPhpDocTagNode($newSeeTagNode); - - return $node; - } - - private function shouldSkipClass(Class_ $class, string $testCaseClassName): bool - { - // we are in the test case - if ($this->isName($class, '*Test')) { - return true; - } - - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($class); - $seeTags = $phpDocInfo->getTagsByName(self::SEE); - - // is the @see annotation already added - foreach ($seeTags as $seeTag) { - if (! $seeTag->value instanceof GenericTagValueNode) { - continue; - } - - /** @var GenericTagValueNode $genericTagValueNode */ - $genericTagValueNode = $seeTag->value; - - $seeTagClass = ltrim($genericTagValueNode->value, '\\'); - if ($seeTagClass === $testCaseClassName) { - return true; - } - } - - return false; - } - - private function createSeePhpDocTagNode(string $className): PhpDocTagNode - { - return new AttributeAwarePhpDocTagNode('@see', new AttributeAwareGenericTagValueNode('\\' . $className)); - } - - private function hasAlreadySeeAnnotation(PhpDocInfo $phpDocInfo, string $testCaseClassName): bool - { - $seePhpDocTagNodes = $phpDocInfo->getTagsByName(self::SEE); - - foreach ($seePhpDocTagNodes as $seePhpDocTagNode) { - if (! $seePhpDocTagNode->value instanceof GenericTagValueNode) { - continue; - } - - $possibleClassName = $seePhpDocTagNode->value->value; - - // annotation already exists - if ($possibleClassName === '\\' . $testCaseClassName) { - return true; - } - } - - return false; - } - - private function removeNonExistingClassSeeAnnotation(PhpDocInfo $phpDocInfo): void - { - $seePhpDocTagNodes = $phpDocInfo->getTagsByName(self::SEE); - - foreach ($seePhpDocTagNodes as $seePhpDocTagNode) { - if (! $seePhpDocTagNode->value instanceof GenericTagValueNode) { - continue; - } - - $possibleClassName = $seePhpDocTagNode->value->value; - if (! $this->isSeeTestCaseClass($possibleClassName)) { - continue; - } - - if ($this->reflectionProvider->hasClass($possibleClassName)) { - continue; - } - - // remove old annotation - $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $seePhpDocTagNode); - } - } - - private function isSeeTestCaseClass(string $possibleClassName): bool - { - if (! Strings::startsWith($possibleClassName, '\\')) { - return false; - } - - return Strings::endsWith($possibleClassName, 'Test'); - } -} diff --git a/rules/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector.php b/rules/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector.php deleted file mode 100644 index 2d9ecfc9539..00000000000 --- a/rules/PHPUnit/Rector/Class_/ArrayArgumentToDataProviderRector.php +++ /dev/null @@ -1,350 +0,0 @@ -dataProviderClassMethodFactory = $dataProviderClassMethodFactory; - $this->paramAndArgFromArrayResolver = $paramAndArgFromArrayResolver; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition('Move array argument from tests into data provider [configurable]', [ - new ConfiguredCodeSample( - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; - -class SomeServiceTest extends TestCase -{ - public function test() - { - $this->doTestMultiple([1, 2, 3]); - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; - -class SomeServiceTest extends TestCase -{ - /** - * @dataProvider provideData() - */ - public function test(int $number) - { - $this->doTestSingle($number); - } - - public function provideData(): \Iterator - { - yield [1]; - yield [2]; - yield [3]; - } -} -CODE_SAMPLE - - , - [ - self::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS => [ - new ArrayArgumentToDataProvider( - 'PHPUnit\Framework\TestCase', - 'doTestMultiple', - 'doTestSingle', - 'number' - ), - ], - ] - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * @param Class_ $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isInTestClass($node)) { - return null; - } - - $this->dataProviderClassMethodRecipes = []; - - $this->traverseNodesWithCallable($node->stmts, function (Node $node) { - if (! $node instanceof MethodCall) { - return null; - } - - foreach ($this->arrayArgumentsToDataProviders as $arrayArgumentsToDataProvider) { - $this->refactorMethodCallWithConfiguration($node, $arrayArgumentsToDataProvider); - } - - return null; - }); - - if ($this->dataProviderClassMethodRecipes === []) { - return null; - } - - $dataProviderClassMethods = $this->createDataProviderClassMethodsFromRecipes(); - - $node->stmts = array_merge($node->stmts, $dataProviderClassMethods); - - return $node; - } - - /** - * @param array $arrayArgumentsToDataProviders - */ - public function configure(array $arrayArgumentsToDataProviders): void - { - $arrayArgumentsToDataProviders = $arrayArgumentsToDataProviders[self::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS] ?? []; - Assert::allIsInstanceOf($arrayArgumentsToDataProviders, ArrayArgumentToDataProvider::class); - $this->arrayArgumentsToDataProviders = $arrayArgumentsToDataProviders; - } - - private function refactorMethodCallWithConfiguration( - MethodCall $methodCall, - ArrayArgumentToDataProvider $arrayArgumentToDataProvider - ): void { - if (! $this->isMethodCallMatch($methodCall, $arrayArgumentToDataProvider)) { - return; - } - - if (count($methodCall->args) !== 1) { - throw new ShouldNotHappenException(); - } - - // resolve value types - $firstArgumentValue = $methodCall->args[0]->value; - if (! $firstArgumentValue instanceof Array_) { - // nothing we can do - return; - } - - // rename method to new one handling non-array input - $methodCall->name = new Identifier($arrayArgumentToDataProvider->getNewMethod()); - - $dataProviderMethodName = $this->createDataProviderMethodName($methodCall); - - $this->dataProviderClassMethodRecipes[] = new DataProviderClassMethodRecipe( - $dataProviderMethodName, - $methodCall->args - ); - - $methodCall->args = []; - - $paramAndArgs = $this->paramAndArgFromArrayResolver->resolve( - $firstArgumentValue, - $arrayArgumentToDataProvider->getVariableName() - ); - - foreach ($paramAndArgs as $paramAndArg) { - $methodCall->args[] = new Arg($paramAndArg->getVariable()); - } - - /** @var ClassMethod $classMethod */ - $classMethod = $methodCall->getAttribute(AttributeKey::METHOD_NODE); - - $this->refactorTestClassMethodParams($classMethod, $paramAndArgs); - - // add data provider annotation - $dataProviderTagNode = $this->createDataProviderTagNode($dataProviderMethodName); - - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); - $phpDocInfo->addPhpDocTagNode($dataProviderTagNode); - } - - /** - * @return ClassMethod[] - */ - private function createDataProviderClassMethodsFromRecipes(): array - { - $dataProviderClassMethods = []; - - foreach ($this->dataProviderClassMethodRecipes as $dataProviderClassMethodRecipe) { - $dataProviderClassMethods[] = $this->dataProviderClassMethodFactory->createFromRecipe( - $dataProviderClassMethodRecipe - ); - } - - return $dataProviderClassMethods; - } - - private function isMethodCallMatch( - MethodCall $methodCall, - ArrayArgumentToDataProvider $arrayArgumentToDataProvider - ): bool { - if (! $this->isObjectType($methodCall->var, $arrayArgumentToDataProvider->getObjectType())) { - return false; - } - - return $this->isName($methodCall->name, $arrayArgumentToDataProvider->getOldMethod()); - } - - private function createDataProviderMethodName(MethodCall $methodCall): string - { - /** @var string $methodName */ - $methodName = $methodCall->getAttribute(AttributeKey::METHOD_NAME); - - return 'provideDataFor' . ucfirst($methodName); - } - - /** - * @param ParamAndArg[] $paramAndArgs - */ - private function refactorTestClassMethodParams(ClassMethod $classMethod, array $paramAndArgs): void - { - $classMethod->params = $this->createParams($paramAndArgs); - - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); - - foreach ($paramAndArgs as $paramAndArg) { - $staticType = $paramAndArg->getType(); - - if (! $staticType instanceof UnionType) { - continue; - } - - /** @var string $paramName */ - $paramName = $this->getName($paramAndArg->getVariable()); - - /** @var TypeNode $staticTypeNode */ - $staticTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($staticType); - - $paramTagValueNode = $this->createParamTagNode($paramName, $staticTypeNode); - $phpDocInfo->addTagValueNode($paramTagValueNode); - } - } - - private function createDataProviderTagNode(string $dataProviderMethodName): PhpDocTagNode - { - return new AttributeAwarePhpDocTagNode('@dataProvider', new GenericTagValueNode( - $dataProviderMethodName . '()' - )); - } - - /** - * @param ParamAndArg[] $paramAndArgs - * @return Param[] - */ - private function createParams(array $paramAndArgs): array - { - $params = []; - foreach ($paramAndArgs as $paramAndArg) { - $param = new Param($paramAndArg->getVariable()); - $this->setTypeIfNotNull($paramAndArg, $param); - - $params[] = $param; - } - - return $params; - } - - private function createParamTagNode(string $name, TypeNode $typeNode): AttributeAwareParamTagValueNode - { - return new AttributeAwareParamTagValueNode($typeNode, false, '$' . $name, ''); - } - - private function setTypeIfNotNull(ParamAndArg $paramAndArg, Param $param): void - { - $staticType = $paramAndArg->getType(); - if (! $staticType instanceof Type) { - return; - } - - if ($staticType instanceof UnionType) { - return; - } - - $phpNodeType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($staticType); - if ($phpNodeType === null) { - return; - } - - $param->type = $phpNodeType; - } -} diff --git a/rules/PHPUnit/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php b/rules/PHPUnit/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php deleted file mode 100644 index b4e78f69b54..00000000000 --- a/rules/PHPUnit/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php +++ /dev/null @@ -1,146 +0,0 @@ -setUpClassMethodNodeManipulator = $setUpClassMethodNodeManipulator; - $this->staticCallAnalyzer = $staticCallAnalyzer; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Change __construct() method in tests of `PHPUnit\Framework\TestCase` to setUp(), to prevent dangerous override', - [ - new CodeSample( - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; - -final class SomeTest extends TestCase -{ - private $someValue; - - public function __construct(?string $name = null, array $data = [], string $dataName = '') - { - $this->someValue = 1000; - parent::__construct($name, $data, $dataName); - } -} -CODE_SAMPLE - - , - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; - -final class SomeTest extends TestCase -{ - private $someValue; - - protected function setUp() - { - parent::setUp(); - - $this->someValue = 1000; - } -} -CODE_SAMPLE - - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * @param Class_ $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isInTestClass($node)) { - return null; - } - - $constructClassMethod = $node->getMethod(MethodName::CONSTRUCT); - if (! $constructClassMethod instanceof ClassMethod) { - return null; - } - - $this->removeNode($constructClassMethod); - - $addedStmts = $this->resolveStmtsToAddToSetUp($constructClassMethod); - $this->setUpClassMethodNodeManipulator->decorateOrCreate($node, $addedStmts); - - return $node; - } - - /** - * @return Stmt[] - */ - private function resolveStmtsToAddToSetUp(ClassMethod $constructClassMethod): array - { - $constructorStmts = (array) $constructClassMethod->stmts; - - // remove parent call - foreach ($constructorStmts as $key => $constructorStmt) { - if ($constructorStmt instanceof Expression) { - $constructorStmt = clone $constructorStmt->expr; - } - - if (! $this->staticCallAnalyzer->isParentCallNamed($constructorStmt, MethodName::CONSTRUCT)) { - continue; - } - - unset($constructorStmts[$key]); - } - - return $constructorStmts; - } -} diff --git a/rules/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector.php b/rules/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector.php deleted file mode 100644 index f0749d0415f..00000000000 --- a/rules/PHPUnit/Rector/Class_/RemoveDataProviderTestPrefixRector.php +++ /dev/null @@ -1,154 +0,0 @@ -testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Data provider methods cannot start with "test" prefix', - [ - new CodeSample( - <<<'CODE_SAMPLE' -class SomeClass extends PHPUnit\Framework\TestCase -{ - /** - * @dataProvider testProvideData() - */ - public function test() - { - $nothing = 5; - } - - public function testProvideData() - { - return ['123']; - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -class SomeClass extends PHPUnit\Framework\TestCase -{ - /** - * @dataProvider provideData() - */ - public function test() - { - $nothing = 5; - } - - public function provideData() - { - return ['123']; - } -} -CODE_SAMPLE - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * @param Class_ $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isInTestClass($node)) { - return null; - } - - $this->providerMethodNamesToNewNames = []; - - $this->renameDataProviderAnnotationsAndCollectRenamedMethods($node); - $this->renameProviderMethods($node); - - return $node; - } - - private function renameDataProviderAnnotationsAndCollectRenamedMethods(Class_ $class): void - { - foreach ($class->getMethods() as $classMethod) { - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); - - /** @var PHPUnitDataProviderTagValueNode[] $phpunitDataProviderTagValueNodes */ - $phpunitDataProviderTagValueNodes = $phpDocInfo->findAllByType(PHPUnitDataProviderTagValueNode::class); - if ($phpunitDataProviderTagValueNodes === []) { - continue; - } - - foreach ($phpunitDataProviderTagValueNodes as $phpunitDataProviderTagValueNode) { - $oldMethodName = $phpunitDataProviderTagValueNode->getMethodName(); - if (! Strings::startsWith($oldMethodName, 'test')) { - continue; - } - - $newMethodName = $this->createNewMethodName($oldMethodName); - $phpunitDataProviderTagValueNode->changeMethodName($newMethodName); - $phpDocInfo->markAsChanged(); - - $this->providerMethodNamesToNewNames[$oldMethodName] = $newMethodName; - } - } - } - - private function renameProviderMethods(Class_ $class): void - { - foreach ($class->getMethods() as $classMethod) { - foreach ($this->providerMethodNamesToNewNames as $oldName => $newName) { - if (! $this->isName($classMethod, $oldName)) { - continue; - } - - $classMethod->name = new Identifier($newName); - } - } - } - - private function createNewMethodName(string $oldMethodName): string - { - $newMethodName = Strings::substring($oldMethodName, strlen('test')); - - return lcfirst($newMethodName); - } -} diff --git a/rules/PHPUnit/Rector/Class_/TestListenerToHooksRector.php b/rules/PHPUnit/Rector/Class_/TestListenerToHooksRector.php deleted file mode 100644 index 76a2a50fb87..00000000000 --- a/rules/PHPUnit/Rector/Class_/TestListenerToHooksRector.php +++ /dev/null @@ -1,170 +0,0 @@ -> - */ - private const LISTENER_METHOD_TO_HOOK_INTERFACES = [ - 'addIncompleteTest' => ['PHPUnit\Runner\AfterIncompleteTestHook', 'executeAfterIncompleteTest'], - 'addRiskyTest' => ['PHPUnit\Runner\AfterRiskyTestHook', 'executeAfterRiskyTest'], - 'addSkippedTest' => ['PHPUnit\Runner\AfterSkippedTestHook', 'executeAfterSkippedTest'], - 'addError' => ['PHPUnit\Runner\AfterTestErrorHook', 'executeAfterTestError'], - 'addFailure' => ['PHPUnit\Runner\AfterTestFailureHook', 'executeAfterTestFailure'], - 'addWarning' => ['PHPUnit\Runner\AfterTestWarningHook', 'executeAfterTestWarning'], - # test - 'startTest' => ['PHPUnit\Runner\BeforeTestHook', 'executeBeforeTest'], - 'endTest' => ['PHPUnit\Runner\AfterTestHook', 'executeAfterTest'], - # suite - 'startTestSuite' => ['PHPUnit\Runner\BeforeFirstTestHook', 'executeBeforeFirstTest'], - 'endTestSuite' => ['PHPUnit\Runner\AfterLastTestHook', 'executeAfterLastTest'], - ]; - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Refactor "*TestListener.php" to particular "*Hook.php" files', - [ - new CodeSample( - <<<'CODE_SAMPLE' -namespace App\Tests; - -use PHPUnit\Framework\TestListener; - -final class BeforeListHook implements TestListener -{ - public function addError(Test $test, \Throwable $t, float $time): void - { - } - - public function addWarning(Test $test, Warning $e, float $time): void - { - } - - public function addFailure(Test $test, AssertionFailedError $e, float $time): void - { - } - - public function addIncompleteTest(Test $test, \Throwable $t, float $time): void - { - } - - public function addRiskyTest(Test $test, \Throwable $t, float $time): void - { - } - - public function addSkippedTest(Test $test, \Throwable $t, float $time): void - { - } - - public function startTestSuite(TestSuite $suite): void - { - } - - public function endTestSuite(TestSuite $suite): void - { - } - - public function startTest(Test $test): void - { - echo 'start test!'; - } - - public function endTest(Test $test, float $time): void - { - echo $time; - } -} -CODE_SAMPLE - , -<<<'CODE_SAMPLE' -namespace App\Tests; - -final class BeforeListHook implements \PHPUnit\Runner\BeforeTestHook, \PHPUnit\Runner\AfterTestHook -{ - public function executeBeforeTest(Test $test): void - { - echo 'start test!'; - } - - public function executeAfterTest(Test $test, float $time): void - { - echo $time; - } -} -CODE_SAMPLE - ), - ]); - } - - /** - * List of nodes this class checks, classes that implement @see \PhpParser\Node - * @return array> - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * Process Node of matched type - * @param Class_ $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->isObjectType($node, new ObjectType('PHPUnit\Framework\TestListener'))) { - return null; - } - - foreach ($node->implements as $implement) { - if ($this->isName($implement, 'PHPUnit\Framework\TestListener')) { - $this->removeNode($implement); - } - } - - foreach ($node->getMethods() as $classMethod) { - $this->processClassMethod($node, $classMethod); - } - - return $node; - } - - private function processClassMethod(Class_ $class, ClassMethod $classMethod): void - { - foreach (self::LISTENER_METHOD_TO_HOOK_INTERFACES as $methodName => $hookClassAndMethod) { - /** @var string $methodName */ - if (! $this->isName($classMethod, $methodName)) { - continue; - } - - // remove empty methods - if ($classMethod->stmts === [] || $classMethod->stmts === null) { - $this->removeNode($classMethod); - } else { - $class->implements[] = new FullyQualified($hookClassAndMethod[0]); - $classMethod->name = new Identifier($hookClassAndMethod[1]); - } - } - } -} diff --git a/rules/PHPUnit/Rector/Foreach_/SimplifyForeachInstanceOfRector.php b/rules/PHPUnit/Rector/Foreach_/SimplifyForeachInstanceOfRector.php deleted file mode 100644 index 2c33dc834bc..00000000000 --- a/rules/PHPUnit/Rector/Foreach_/SimplifyForeachInstanceOfRector.php +++ /dev/null @@ -1,108 +0,0 @@ -foreachManipulator = $foreachManipulator; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Simplify unnecessary foreach check of instances', - [ - new CodeSample( - <<<'CODE_SAMPLE' -foreach ($foos as $foo) { - $this->assertInstanceOf(SplFileInfo::class, $foo); -} -CODE_SAMPLE - , - '$this->assertContainsOnlyInstancesOf(\SplFileInfo::class, $foos);' - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [Foreach_::class]; - } - - /** - * @param Foreach_ $node - */ - public function refactor(Node $node): ?Node - { - /** @var MethodCall|StaticCall|null $matchedNode */ - $matchedNode = $this->foreachManipulator->matchOnlyStmt( - $node, - function (Node $node, Foreach_ $foreachNode): ?Node { - if (! $node instanceof MethodCall && ! $node instanceof StaticCall) { - return null; - } - - if (! $this->isName($node->name, 'assertInstanceOf')) { - return null; - } - - if (! $this->nodeComparator->areNodesEqual($foreachNode->valueVar, $node->args[1]->value)) { - return null; - } - - return $node; - } - ); - - if ($matchedNode === null) { - return null; - } - - /** @var MethodCall|StaticCall $matchedNode */ - $callClass = get_class($matchedNode); - - return new $callClass( - $this->resolveVar($matchedNode), - new Name('assertContainsOnlyInstancesOf'), - [$matchedNode->args[0], new Arg($node->expr)] - ); - } - - /** - * @param MethodCall|StaticCall $node - */ - private function resolveVar(Node $node): Node - { - if ($node instanceof MethodCall) { - return $node->var; - } - - return $node->class; - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector.php b/rules/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector.php deleted file mode 100644 index b670d1282df..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/AssertCompareToSpecificMethodRector.php +++ /dev/null @@ -1,154 +0,0 @@ -functionNamesWithAssertMethods = [ - new FunctionNameWithAssertMethods('count', self::ASSERT_COUNT, self::ASSERT_NOT_COUNT), - new FunctionNameWithAssertMethods('sizeof', self::ASSERT_COUNT, self::ASSERT_NOT_COUNT), - new FunctionNameWithAssertMethods('iterator_count', self::ASSERT_COUNT, self::ASSERT_NOT_COUNT), - new FunctionNameWithAssertMethods('gettype', 'assertInternalType', 'assertNotInternalType'), - new FunctionNameWithAssertMethods('get_class', 'assertInstanceOf', 'assertNotInstanceOf'), - ]; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Turns vague php-only method in PHPUnit TestCase to more specific', - [ - new CodeSample( - '$this->assertSame(10, count($anything), "message");', - '$this->assertCount(10, $anything, "message");' - ), - new CodeSample( - '$this->assertNotEquals(get_class($value), stdClass::class);', - '$this->assertNotInstanceOf(stdClass::class, $value);' - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames( - $node, - ['assertSame', 'assertNotSame', 'assertEquals', 'assertNotEquals'] - )) { - return null; - } - - // we need 2 args - if (! isset($node->args[1])) { - return null; - } - - $firstArgument = $node->args[0]; - $secondArgument = $node->args[1]; - $firstArgumentValue = $firstArgument->value; - $secondArgumentValue = $secondArgument->value; - - if ($secondArgumentValue instanceof FuncCall) { - return $this->processFuncCallArgumentValue($node, $secondArgumentValue, $firstArgument); - } - - if ($firstArgumentValue instanceof FuncCall) { - return $this->processFuncCallArgumentValue($node, $firstArgumentValue, $secondArgument); - } - - return null; - } - - /** - * @param MethodCall|StaticCall $node - * @return MethodCall|StaticCall|null - */ - private function processFuncCallArgumentValue(Node $node, FuncCall $funcCall, Arg $requiredArg): ?Node - { - foreach ($this->functionNamesWithAssertMethods as $functionNameWithAssertMethod) { - if (! $this->isName($funcCall, $functionNameWithAssertMethod->getFunctionName())) { - continue; - } - - $this->renameMethod($node, $functionNameWithAssertMethod); - $this->moveFunctionArgumentsUp($node, $funcCall, $requiredArg); - - return $node; - } - - return null; - } - - /** - * @param MethodCall|StaticCall $node - */ - private function renameMethod(Node $node, FunctionNameWithAssertMethods $functionNameWithAssertMethods): void - { - if ($this->isNames($node->name, ['assertSame', 'assertEquals'])) { - $node->name = new Identifier($functionNameWithAssertMethods->getAssetMethodName()); - } elseif ($this->isNames($node->name, ['assertNotSame', 'assertNotEquals'])) { - $node->name = new Identifier($functionNameWithAssertMethods->getNotAssertMethodName()); - } - } - - /** - * Handles custom error messages to not be overwrite by function with multiple args. - * @param StaticCall|MethodCall $node - */ - private function moveFunctionArgumentsUp(Node $node, FuncCall $funcCall, Arg $requiredArg): void - { - $node->args[1] = $funcCall->args[0]; - $node->args[0] = $requiredArg; - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/AssertComparisonToSpecificMethodRector.php b/rules/PHPUnit/Rector/MethodCall/AssertComparisonToSpecificMethodRector.php deleted file mode 100644 index 8b7812c49fa..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/AssertComparisonToSpecificMethodRector.php +++ /dev/null @@ -1,179 +0,0 @@ -identifierManipulator = $identifierManipulator; - - $this->binaryOpWithAssertMethods = [ - new BinaryOpWithAssertMethod(Identical::class, 'assertSame', 'assertNotSame'), - new BinaryOpWithAssertMethod(NotIdentical::class, 'assertNotSame', 'assertSame'), - new BinaryOpWithAssertMethod(Equal::class, 'assertEquals', 'assertNotEquals'), - new BinaryOpWithAssertMethod(NotEqual::class, 'assertNotEquals', 'assertEquals'), - new BinaryOpWithAssertMethod(Greater::class, 'assertGreaterThan', 'assertLessThan'), - new BinaryOpWithAssertMethod(Smaller::class, 'assertLessThan', 'assertGreaterThan'), - new BinaryOpWithAssertMethod( - GreaterOrEqual::class, - 'assertGreaterThanOrEqual', - 'assertLessThanOrEqual' - ), - new BinaryOpWithAssertMethod( - SmallerOrEqual::class, - 'assertLessThanOrEqual', - 'assertGreaterThanOrEqual' - ), - ]; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Turns comparison operations to their method name alternatives in PHPUnit TestCase', - [ - new CodeSample( - '$this->assertTrue($foo === $bar, "message");', - '$this->assertSame($bar, $foo, "message");' - ), - new CodeSample( - '$this->assertFalse($foo >= $bar, "message");', - '$this->assertLessThanOrEqual($bar, $foo, "message");' - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames($node, ['assertTrue', 'assertFalse'])) { - return null; - } - - $firstArgumentValue = $node->args[0]->value; - if (! $firstArgumentValue instanceof BinaryOp) { - return null; - } - - return $this->processCallWithBinaryOp($node, $firstArgumentValue); - } - - /** - * @param MethodCall|StaticCall $node - */ - private function processCallWithBinaryOp(Node $node, BinaryOp $binaryOp): ?Node - { - $binaryOpClass = get_class($binaryOp); - - foreach ($this->binaryOpWithAssertMethods as $binaryOpWithAssertMethod) { - if ($binaryOpClass !== $binaryOpWithAssertMethod->getBinaryOpClass()) { - continue; - } - - $this->identifierManipulator->renameNodeWithMap($node, [ - 'assertTrue' => $binaryOpWithAssertMethod->getAssetMethodName(), - 'assertFalse' => $binaryOpWithAssertMethod->getNotAssertMethodName(), - ]); - - $this->changeArgumentsOrder($node); - - return $node; - } - - return null; - } - - /** - * @param MethodCall|StaticCall $node - */ - private function changeArgumentsOrder(Node $node): void - { - $oldArguments = $node->args; - - /** @var BinaryOp $expression */ - $expression = $oldArguments[0]->value; - - if ($this->isConstantValue($expression->left)) { - $firstArgument = new Arg($expression->left); - $secondArgument = new Arg($expression->right); - } else { - $firstArgument = new Arg($expression->right); - $secondArgument = new Arg($expression->left); - } - - unset($oldArguments[0]); - $newArgs = [$firstArgument, $secondArgument]; - $node->args = $this->appendArgs($newArgs, $oldArguments); - } - - private function isConstantValue(Expr $expr): bool - { - $nodeClass = get_class($expr); - if (in_array($nodeClass, [Array_::class, ConstFetch::class], true)) { - return true; - } - - if (is_subclass_of($expr, Scalar::class)) { - return true; - } - - return $this->nodeNameResolver->isVariableName($expr, 'exp*'); - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector.php b/rules/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector.php deleted file mode 100644 index 2249ceaf946..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector.php +++ /dev/null @@ -1,175 +0,0 @@ -assertCallFactory = $assertCallFactory; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Change assertEquals()/assertNotEquals() method parameters to new specific alternatives', - [ - new CodeSample( - <<<'CODE_SAMPLE' -final class SomeTest extends \PHPUnit\Framework\TestCase -{ - public function test() - { - $value = 'value'; - $this->assertEquals('string', $value, 'message', 5.0); - - $this->assertEquals('string', $value, 'message', 0.0, 20); - - $this->assertEquals('string', $value, 'message', 0.0, 10, true); - - $this->assertEquals('string', $value, 'message', 0.0, 10, false, true); - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -final class SomeTest extends \PHPUnit\Framework\TestCase -{ - public function test() - { - $value = 'value'; - $this->assertEqualsWithDelta('string', $value, 5.0, 'message'); - - $this->assertEquals('string', $value, 'message', 0.0); - - $this->assertEqualsCanonicalizing('string', $value, 'message'); - - $this->assertEqualsIgnoringCase('string', $value, 'message'); - } -} -CODE_SAMPLE - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames($node, ['assertEquals', 'assertNotEquals'])) { - return null; - } - - // 1. refactor to "assertEqualsIgnoringCase()" - $this->processAssertEqualsIgnoringCase($node); - - // 2. refactor to "assertEqualsCanonicalizing()" - $this->processAssertEqualsCanonicalizing($node); - - // 3. remove $maxDepth - if (isset($node->args[4])) { - // add new node only in case of non-default value - unset($node->args[4]); - } - - // 4. refactor $delta to "assertEqualsWithDelta()" - $this->processAssertEqualsWithDelta($node); - - return $node; - } - - /** - * @param MethodCall|StaticCall $node - */ - private function processAssertEqualsIgnoringCase(Node $node): void - { - if (isset($node->args[6])) { - if ($this->valueResolver->isTrue($node->args[6]->value)) { - $newMethodCall = $this->assertCallFactory->createCallWithName($node, 'assertEqualsIgnoringCase'); - $newMethodCall->args[0] = $node->args[0]; - $newMethodCall->args[1] = $node->args[1]; - $newMethodCall->args[2] = $node->args[2]; - $this->addNodeAfterNode($newMethodCall, $node); - } - - unset($node->args[6]); - } - } - - /** - * @param MethodCall|StaticCall $node - */ - private function processAssertEqualsCanonicalizing(Node $node): void - { - if (isset($node->args[5])) { - // add new node only in case of non-default value - if ($this->valueResolver->isTrue($node->args[5]->value)) { - $newMethodCall = $this->assertCallFactory->createCallWithName($node, 'assertEqualsCanonicalizing'); - $newMethodCall->args[0] = $node->args[0]; - $newMethodCall->args[1] = $node->args[1]; - $newMethodCall->args[2] = $node->args[2]; - $this->addNodeAfterNode($newMethodCall, $node); - } - - unset($node->args[5]); - } - } - - /** - * @param MethodCall|StaticCall $node - */ - private function processAssertEqualsWithDelta(Node $node): void - { - if (isset($node->args[3])) { - // add new node only in case of non-default value - if (! $this->valueResolver->isValue($node->args[3]->value, 0.0)) { - $newMethodCall = $this->assertCallFactory->createCallWithName($node, 'assertEqualsWithDelta'); - $newMethodCall->args[0] = $node->args[0]; - $newMethodCall->args[1] = $node->args[1]; - $newMethodCall->args[2] = $node->args[3]; - $newMethodCall->args[3] = $node->args[2]; - $this->addNodeAfterNode($newMethodCall, $node); - } - - unset($node->args[3]); - } - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector.php b/rules/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector.php deleted file mode 100644 index 46d65814c5c..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/AssertEqualsToSameRector.php +++ /dev/null @@ -1,111 +0,0 @@ - - */ - private const RENAME_METHODS_MAP = [ - 'assertEquals' => 'assertSame', - ]; - - /** - * We exclude - * - bool because this is taken care of AssertEqualsParameterToSpecificMethodsTypeRector - * - null because this is taken care of AssertEqualsParameterToSpecificMethodsTypeRector - * - * @var array> - */ - private const SCALAR_TYPES = [FloatType::class, IntegerType::class, StringType::class]; - - /** - * @var IdentifierManipulator - */ - private $identifierManipulator; - - /** - * @var TestsNodeAnalyzer - */ - private $testsNodeAnalyzer; - - public function __construct(IdentifierManipulator $identifierManipulator, TestsNodeAnalyzer $testsNodeAnalyzer) - { - $this->identifierManipulator = $identifierManipulator; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Turns `assertEquals()` into stricter `assertSame()` for scalar values in PHPUnit TestCase', - [ - new CodeSample( - '$this->assertEquals(2, $result, "message");', - '$this->assertSame(2, $result, "message");' - ), - new CodeSample( - '$this->assertEquals($aString, $result, "message");', - '$this->assertSame($aString, $result, "message");' - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isInTestClass($node)) { - return null; - } - - $methodNames = array_keys(self::RENAME_METHODS_MAP); - if (! $this->isNames($node->name, $methodNames)) { - return null; - } - - if (! isset($node->args[0])) { - return null; - } - - $valueNode = $node->args[0]; - $valueNodeType = $this->nodeTypeResolver->resolve($valueNode->value); - if (! StaticInstanceOf::isOneOf($valueNodeType, self::SCALAR_TYPES)) { - return null; - } - - $this->identifierManipulator->renameNodeWithMap($node, self::RENAME_METHODS_MAP); - - return $node; - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/AssertFalseStrposToContainsRector.php b/rules/PHPUnit/Rector/MethodCall/AssertFalseStrposToContainsRector.php deleted file mode 100644 index 9e32c698b9d..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/AssertFalseStrposToContainsRector.php +++ /dev/null @@ -1,122 +0,0 @@ - - */ - private const RENAME_METHODS_MAP = [ - 'assertFalse' => 'assertNotContains', - 'assertNotFalse' => 'assertContains', - ]; - - /** - * @var IdentifierManipulator - */ - private $identifierManipulator; - - /** - * @var TestsNodeAnalyzer - */ - private $testsNodeAnalyzer; - - public function __construct(IdentifierManipulator $identifierManipulator, TestsNodeAnalyzer $testsNodeAnalyzer) - { - $this->identifierManipulator = $identifierManipulator; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Turns `strpos`/`stripos` comparisons to their method name alternatives in PHPUnit TestCase', - [ - new CodeSample( - '$this->assertFalse(strpos($anything, "foo"), "message");', - '$this->assertNotContains("foo", $anything, "message");' - ), - new CodeSample( - '$this->assertNotFalse(stripos($anything, "foo"), "message");', - '$this->assertContains("foo", $anything, "message");' - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - $oldMethodName = array_keys(self::RENAME_METHODS_MAP); - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames($node, $oldMethodName)) { - return null; - } - - $firstArgumentValue = $node->args[0]->value; - if ($firstArgumentValue instanceof StaticCall) { - return null; - } - - if ($firstArgumentValue instanceof MethodCall) { - return null; - } - - if (! $this->isNames($firstArgumentValue, ['strpos', 'stripos'])) { - return null; - } - - $this->identifierManipulator->renameNodeWithMap($node, self::RENAME_METHODS_MAP); - - return $this->changeArgumentsOrder($node); - } - - /** - * @param MethodCall|StaticCall $node - * @return MethodCall|StaticCall|null - */ - private function changeArgumentsOrder(Node $node): ?Node - { - $oldArguments = $node->args; - - $strposFuncCallNode = $oldArguments[0]->value; - if (! $strposFuncCallNode instanceof FuncCall) { - return null; - } - - $firstArgument = $strposFuncCallNode->args[1]; - $secondArgument = $strposFuncCallNode->args[0]; - - unset($oldArguments[0]); - - $newArgs = [$firstArgument, $secondArgument]; - $node->args = $this->appendArgs($newArgs, $oldArguments); - - return $node; - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/AssertInstanceOfComparisonRector.php b/rules/PHPUnit/Rector/MethodCall/AssertInstanceOfComparisonRector.php deleted file mode 100644 index 2c61ea7a815..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/AssertInstanceOfComparisonRector.php +++ /dev/null @@ -1,115 +0,0 @@ - - */ - private const RENAME_METHODS_MAP = [ - 'assertTrue' => 'assertInstanceOf', - 'assertFalse' => 'assertNotInstanceOf', - ]; - - /** - * @var IdentifierManipulator - */ - private $identifierManipulator; - - /** - * @var TestsNodeAnalyzer - */ - private $testsNodeAnalyzer; - - public function __construct(IdentifierManipulator $identifierManipulator, TestsNodeAnalyzer $testsNodeAnalyzer) - { - $this->identifierManipulator = $identifierManipulator; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Turns instanceof comparisons to their method name alternatives in PHPUnit TestCase', - [ - new CodeSample( - '$this->assertTrue($foo instanceof Foo, "message");', - '$this->assertInstanceOf("Foo", $foo, "message");' - ), - new CodeSample( - '$this->assertFalse($foo instanceof Foo, "message");', - '$this->assertNotInstanceOf("Foo", $foo, "message");' - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - $oldMethodNames = array_keys(self::RENAME_METHODS_MAP); - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames($node, $oldMethodNames)) { - return null; - } - - $firstArgumentValue = $node->args[0]->value; - if (! $firstArgumentValue instanceof Instanceof_) { - return null; - } - $this->identifierManipulator->renameNodeWithMap($node, self::RENAME_METHODS_MAP); - $this->changeArgumentsOrder($node); - - return $node; - } - - /** - * @param MethodCall|StaticCall $node - */ - private function changeArgumentsOrder(Node $node): void - { - $oldArguments = $node->args; - /** @var Instanceof_ $comparison */ - $comparison = $oldArguments[0]->value; - - $argument = $comparison->expr; - unset($oldArguments[0]); - - $className = $this->getName($comparison->class); - if ($className === null) { - throw new ShouldNotHappenException(); - } - - $node->args = array_merge([ - new Arg($this->nodeFactory->createClassConstReference($className)), - new Arg($argument), - ], $oldArguments); - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/AssertIssetToSpecificMethodRector.php b/rules/PHPUnit/Rector/MethodCall/AssertIssetToSpecificMethodRector.php deleted file mode 100644 index 5509e14636e..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/AssertIssetToSpecificMethodRector.php +++ /dev/null @@ -1,145 +0,0 @@ -identifierManipulator = $identifierManipulator; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Turns isset comparisons to their method name alternatives in PHPUnit TestCase', - [ - new CodeSample( - '$this->assertTrue(isset($anything->foo));', - '$this->assertObjectHasAttribute("foo", $anything);' - ), - new CodeSample( - '$this->assertFalse(isset($anything["foo"]), "message");', - '$this->assertArrayNotHasKey("foo", $anything, "message");' - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames($node, [self::ASSERT_TRUE, self::ASSERT_FALSE])) { - return null; - } - - $firstArgumentValue = $node->args[0]->value; - // is property access - if (! $firstArgumentValue instanceof Isset_) { - return null; - } - $variableNodeClass = get_class($firstArgumentValue->vars[0]); - if (! in_array($variableNodeClass, [ArrayDimFetch::class, PropertyFetch::class], true)) { - return null; - } - /** @var Isset_ $issetNode */ - $issetNode = $node->args[0]->value; - - $issetNodeArg = $issetNode->vars[0]; - - if ($issetNodeArg instanceof PropertyFetch) { - $this->refactorPropertyFetchNode($node, $issetNodeArg); - } elseif ($issetNodeArg instanceof ArrayDimFetch) { - $this->refactorArrayDimFetchNode($node, $issetNodeArg); - } - - return $node; - } - - /** - * @param MethodCall|StaticCall $node - */ - private function refactorPropertyFetchNode(Node $node, PropertyFetch $propertyFetch): void - { - $name = $this->getName($propertyFetch); - if ($name === null) { - return; - } - - $this->identifierManipulator->renameNodeWithMap($node, [ - self::ASSERT_TRUE => 'assertObjectHasAttribute', - self::ASSERT_FALSE => 'assertObjectNotHasAttribute', - ]); - - $oldArgs = $node->args; - unset($oldArgs[0]); - - $newArgs = $this->nodeFactory->createArgs([new String_($name), $propertyFetch->var]); - $node->args = $this->appendArgs($newArgs, $oldArgs); - } - - /** - * @param MethodCall|StaticCall $node - */ - private function refactorArrayDimFetchNode(Node $node, ArrayDimFetch $arrayDimFetch): void - { - $this->identifierManipulator->renameNodeWithMap($node, [ - self::ASSERT_TRUE => 'assertArrayHasKey', - self::ASSERT_FALSE => 'assertArrayNotHasKey', - ]); - - $oldArgs = $node->args; - - unset($oldArgs[0]); - - $node->args = array_merge($this->nodeFactory->createArgs([$arrayDimFetch->dim, $arrayDimFetch->var]), $oldArgs); - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/AssertNotOperatorRector.php b/rules/PHPUnit/Rector/MethodCall/AssertNotOperatorRector.php deleted file mode 100644 index 86cf5dc93d3..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/AssertNotOperatorRector.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ - private const RENAME_METHODS_MAP = [ - 'assertTrue' => 'assertFalse', - 'assertFalse' => 'assertTrue', - ]; - - /** - * @var IdentifierManipulator - */ - private $identifierManipulator; - - /** - * @var TestsNodeAnalyzer - */ - private $testsNodeAnalyzer; - - public function __construct(IdentifierManipulator $identifierManipulator, TestsNodeAnalyzer $testsNodeAnalyzer) - { - $this->identifierManipulator = $identifierManipulator; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Turns not-operator comparisons to their method name alternatives in PHPUnit TestCase', - [ - new CodeSample('$this->assertTrue(!$foo, "message");', '$this->assertFalse($foo, "message");'), - new CodeSample('$this->assertFalse(!$foo, "message");', '$this->assertTrue($foo, "message");'), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - $oldMethodNames = array_keys(self::RENAME_METHODS_MAP); - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames($node, $oldMethodNames)) { - return null; - } - - $firstArgumentValue = $node->args[0]->value; - if (! $firstArgumentValue instanceof BooleanNot) { - return null; - } - - $this->identifierManipulator->renameNodeWithMap($node, self::RENAME_METHODS_MAP); - - $oldArguments = $node->args; - /** @var BooleanNot $negation */ - $negation = $oldArguments[0]->value; - - $expression = $negation->expr; - - unset($oldArguments[0]); - - $node->args = array_merge([new Arg($expression)], $oldArguments); - - return $node; - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector.php b/rules/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector.php deleted file mode 100644 index 08634916a15..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/AssertPropertyExistsRector.php +++ /dev/null @@ -1,132 +0,0 @@ - - */ - private const RENAME_METHODS_WITH_OBJECT_MAP = [ - 'assertTrue' => 'assertObjectHasAttribute', - 'assertFalse' => 'assertObjectNotHasAttribute', - ]; - - /** - * @var array - */ - private const RENAME_METHODS_WITH_CLASS_MAP = [ - 'assertTrue' => 'assertClassHasAttribute', - 'assertFalse' => 'assertClassNotHasAttribute', - ]; - - /** - * @var IdentifierManipulator - */ - private $identifierManipulator; - - /** - * @var TestsNodeAnalyzer - */ - private $testsNodeAnalyzer; - - public function __construct(IdentifierManipulator $identifierManipulator, TestsNodeAnalyzer $testsNodeAnalyzer) - { - $this->identifierManipulator = $identifierManipulator; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Turns `property_exists` comparisons to their method name alternatives in PHPUnit TestCase', - [ - new CodeSample( - '$this->assertTrue(property_exists(new Class, "property"), "message");', - '$this->assertClassHasAttribute("property", "Class", "message");' - ), - new CodeSample( - '$this->assertFalse(property_exists(new Class, "property"), "message");', - '$this->assertClassNotHasAttribute("property", "Class", "message");' - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames($node, ['assertTrue', 'assertFalse'])) { - return null; - } - - $firstArgumentValue = $node->args[0]->value; - if (! $firstArgumentValue instanceof FuncCall) { - return null; - } - - if (! $this->isName($firstArgumentValue, 'property_exists')) { - return null; - } - - $propertyExistsMethodCall = $node->args[0]->value; - if (! $propertyExistsMethodCall instanceof FuncCall) { - return null; - } - - $firstArgument = $propertyExistsMethodCall->args[0]; - $secondArgument = $propertyExistsMethodCall->args[1]; - - if ($firstArgument->value instanceof Variable) { - $secondArg = new Variable($firstArgument->value->name); - $map = self::RENAME_METHODS_WITH_OBJECT_MAP; - } elseif ($firstArgument->value instanceof New_) { - $secondArg = $this->getName($firstArgument->value->class); - $map = self::RENAME_METHODS_WITH_CLASS_MAP; - } else { - return null; - } - - if (! $secondArgument->value instanceof String_) { - return null; - } - - unset($node->args[0]); - - $newArgs = $this->nodeFactory->createArgs([$secondArgument->value->value, $secondArg]); - - $node->args = $this->appendArgs($newArgs, $node->args); - - $this->identifierManipulator->renameNodeWithMap($node, $map); - - return $node; - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/AssertRegExpRector.php b/rules/PHPUnit/Rector/MethodCall/AssertRegExpRector.php deleted file mode 100644 index 06113d9d901..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/AssertRegExpRector.php +++ /dev/null @@ -1,166 +0,0 @@ -testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Turns `preg_match` comparisons to their method name alternatives in PHPUnit TestCase', - [ - new CodeSample( - '$this->assertSame(1, preg_match("/^Message for ".*"\.$/", $string), $message);', - '$this->assertRegExp("/^Message for ".*"\.$/", $string, $message);' - ), - new CodeSample( - '$this->assertEquals(false, preg_match("/^Message for ".*"\.$/", $string), $message);', - '$this->assertNotRegExp("/^Message for ".*"\.$/", $string, $message);' - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames( - $node, - [self::ASSERT_SAME, self::ASSERT_EQUALS, self::ASSERT_NOT_SAME, self::ASSERT_NOT_EQUALS] - )) { - return null; - } - - /** @var FuncCall|Node $secondArgumentValue */ - $secondArgumentValue = $node->args[1]->value; - - if (! $secondArgumentValue instanceof FuncCall) { - return null; - } - - if (! $this->isName($secondArgumentValue, 'preg_match')) { - return null; - } - - $oldMethodName = $this->getName($node->name); - if ($oldMethodName === null) { - return null; - } - - $oldFirstArgument = $node->args[0]->value; - $oldCondition = $this->resolveOldCondition($oldFirstArgument); - - $this->renameMethod($node, $oldMethodName, $oldCondition); - $this->moveFunctionArgumentsUp($node); - - return $node; - } - - private function resolveOldCondition(Expr $expr): int - { - if ($expr instanceof LNumber) { - return $expr->value; - } - - if ($expr instanceof ConstFetch) { - return $this->valueResolver->isTrue($expr) ? 1 : 0; - } - - throw new ShouldNotHappenException(); - } - - /** - * @param MethodCall|StaticCall $node - */ - private function renameMethod(Node $node, string $oldMethodName, int $oldCondition): void - { - if (in_array($oldMethodName, [self::ASSERT_SAME, self::ASSERT_EQUALS], true) && $oldCondition === 1 - || in_array($oldMethodName, [self::ASSERT_NOT_SAME, self::ASSERT_NOT_EQUALS], true) && $oldCondition === 0 - ) { - $node->name = new Identifier('assertRegExp'); - } - - if (in_array($oldMethodName, [self::ASSERT_SAME, self::ASSERT_EQUALS], true) && $oldCondition === 0 - || in_array($oldMethodName, [self::ASSERT_NOT_SAME, self::ASSERT_NOT_EQUALS], true) && $oldCondition === 1 - ) { - $node->name = new Identifier('assertNotRegExp'); - } - } - - /** - * @param MethodCall|StaticCall $node - */ - private function moveFunctionArgumentsUp(Node $node): void - { - $oldArguments = $node->args; - - /** @var FuncCall $pregMatchFunction */ - $pregMatchFunction = $oldArguments[1]->value; - - $regex = $pregMatchFunction->args[0]; - $variable = $pregMatchFunction->args[1]; - - unset($oldArguments[0], $oldArguments[1]); - - $node->args = array_merge([$regex, $variable], $oldArguments); - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/AssertResourceToClosedResourceRector.php b/rules/PHPUnit/Rector/MethodCall/AssertResourceToClosedResourceRector.php deleted file mode 100644 index e44583dc3ca..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/AssertResourceToClosedResourceRector.php +++ /dev/null @@ -1,89 +0,0 @@ - - */ - private const RENAME_METHODS_MAP = [ - 'assertIsNotResource' => 'assertIsClosedResource', - ]; - - /** - * @var IdentifierManipulator - */ - private $identifierManipulator; - - /** - * @var TestsNodeAnalyzer - */ - private $testsNodeAnalyzer; - - public function __construct(IdentifierManipulator $identifierManipulator, TestsNodeAnalyzer $testsNodeAnalyzer) - { - $this->identifierManipulator = $identifierManipulator; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Turns `assertIsNotResource()` into stricter `assertIsClosedResource()` for resource values in PHPUnit TestCase', - [ - new CodeSample( - '$this->assertIsNotResource($aResource, "message");', - '$this->assertIsClosedResource($aResource, "message");' - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isInTestClass($node)) { - return null; - } - - $methodNames = array_keys(self::RENAME_METHODS_MAP); - if (! $this->isNames($node->name, $methodNames)) { - return null; - } - - if (! isset($node->args[0])) { - return null; - } - - $this->identifierManipulator->renameNodeWithMap($node, self::RENAME_METHODS_MAP); - - return $node; - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector.php b/rules/PHPUnit/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector.php deleted file mode 100644 index 0629f579448..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector.php +++ /dev/null @@ -1,116 +0,0 @@ -identifierManipulator = $identifierManipulator; - - $this->constantWithAssertMethods = [ - new ConstantWithAssertMethods('null', 'assertNull', 'assertNotNull'), - new ConstantWithAssertMethods('true', 'assertTrue', 'assertNotTrue'), - new ConstantWithAssertMethods('false', 'assertFalse', 'assertNotFalse'), - ]; - $this->argumentMover = $argumentMover; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Turns same bool and null comparisons to their method name alternatives in PHPUnit TestCase', - [ - new CodeSample('$this->assertSame(null, $anything);', '$this->assertNull($anything);'), - new CodeSample('$this->assertNotSame(false, $anything);', '$this->assertNotFalse($anything);'), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames($node, ['assertSame', 'assertNotSame'])) { - return null; - } - $firstArgumentValue = $node->args[0]->value; - if (! $firstArgumentValue instanceof ConstFetch) { - return null; - } - - foreach ($this->constantWithAssertMethods as $constantWithAssertMethod) { - if (! $this->isName($firstArgumentValue, $constantWithAssertMethod->getConstant())) { - continue; - } - - $this->renameMethod($node, $constantWithAssertMethod); - $this->argumentMover->removeFirst($node); - - return $node; - } - - return null; - } - - /** - * @param MethodCall|StaticCall $node - */ - private function renameMethod(Node $node, ConstantWithAssertMethods $constantWithAssertMethods): void - { - $this->identifierManipulator->renameNodeWithMap($node, [ - 'assertSame' => $constantWithAssertMethods->getAssetMethodName(), - 'assertNotSame' => $constantWithAssertMethods->getNotAssertMethodName(), - ]); - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector.php b/rules/PHPUnit/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector.php deleted file mode 100644 index 4a9b582fc04..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector.php +++ /dev/null @@ -1,111 +0,0 @@ -argumentMover = $argumentMover; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Change $this->assertSame(true, ...) to assertTrue()', - [ - new CodeSample( - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; - -final class SomeTest extends TestCase -{ - public function test() - { - $value = (bool) mt_rand(0, 1); - $this->assertSame(true, $value); - } -} -CODE_SAMPLE - - , - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; - -final class SomeTest extends TestCase -{ - public function test() - { - $value = (bool) mt_rand(0, 1); - $this->assertTrue($value); - } -} -CODE_SAMPLE - - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class]; - } - - /** - * @param MethodCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames( - $node, - ['assertSame', 'assertEqual', 'assertNotSame', 'assertNotEqual'] - )) { - return null; - } - - if ($this->valueResolver->isTrue($node->args[0]->value)) { - $this->argumentMover->removeFirst($node); - - $node->name = new Identifier('assertTrue'); - - return $node; - } - - if ($this->valueResolver->isFalse($node->args[0]->value)) { - $this->argumentMover->removeFirst($node); - - $node->name = new Identifier('assertFalse'); - return $node; - } - - return null; - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector.php b/rules/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector.php deleted file mode 100644 index 4fc05338e27..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector.php +++ /dev/null @@ -1,143 +0,0 @@ - - */ - private const OLD_FUNCTIONS_TO_TYPES = [ - 'is_array' => 'array', - 'is_bool' => 'bool', - 'is_callable' => 'callable', - 'is_double' => 'double', - 'is_float' => 'float', - 'is_int' => 'int', - 'is_integer' => 'integer', - 'is_iterable' => 'iterable', - 'is_numeric' => 'numeric', - 'is_object' => 'object', - 'is_real' => 'real', - 'is_resource' => 'resource', - 'is_scalar' => 'scalar', - 'is_string' => 'string', - ]; - - /** - * @var array - */ - private const RENAME_METHODS_MAP = [ - 'assertTrue' => 'assertInternalType', - 'assertFalse' => 'assertNotInternalType', - ]; - - /** - * @var IdentifierManipulator - */ - private $identifierManipulator; - - /** - * @var TestsNodeAnalyzer - */ - private $testsNodeAnalyzer; - - public function __construct(IdentifierManipulator $identifierManipulator, TestsNodeAnalyzer $testsNodeAnalyzer) - { - $this->identifierManipulator = $identifierManipulator; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Turns true/false with internal type comparisons to their method name alternatives in PHPUnit TestCase', - [ - new CodeSample( - '$this->assertTrue(is_{internal_type}($anything), "message");', - '$this->assertInternalType({internal_type}, $anything, "message");' - ), - new CodeSample( - '$this->assertFalse(is_{internal_type}($anything), "message");', - '$this->assertNotInternalType({internal_type}, $anything, "message");' - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - $oldMethods = array_keys(self::RENAME_METHODS_MAP); - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames($node, $oldMethods)) { - return null; - } - - /** @var FuncCall|Node $firstArgumentValue */ - $firstArgumentValue = $node->args[0]->value; - - if (! $firstArgumentValue instanceof FuncCall) { - return null; - } - - $functionName = $this->getName($firstArgumentValue); - if (! isset(self::OLD_FUNCTIONS_TO_TYPES[$functionName])) { - return null; - } - - $this->identifierManipulator->renameNodeWithMap($node, self::RENAME_METHODS_MAP); - - return $this->moveFunctionArgumentsUp($node); - } - - /** - * @param MethodCall|StaticCall $node - */ - private function moveFunctionArgumentsUp(Node $node): Node - { - /** @var FuncCall $isFunctionNode */ - $isFunctionNode = $node->args[0]->value; - - $firstArgumentValue = $isFunctionNode->args[0]->value; - $isFunctionName = $this->getName($isFunctionNode); - - $newArgs = [ - new Arg(new String_(self::OLD_FUNCTIONS_TO_TYPES[$isFunctionName])), - new Arg($firstArgumentValue), - ]; - - $oldArguments = $node->args; - unset($oldArguments[0]); - - $node->args = $this->appendArgs($newArgs, $oldArguments); - - return $node; - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector.php b/rules/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector.php deleted file mode 100644 index 9a215a52815..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector.php +++ /dev/null @@ -1,199 +0,0 @@ -functionNameWithAssertMethods = [ - new FunctionNameWithAssertMethods('is_readable', 'assertIsReadable', 'assertNotIsReadable'), - new FunctionNameWithAssertMethods('array_key_exists', 'assertArrayHasKey', 'assertArrayNotHasKey'), - new FunctionNameWithAssertMethods('array_search', 'assertContains', 'assertNotContains'), - new FunctionNameWithAssertMethods('in_array', 'assertContains', 'assertNotContains'), - new FunctionNameWithAssertMethods('empty', 'assertEmpty', 'assertNotEmpty'), - new FunctionNameWithAssertMethods('file_exists', 'assertFileExists', 'assertFileNotExists'), - new FunctionNameWithAssertMethods('is_dir', 'assertDirectoryExists', 'assertDirectoryNotExists'), - new FunctionNameWithAssertMethods('is_infinite', 'assertInfinite', 'assertFinite'), - new FunctionNameWithAssertMethods('is_null', 'assertNull', 'assertNotNull'), - new FunctionNameWithAssertMethods('is_writable', 'assertIsWritable', 'assertNotIsWritable'), - new FunctionNameWithAssertMethods('is_nan', 'assertNan', ''), - new FunctionNameWithAssertMethods('is_a', 'assertInstanceOf', 'assertNotInstanceOf'), - ]; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Turns true/false comparisons to their method name alternatives in PHPUnit TestCase when possible', - [ - new CodeSample( - '$this->assertTrue(is_readable($readmeFile), "message");', - '$this->assertIsReadable($readmeFile, "message");' - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames( - $node, - ['assertTrue', 'assertFalse', 'assertNotTrue', 'assertNotFalse'] - )) { - return null; - } - - if (! isset($node->args[0])) { - return null; - } - - $firstArgumentValue = $node->args[0]->value; - if (! $firstArgumentValue instanceof FuncCall && ! $firstArgumentValue instanceof Empty_) { - return null; - } - - foreach ($this->functionNameWithAssertMethods as $functionNameWithAssertMethod) { - if (! $this->isName($firstArgumentValue, $functionNameWithAssertMethod->getFunctionName())) { - continue; - } - - $name = $this->getName($firstArgumentValue); - if ($name === null) { - return null; - } - - $this->renameMethod($node, $functionNameWithAssertMethod); - $this->moveFunctionArgumentsUp($node); - - return $node; - } - - return null; - } - - /** - * @param MethodCall|StaticCall $node - */ - private function renameMethod(Node $node, FunctionNameWithAssertMethods $functionNameWithAssertMethods): void - { - /** @var Identifier $identifierNode */ - $identifierNode = $node->name; - $oldMethodName = $identifierNode->toString(); - - if ($functionNameWithAssertMethods->getAssetMethodName() && in_array( - $oldMethodName, - ['assertTrue', 'assertNotFalse'], - true - )) { - $node->name = new Identifier($functionNameWithAssertMethods->getAssetMethodName()); - } - if ($functionNameWithAssertMethods->getNotAssertMethodName() === '') { - return; - } - if (! in_array($oldMethodName, ['assertFalse', 'assertNotTrue'], true)) { - return; - } - $node->name = new Identifier($functionNameWithAssertMethods->getNotAssertMethodName()); - } - - /** - * Before: - * - $this->assertTrue(array_key_exists('...', ['...']), 'second argument'); - * - * After: - * - $this->assertArrayHasKey('...', ['...'], 'second argument'); - * - * @param MethodCall|StaticCall $node - */ - private function moveFunctionArgumentsUp(Node $node): void - { - $funcCallOrEmptyNode = $node->args[0]->value; - if ($funcCallOrEmptyNode instanceof FuncCall) { - $funcCallOrEmptyNodeName = $this->getName($funcCallOrEmptyNode); - if ($funcCallOrEmptyNodeName === null) { - return; - } - - $funcCallOrEmptyNodeArgs = $funcCallOrEmptyNode->args; - $oldArguments = $node->args; - unset($oldArguments[0]); - - $node->args = $this->buildNewArguments( - $funcCallOrEmptyNodeName, - $funcCallOrEmptyNodeArgs, - $oldArguments - ); - } - - if ($funcCallOrEmptyNode instanceof Empty_) { - $node->args[0] = new Arg($funcCallOrEmptyNode->expr); - } - } - - /** - * @param Arg[] $funcCallOrEmptyNodeArgs - * @param Arg[] $oldArguments - * @return mixed[] - */ - private function buildNewArguments( - string $funcCallOrEmptyNodeName, - array $funcCallOrEmptyNodeArgs, - array $oldArguments - ): array { - if (in_array($funcCallOrEmptyNodeName, ['in_array', 'array_search'], true) - && count($funcCallOrEmptyNodeArgs) === 3) { - unset($funcCallOrEmptyNodeArgs[2]); - - return $this->appendArgs($funcCallOrEmptyNodeArgs, $oldArguments); - } - - if ($funcCallOrEmptyNodeName === 'is_a') { - $newArgs = [$funcCallOrEmptyNodeArgs[1], $funcCallOrEmptyNodeArgs[0]]; - - return $this->appendArgs($newArgs, $oldArguments); - } - - return $this->appendArgs($funcCallOrEmptyNodeArgs, $oldArguments); - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector.php b/rules/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector.php deleted file mode 100644 index a932b6288b3..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/CreateMockToCreateStubRector.php +++ /dev/null @@ -1,136 +0,0 @@ -methodCallManipulator = $methodCallManipulator; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Replaces createMock() with createStub() when relevant', - [ - new CodeSample( - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase - -class MyTest extends TestCase -{ - public function testItBehavesAsExpected(): void - { - $stub = $this->createMock(\Exception::class); - $stub->method('getMessage') - ->willReturn('a message'); - - $mock = $this->createMock(\Exception::class); - $mock->expects($this->once()) - ->method('getMessage') - ->willReturn('a message'); - - self::assertSame('a message', $stub->getMessage()); - self::assertSame('a message', $mock->getMessage()); - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase - -class MyTest extends TestCase -{ - public function testItBehavesAsExpected(): void - { - $stub = $this->createStub(\Exception::class); - $stub->method('getMessage') - ->willReturn('a message'); - - $mock = $this->createMock(\Exception::class); - $mock->expects($this->once()) - ->method('getMessage') - ->willReturn('a message'); - - self::assertSame('a message', $stub->getMessage()); - self::assertSame('a message', $mock->getMessage()); - } -} -CODE_SAMPLE - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class]; - } - - /** - * @param MethodCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isInTestClass($node)) { - return null; - } - - if (! $this->isName($node->name, 'createMock')) { - return null; - } - - $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); - if (! $parentNode instanceof Assign) { - return null; - } - - $mockVariable = $parentNode->var; - if (! $mockVariable instanceof Variable) { - return null; - } - - $methodCallNamesOnVariable = $this->methodCallManipulator->findMethodCallNamesOnVariable($mockVariable); - if (in_array('expects', $methodCallNamesOnVariable, true)) { - return null; - } - - $node->name = new Identifier('createStub'); - - return $node; - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector.php b/rules/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector.php deleted file mode 100644 index 004240a2640..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/DelegateExceptionArgumentsRector.php +++ /dev/null @@ -1,106 +0,0 @@ - - */ - private const OLD_TO_NEW_METHOD = [ - 'setExpectedException' => 'expectExceptionMessage', - 'setExpectedExceptionRegExp' => 'expectExceptionMessageRegExp', - ]; - - /** - * @var AssertCallFactory - */ - private $assertCallFactory; - - /** - * @var TestsNodeAnalyzer - */ - private $testsNodeAnalyzer; - - public function __construct(AssertCallFactory $assertCallFactory, TestsNodeAnalyzer $testsNodeAnalyzer) - { - $this->assertCallFactory = $assertCallFactory; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Takes `setExpectedException()` 2nd and next arguments to own methods in PHPUnit.', - [ - new CodeSample( - '$this->setExpectedException(Exception::class, "Message", "CODE");', - <<<'CODE_SAMPLE' -$this->setExpectedException(Exception::class); -$this->expectExceptionMessage('Message'); -$this->expectExceptionCode('CODE'); -CODE_SAMPLE - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - $oldMethodNames = array_keys(self::OLD_TO_NEW_METHOD); - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames($node, $oldMethodNames)) { - return null; - } - - if (isset($node->args[1])) { - /** @var Identifier $identifierNode */ - $identifierNode = $node->name; - $oldMethodName = $identifierNode->name; - - $call = $this->assertCallFactory->createCallWithName($node, self::OLD_TO_NEW_METHOD[$oldMethodName]); - $call->args[] = $node->args[1]; - $this->addNodeAfterNode($call, $node); - - unset($node->args[1]); - - // add exception code method call - if (isset($node->args[2])) { - $call = $this->assertCallFactory->createCallWithName($node, 'expectExceptionCode'); - $call->args[] = $node->args[2]; - $this->addNodeAfterNode($call, $node); - - unset($node->args[2]); - } - } - - $node->name = new Identifier('expectException'); - - return $node; - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector.php b/rules/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector.php deleted file mode 100644 index 53c78644372..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/ExplicitPhpErrorApiRector.php +++ /dev/null @@ -1,146 +0,0 @@ - - */ - private const REPLACEMENTS = [ - 'PHPUnit\Framework\TestCase\Notice' => 'expectNotice', - 'PHPUnit\Framework\TestCase\Deprecated' => 'expectDeprecation', - 'PHPUnit\Framework\TestCase\Error' => 'expectError', - 'PHPUnit\Framework\TestCase\Warning' => 'expectWarning', - ]; - - /** - * @var AssertCallFactory - */ - private $assertCallFactory; - - /** - * @var TestsNodeAnalyzer - */ - private $testsNodeAnalyzer; - - public function __construct(AssertCallFactory $assertCallFactory, TestsNodeAnalyzer $testsNodeAnalyzer) - { - $this->assertCallFactory = $assertCallFactory; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Use explicit API for expecting PHP errors, warnings, and notices', - [ - new CodeSample( - <<<'CODE_SAMPLE' -final class SomeTest extends \PHPUnit\Framework\TestCase -{ - public function test() - { - $this->expectException(\PHPUnit\Framework\TestCase\Deprecated::class); - $this->expectException(\PHPUnit\Framework\TestCase\Error::class); - $this->expectException(\PHPUnit\Framework\TestCase\Notice::class); - $this->expectException(\PHPUnit\Framework\TestCase\Warning::class); - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -final class SomeTest extends \PHPUnit\Framework\TestCase -{ - public function test() - { - $this->expectDeprecation(); - $this->expectError(); - $this->expectNotice(); - $this->expectWarning(); - } -} -CODE_SAMPLE - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames($node, ['expectException'])) { - return null; - } - - foreach (self::REPLACEMENTS as $class => $method) { - $newNode = $this->replaceExceptionWith($node, $class, $method); - if ($newNode !== null) { - return $newNode; - } - } - - return $node; - } - - /** - * @param MethodCall|StaticCall $node - */ - private function replaceExceptionWith(Node $node, string $exceptionClass, string $explicitMethod): ?Node - { - if (! isset($node->args[0])) { - return null; - } - - if (! $this->isClassConstReference($node->args[0]->value, $exceptionClass)) { - return null; - } - - return $this->assertCallFactory->createCallWithName($node, $explicitMethod); - } - - /** - * Detects "SomeClass::class" - */ - private function isClassConstReference(Expr $expr, string $className): bool - { - if (! $expr instanceof ClassConstFetch) { - return false; - } - - if (! $this->isName($expr->name, 'class')) { - return false; - } - - return $this->isName($expr->class, $className); - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector.php b/rules/PHPUnit/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector.php deleted file mode 100644 index ba39f97cf9b..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector.php +++ /dev/null @@ -1,88 +0,0 @@ -getMockBuilder('SomeClass') - ->disableOriginalConstructor() - ->getMock(); - } -} -CODE_SAMPLE -, - <<<'CODE_SAMPLE' -class SomeTest extends \PHPUnit\Framework\TestCase -{ - public function test() - { - $applicationMock = $this->createMock('SomeClass'); - } -} -CODE_SAMPLE - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class]; - } - - /** - * @param MethodCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->isName($node->name, 'getMock')) { - return null; - } - - if (! $node->var instanceof MethodCall) { - return null; - } - - $getMockBuilderMethodCall = $this->isName( - $node->var->name, - 'disableOriginalConstructor' - ) ? $node->var->var : $node->var; - - if (! $getMockBuilderMethodCall instanceof MethodCall) { - return null; - } - - if (! $this->isName($getMockBuilderMethodCall->name, 'getMockBuilder')) { - return null; - } - - $args = $getMockBuilderMethodCall->args; - $thisVariable = $getMockBuilderMethodCall->var; - - return new MethodCall($thisVariable, 'createMock', $args); - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/RemoveExpectAnyFromMockRector.php b/rules/PHPUnit/Rector/MethodCall/RemoveExpectAnyFromMockRector.php deleted file mode 100644 index bd52d8b899c..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/RemoveExpectAnyFromMockRector.php +++ /dev/null @@ -1,108 +0,0 @@ -testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Remove `expect($this->any())` from mocks as it has no added value', - [ - new CodeSample( - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; - -class SomeClass extends TestCase -{ - public function test() - { - $translator = $this->getMock('SomeClass'); - $translator->expects($this->any()) - ->method('trans') - ->willReturn('translated max {{ max }}!'); - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; - -class SomeClass extends TestCase -{ - public function test() - { - $translator = $this->getMock('SomeClass'); - $translator->method('trans') - ->willReturn('translated max {{ max }}!'); - } -} -CODE_SAMPLE - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class]; - } - - /** - * @param MethodCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isInTestClass($node)) { - return null; - } - - if (! $this->isName($node->name, 'expects')) { - return null; - } - - if (count($node->args) !== 1) { - return null; - } - - $onlyArgument = $node->args[0]->value; - if (! $onlyArgument instanceof MethodCall) { - return null; - } - - if (! $this->isName($onlyArgument->var, 'this')) { - return null; - } - - if (! $this->isName($onlyArgument->name, 'any')) { - return null; - } - - return $node->var; - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector.php b/rules/PHPUnit/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector.php deleted file mode 100644 index 02cc9df2bf9..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector.php +++ /dev/null @@ -1,92 +0,0 @@ -testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Change assertArraySubset() to static call of DMS\PHPUnitExtensions\ArraySubset\Assert', - [ - new CodeSample( - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; - -class SomeClass extends TestCase -{ - public function test() - { - self::assertArraySubset(['bar' => 0], ['bar' => '0'], true); - - $this->assertArraySubset(['bar' => 0], ['bar' => '0'], true); - } -} -CODE_SAMPLE -, - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; - -class SomeClass extends TestCase -{ - public function test() - { - \DMS\PHPUnitExtensions\ArraySubset\Assert::assertArraySubset(['bar' => 0], ['bar' => '0'], true); - - \DMS\PHPUnitExtensions\ArraySubset\Assert::assertArraySubset(['bar' => 0], ['bar' => '0'], true); - } -} -CODE_SAMPLE - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodName($node, 'assertArraySubset')) { - return null; - } - - return $this->nodeFactory->createStaticCall('DMS\PHPUnitExtensions\ArraySubset\Assert', 'assertArraySubset', - $node->args - ); - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector.php b/rules/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector.php deleted file mode 100644 index 18fea85ceba..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/SpecificAssertContainsRector.php +++ /dev/null @@ -1,117 +0,0 @@ - - */ - private const OLD_TO_NEW_METHOD_NAMES = [ - 'assertContains' => 'assertStringContainsString', - 'assertNotContains' => 'assertStringNotContainsString', - ]; - - /** - * @var TestsNodeAnalyzer - */ - private $testsNodeAnalyzer; - - public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer) - { - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Change assertContains()/assertNotContains() method to new string and iterable alternatives', - [ - new CodeSample( - <<<'CODE_SAMPLE' -final class SomeTest extends \PHPUnit\Framework\TestCase -{ - public function test() - { - $this->assertContains('foo', 'foo bar'); - $this->assertNotContains('foo', 'foo bar'); - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -final class SomeTest extends \PHPUnit\Framework\TestCase -{ - public function test() - { - $this->assertStringContainsString('foo', 'foo bar'); - $this->assertStringNotContainsString('foo', 'foo bar'); - } -} -CODE_SAMPLE - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames($node, ['assertContains', 'assertNotContains'])) { - return null; - } - - if (! $this->isPossiblyStringType($node->args[1]->value)) { - return null; - } - - $methodName = $this->getName($node->name); - $newMethodName = self::OLD_TO_NEW_METHOD_NAMES[$methodName]; - $node->name = new Identifier($newMethodName); - - return $node; - } - - private function isPossiblyStringType(Expr $expr): bool - { - $exprType = $this->getStaticType($expr); - if ($exprType instanceof UnionType) { - foreach ($exprType->getTypes() as $unionedType) { - if ($unionedType instanceof StringType) { - return true; - } - } - } - - return $exprType instanceof StringType; - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector.php b/rules/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector.php deleted file mode 100644 index a44fd0b31b3..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector.php +++ /dev/null @@ -1,119 +0,0 @@ -> - */ - private const OLD_METHODS_NAMES_TO_NEW_NAMES = [ - 'string' => [ - 'assertContains' => 'assertContainsEquals', - 'assertNotContains' => 'assertNotContainsEquals', - ], - ]; - - /** - * @var TestsNodeAnalyzer - */ - private $testsNodeAnalyzer; - - public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer) - { - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Change assertContains()/assertNotContains() with non-strict comparison to new specific alternatives', - [ - new CodeSample( - <<<'CODE_SAMPLE' -final class SomeTest extends \PHPUnit\Framework\TestCase -{ - public function test() - { - $objects = [ new \stdClass(), new \stdClass(), new \stdClass() ]; - $this->assertContains(new \stdClass(), $objects, 'message', false, false); - $this->assertNotContains(new \stdClass(), $objects, 'message', false, false); - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -final class SomeTest extends TestCase -{ - public function test() - { - $objects = [ new \stdClass(), new \stdClass(), new \stdClass() ]; - $this->assertContainsEquals(new \stdClass(), $objects, 'message'); - $this->assertNotContainsEquals(new \stdClass(), $objects, 'message'); - } -} -CODE_SAMPLE - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames($node, ['assertContains', 'assertNotContains'])) { - return null; - } - - //when second argument is string: do nothing - if ($this->nodeTypeResolver->isStaticType($node->args[1]->value, StringType::class)) { - return null; - } - //when less then 5 arguments given: do nothing - if (! isset($node->args[4])) { - return null; - } - if ($node->args[4]->value === null) { - return null; - } - - //when 5th argument check identity is true: do nothing - if ($this->valueResolver->isValue($node->args[4]->value, true)) { - return null; - } - - /* here we search for element of array without identity check and we can replace functions */ - $methodName = $this->getName($node->name); - - $node->name = new Identifier(self::OLD_METHODS_NAMES_TO_NEW_NAMES['string'][$methodName]); - unset($node->args[3], $node->args[4]); - - return $node; - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/SpecificAssertInternalTypeRector.php b/rules/PHPUnit/Rector/MethodCall/SpecificAssertInternalTypeRector.php deleted file mode 100644 index c3ddf294f62..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/SpecificAssertInternalTypeRector.php +++ /dev/null @@ -1,129 +0,0 @@ - - */ - private const TYPE_TO_METHOD = [ - 'array' => ['assertIsArray', 'assertIsNotArray'], - 'bool' => ['assertIsBool', 'assertIsNotBool'], - 'float' => ['assertIsFloat', 'assertIsNotFloat'], - 'int' => ['assertIsInt', 'assertIsNotInt'], - 'numeric' => ['assertIsNumeric', 'assertIsNotNumeric'], - 'object' => ['assertIsObject', 'assertIsNotObject'], - 'resource' => ['assertIsResource', 'assertIsNotResource'], - 'string' => ['assertIsString', 'assertIsNotString'], - 'scalar' => ['assertIsScalar', 'assertIsNotScalar'], - 'callable' => ['assertIsCallable', 'assertIsNotCallable'], - 'iterable' => ['assertIsIterable', 'assertIsNotIterable'], - 'null' => ['assertNull', 'assertNotNull'], - ]; - - /** - * @var TypeAnalyzer - */ - private $typeAnalyzer; - - /** - * @var TestsNodeAnalyzer - */ - private $testsNodeAnalyzer; - - public function __construct(TypeAnalyzer $typeAnalyzer, TestsNodeAnalyzer $testsNodeAnalyzer) - { - $this->typeAnalyzer = $typeAnalyzer; - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Change assertInternalType()/assertNotInternalType() method to new specific alternatives', - [ - new CodeSample( - <<<'CODE_SAMPLE' -final class SomeTest extends \PHPUnit\Framework\TestCase -{ - public function test() - { - $value = 'value'; - $this->assertInternalType('string', $value); - $this->assertNotInternalType('array', $value); - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -final class SomeTest extends \PHPUnit\Framework\TestCase -{ - public function test() - { - $value = 'value'; - $this->assertIsString($value); - $this->assertIsNotArray($value); - } -} -CODE_SAMPLE - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames($node, ['assertInternalType', 'assertNotInternalType'])) { - return null; - } - - $typeNode = $node->args[0]->value; - if (! $typeNode instanceof String_) { - return null; - } - - $type = $this->typeAnalyzer->normalizeType($typeNode->value); - if (! isset(self::TYPE_TO_METHOD[$type])) { - return null; - } - - array_shift($node->args); - - $position = $this->isName($node->name, 'assertInternalType') ? 0 : 1; - $methodName = self::TYPE_TO_METHOD[$type][$position]; - - $node->name = new Identifier($methodName); - - return $node; - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/UseSpecificWillMethodRector.php b/rules/PHPUnit/Rector/MethodCall/UseSpecificWillMethodRector.php deleted file mode 100644 index a8c20e32ad8..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/UseSpecificWillMethodRector.php +++ /dev/null @@ -1,168 +0,0 @@ - - */ - private const NESTED_METHOD_TO_RENAME_MAP = [ - 'returnArgument' => 'willReturnArgument', - 'returnCallback' => 'willReturnCallback', - 'returnSelf' => 'willReturnSelf', - 'returnValue' => 'willReturn', - 'returnValueMap' => 'willReturnMap', - 'throwException' => 'willThrowException', - ]; - - /** - * @var TestsNodeAnalyzer - */ - private $testsNodeAnalyzer; - - public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer) - { - $this->testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Changes ->will($this->xxx()) to one specific method', - [ - new CodeSample( - <<<'CODE_SAMPLE' -class SomeClass extends PHPUnit\Framework\TestCase -{ - public function test() - { - $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock(); - $translator->expects($this->any()) - ->method('trans') - ->with($this->equalTo('old max {{ max }}!')) - ->will($this->returnValue('translated max {{ max }}!')); - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -class SomeClass extends PHPUnit\Framework\TestCase -{ - public function test() - { - $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock(); - $translator->expects($this->any()) - ->method('trans') - ->with('old max {{ max }}!') - ->willReturnValue('translated max {{ max }}!'); - } -} -CODE_SAMPLE - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isInTestClass($node)) { - return null; - } - - $callerNode = $node instanceof StaticCall ? $node->class : $node->var; - if (! $this->isObjectType( - $callerNode, - new ObjectType('PHPUnit\Framework\MockObject\Builder\InvocationMocker') - )) { - return null; - } - - if ($this->isName($node->name, 'with')) { - return $this->processWithCall($node); - } - - if ($this->isName($node->name, 'will')) { - return $this->processWillCall($node); - } - - return null; - } - - /** - * @param MethodCall|StaticCall $node - * @return MethodCall|StaticCall - */ - private function processWithCall(Node $node): Node - { - foreach ($node->args as $i => $argNode) { - if (! $argNode->value instanceof MethodCall) { - continue; - } - - $methodCall = $argNode->value; - if (! $this->isName($methodCall->name, 'equalTo')) { - continue; - } - - $node->args[$i] = $methodCall->args[0]; - } - - return $node; - } - - /** - * @param MethodCall|StaticCall $node - * @return MethodCall|StaticCall|null - */ - private function processWillCall(Node $node): ?Node - { - if (! $node->args[0]->value instanceof MethodCall) { - return null; - } - - $nestedMethodCall = $node->args[0]->value; - - foreach (self::NESTED_METHOD_TO_RENAME_MAP as $oldMethodName => $newParentMethodName) { - if (! $this->isName($nestedMethodCall->name, $oldMethodName)) { - continue; - } - - $node->name = new Identifier($newParentMethodName); - - // move args up - $node->args = $nestedMethodCall->args; - - return $node; - } - - return null; - } -} diff --git a/rules/PHPUnit/Rector/MethodCall/WithConsecutiveArgToArrayRector.php b/rules/PHPUnit/Rector/MethodCall/WithConsecutiveArgToArrayRector.php deleted file mode 100644 index e7a0be07c13..00000000000 --- a/rules/PHPUnit/Rector/MethodCall/WithConsecutiveArgToArrayRector.php +++ /dev/null @@ -1,229 +0,0 @@ -methodCallManipulator = $methodCallManipulator; - $this->reflectionProvider = $reflectionProvider; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition('Split withConsecutive() arg to array', [ - new CodeSample( - <<<'CODE_SAMPLE' -class SomeClass -{ - public function run($one, $two) - { - } -} - -class SomeTestCase extends \PHPUnit\Framework\TestCase -{ - public function test() - { - $someClassMock = $this->createMock(SomeClass::class); - $someClassMock - ->expects($this->exactly(2)) - ->method('run') - ->withConsecutive(1, 2, 3, 5); - } -} -CODE_SAMPLE -, - <<<'CODE_SAMPLE' -class SomeClass -{ - public function run($one, $two) - { - } -} - -class SomeTestCase extends \PHPUnit\Framework\TestCase -{ - public function test() - { - $someClassMock = $this->createMock(SomeClass::class); - $someClassMock - ->expects($this->exactly(2)) - ->method('run') - ->withConsecutive([1, 2], [3, 5]); - } -} -CODE_SAMPLE - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class]; - } - - /** - * @param MethodCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->isName($node->name, 'withConsecutive')) { - return null; - } - - if ($this->areAllArgArrayTypes($node)) { - return null; - } - - // is a mock? - if (! $this->isObjectType($node, new ObjectType('PHPUnit\Framework\MockObject\Builder\InvocationMocker'))) { - return null; - } - - $mockClass = $this->inferMockedClassName($node); - if ($mockClass === null) { - return null; - } - - $mockMethod = $this->inferMockedMethodName($node); - - if (! $this->reflectionProvider->hasClass($mockClass)) { - return null; - } - - $classReflection = $this->reflectionProvider->getClass($mockClass); - $classReflection = $classReflection->getNativeReflection(); - - $reflectionMethod = $classReflection->getMethod($mockMethod); - $numberOfParameters = $reflectionMethod->getNumberOfParameters(); - - $values = []; - foreach ($node->args as $arg) { - $values[] = $arg->value; - } - - // simple check argument count fits to method required args - if (count($values) % $numberOfParameters !== 0) { - return null; - } - - $node->args = []; - - // split into chunks of X parameters - $valueChunks = array_chunk($values, $numberOfParameters); - foreach ($valueChunks as $valueChunk) { - $node->args[] = new Arg($this->nodeFactory->createArray($valueChunk)); - } - - return $node; - } - - private function areAllArgArrayTypes(MethodCall $methodCall): bool - { - foreach ($methodCall->args as $arg) { - $argumentStaticType = $this->getStaticType($arg->value); - if ($argumentStaticType instanceof ArrayType) { - continue; - } - - return false; - } - - return true; - } - - private function inferMockedClassName(MethodCall $methodCall): ?string - { - $variable = $this->findRootVariableOfChainCall($methodCall); - if (! $variable instanceof Variable) { - return null; - } - - // look for "$this->createMock(X)" - $assignToVariable = $this->methodCallManipulator->findAssignToVariable($variable); - if (! $assignToVariable instanceof Assign) { - return null; - } - - if ($assignToVariable->expr instanceof MethodCall) { - /** @var MethodCall $assignedMethodCall */ - $assignedMethodCall = $assignToVariable->expr; - if ($this->isName($assignedMethodCall->var, 'this') && $this->isName( - $assignedMethodCall->name, - 'createMock' - )) { - $firstArgumentValue = $assignedMethodCall->args[0]->value; - return $this->valueResolver->getValue($firstArgumentValue); - } - } - - return null; - } - - private function inferMockedMethodName(MethodCall $methodCall): string - { - $previousMethodCalls = $this->methodCallManipulator->findMethodCallsIncludingChain($methodCall); - foreach ($previousMethodCalls as $previouMethodCall) { - if (! $this->isName($previouMethodCall->name, 'method')) { - continue; - } - - $firstArgumentValue = $previouMethodCall->args[0]->value; - if (! $firstArgumentValue instanceof String_) { - continue; - } - - return $firstArgumentValue->value; - } - - throw new ShouldNotHappenException(); - } - - private function findRootVariableOfChainCall(MethodCall $methodCall): ?Variable - { - $currentMethodCallee = $methodCall->var; - while (! $currentMethodCallee instanceof Variable) { - $currentMethodCallee = $currentMethodCallee->var; - } - - return $currentMethodCallee; - } -} diff --git a/rules/PHPUnit/Rector/StaticCall/GetMockRector.php b/rules/PHPUnit/Rector/StaticCall/GetMockRector.php deleted file mode 100644 index d8adc88abce..00000000000 --- a/rules/PHPUnit/Rector/StaticCall/GetMockRector.php +++ /dev/null @@ -1,78 +0,0 @@ -testsNodeAnalyzer = $testsNodeAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition('Turns getMock*() methods to createMock()', [ - new CodeSample('$this->getMock("Class");', '$this->createMock("Class");'), - new CodeSample( - '$this->getMockWithoutInvokingTheOriginalConstructor("Class");', - '$this->createMock("Class");' - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [MethodCall::class, StaticCall::class]; - } - - /** - * @param MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodNames( - $node, - ['getMock', 'getMockWithoutInvokingTheOriginalConstructor'] - )) { - return null; - } - - if ($node instanceof MethodCall && $node->var instanceof MethodCall) { - return null; - } - - // narrow args to one - if (count($node->args) > 1) { - $node->args = [$node->args[0]]; - } - - $node->name = new Identifier('createMock'); - - return $node; - } -} diff --git a/rules/PHPUnit/TestClassResolver/PHPUnitTestCaseClassesProvider.php b/rules/PHPUnit/TestClassResolver/PHPUnitTestCaseClassesProvider.php deleted file mode 100644 index 819d381ce4c..00000000000 --- a/rules/PHPUnit/TestClassResolver/PHPUnitTestCaseClassesProvider.php +++ /dev/null @@ -1,61 +0,0 @@ -composerAutoloadedDirectoryProvider = $composerAutoloadedDirectoryProvider; - } - - /** - * @return string[] - */ - public function provide(): array - { - if ($this->phpUnitTestCaseClasses !== []) { - return $this->phpUnitTestCaseClasses; - } - - $robotLoader = $this->createRobotLoadForDirectories(); - $robotLoader->rebuild(); - - foreach (array_keys($robotLoader->getIndexedClasses()) as $className) { - $this->phpUnitTestCaseClasses[] = $className; - } - - return $this->phpUnitTestCaseClasses; - } - - private function createRobotLoadForDirectories(): RobotLoader - { - $robotLoader = new RobotLoader(); - $robotLoader->setTempDirectory(sys_get_temp_dir() . '/tests_add_see_rector_tests'); - - $directories = $this->composerAutoloadedDirectoryProvider->provide(); - $robotLoader->addDirectory(...$directories); - - $robotLoader->acceptFiles = ['*Test.php']; - $robotLoader->ignoreDirs[] = '*Expected*'; - $robotLoader->ignoreDirs[] = '*Fixture*'; - $robotLoader->ignoreDirs[] = 'templates'; - - return $robotLoader; - } -} diff --git a/rules/PHPUnit/TestClassResolver/TestClassResolver.php b/rules/PHPUnit/TestClassResolver/TestClassResolver.php deleted file mode 100644 index 51efca9f008..00000000000 --- a/rules/PHPUnit/TestClassResolver/TestClassResolver.php +++ /dev/null @@ -1,113 +0,0 @@ -nodeNameResolver = $nodeNameResolver; - $this->phpUnitTestCaseClassesProvider = $phpUnitTestCaseClassesProvider; - $this->reflectionProvider = $reflectionProvider; - } - - public function resolveFromClassName(string $className): ?string - { - // fallback for unit tests that only have extra "Test" suffix - if ($this->reflectionProvider->hasClass($className . self::TEST)) { - return $className . self::TEST; - } - - $shortClassName = $this->resolveShortClassName($className); - $testShortClassName = $shortClassName . self::TEST; - - $phpUnitTestCaseClasses = $this->phpUnitTestCaseClassesProvider->provide(); - - $classNamespaceParts = $this->resolveNamespaceParts($className); - $classNamespaceParts[] = 'Tests'; - sort($classNamespaceParts); - - foreach ($phpUnitTestCaseClasses as $phpUnitTestCaseClass) { - // 1. is short class match - if (! Strings::endsWith($phpUnitTestCaseClass, '\\' . $testShortClassName)) { - continue; - } - - // 2. is namespace match - $phpUnitTestNamespaceParts = $this->resolveNamespaceParts($phpUnitTestCaseClass); - sort($phpUnitTestNamespaceParts); - - $nestedPhpUnitTestNamespaceParts = array_merge($classNamespaceParts, [$shortClassName]); - sort($nestedPhpUnitTestNamespaceParts); - - if ($classNamespaceParts === $phpUnitTestNamespaceParts) { - return $phpUnitTestCaseClass; - } - - if ($nestedPhpUnitTestNamespaceParts === $phpUnitTestNamespaceParts) { - return $phpUnitTestCaseClass; - } - - return null; - } - - return null; - } - - public function resolveFromClass(Class_ $class): ?string - { - $className = $this->nodeNameResolver->getName($class); - if ($className === null) { - return null; - } - - return $this->resolveFromClassName($className); - } - - private function resolveShortClassName(string $className): ?string - { - return Strings::after($className, '\\', -1); - } - - /** - * @return string[] - */ - private function resolveNamespaceParts(string $className): array - { - $namespacePart = (string) Strings::before($className, '\\', -1); - return explode('\\', $namespacePart); - } -} diff --git a/rules/PHPUnit/ValueObject/ArrayArgumentToDataProvider.php b/rules/PHPUnit/ValueObject/ArrayArgumentToDataProvider.php deleted file mode 100644 index 08f7cdc1d12..00000000000 --- a/rules/PHPUnit/ValueObject/ArrayArgumentToDataProvider.php +++ /dev/null @@ -1,58 +0,0 @@ -class = $class; - $this->oldMethod = $oldMethod; - $this->newMethod = $newMethod; - $this->variableName = $variableName; - } - - public function getObjectType(): ObjectType - { - return new ObjectType($this->class); - } - - public function getOldMethod(): string - { - return $this->oldMethod; - } - - public function getNewMethod(): string - { - return $this->newMethod; - } - - public function getVariableName(): string - { - return $this->variableName; - } -} diff --git a/rules/PHPUnit/ValueObject/BinaryOpWithAssertMethod.php b/rules/PHPUnit/ValueObject/BinaryOpWithAssertMethod.php deleted file mode 100644 index 24f01c84506..00000000000 --- a/rules/PHPUnit/ValueObject/BinaryOpWithAssertMethod.php +++ /dev/null @@ -1,45 +0,0 @@ -binaryOpClass = $binaryOpClass; - $this->assetMethodName = $assetMethodName; - $this->notAssertMethodName = $notAssertMethodName; - } - - public function getBinaryOpClass(): string - { - return $this->binaryOpClass; - } - - public function getAssetMethodName(): string - { - return $this->assetMethodName; - } - - public function getNotAssertMethodName(): string - { - return $this->notAssertMethodName; - } -} diff --git a/rules/PHPUnit/ValueObject/ConstantWithAssertMethods.php b/rules/PHPUnit/ValueObject/ConstantWithAssertMethods.php deleted file mode 100644 index a9950c7abb9..00000000000 --- a/rules/PHPUnit/ValueObject/ConstantWithAssertMethods.php +++ /dev/null @@ -1,45 +0,0 @@ -constant = $constant; - $this->assetMethodName = $assetMethodName; - $this->notAssertMethodName = $notAssertMethodName; - } - - public function getConstant(): string - { - return $this->constant; - } - - public function getAssetMethodName(): string - { - return $this->assetMethodName; - } - - public function getNotAssertMethodName(): string - { - return $this->notAssertMethodName; - } -} diff --git a/rules/PHPUnit/ValueObject/DataProviderClassMethodRecipe.php b/rules/PHPUnit/ValueObject/DataProviderClassMethodRecipe.php deleted file mode 100644 index 78835fe1aa6..00000000000 --- a/rules/PHPUnit/ValueObject/DataProviderClassMethodRecipe.php +++ /dev/null @@ -1,42 +0,0 @@ -methodName = $methodName; - $this->args = $args; - } - - public function getMethodName(): string - { - return $this->methodName; - } - - /** - * @return Arg[] - */ - public function getArgs(): array - { - return $this->args; - } -} diff --git a/rules/PHPUnit/ValueObject/ExpectationMock.php b/rules/PHPUnit/ValueObject/ExpectationMock.php deleted file mode 100644 index 1a7c365066d..00000000000 --- a/rules/PHPUnit/ValueObject/ExpectationMock.php +++ /dev/null @@ -1,98 +0,0 @@ - - */ - private $withArguments = []; - - /** - * @var Expression|null - */ - private $originalExpression; - - /** - * @param Arg[] $methodArguments - * @param array $withArguments - */ - public function __construct( - Variable $expectationVariable, - array $methodArguments, - int $index, - ?Expr $expr, - array $withArguments, - ?Expression $originalExpression - ) { - $this->expectationVariable = $expectationVariable; - $this->methodArguments = $methodArguments; - $this->index = $index; - $this->expr = $expr; - $this->withArguments = $withArguments; - $this->originalExpression = $originalExpression; - } - - public function getExpectationVariable(): Variable - { - return $this->expectationVariable; - } - - /** - * @return Arg[] - */ - public function getMethodArguments(): array - { - return $this->methodArguments; - } - - public function getIndex(): int - { - return $this->index; - } - - public function getReturn(): ?Expr - { - return $this->expr; - } - - /** - * @return array - */ - public function getWithArguments(): array - { - return $this->withArguments; - } - - public function getOriginalExpression(): ?Expression - { - return $this->originalExpression; - } -} diff --git a/rules/PHPUnit/ValueObject/ExpectationMockCollection.php b/rules/PHPUnit/ValueObject/ExpectationMockCollection.php deleted file mode 100644 index 8e95a4ee8b9..00000000000 --- a/rules/PHPUnit/ValueObject/ExpectationMockCollection.php +++ /dev/null @@ -1,131 +0,0 @@ -expectationMocks; - } - - public function hasExpectationMocks(): bool - { - return $this->expectationMocks !== []; - } - - public function add(ExpectationMock $expectationMock): void - { - $this->expectationMocks[] = $expectationMock; - } - - public function getHighestAtIndex(): int - { - if (! $this->hasExpectationMocks()) { - return 0; - } - - $indexes = array_map(static function (ExpectationMock $expectationMock): int { - return $expectationMock->getIndex(); - }, $this->expectationMocks); - return max($indexes) ?: 0; - } - - public function getLowestAtIndex(): int - { - if (! $this->hasExpectationMocks()) { - return 0; - } - - $indexes = array_map(static function (ExpectationMock $expectationMock): int { - return $expectationMock->getIndex(); - }, $this->expectationMocks); - return min($indexes) ?: 0; - } - - public function isMissingAtIndexBetweenHighestAndLowest(): bool - { - $highestAtIndex = $this->getHighestAtIndex(); - $lowestAtIndex = $this->getLowestAtIndex(); - return ($highestAtIndex - $lowestAtIndex + 1) !== count($this->expectationMocks); - } - - public function hasMissingAtIndexes(): bool - { - if ($this->getLowestAtIndex() !== 0) { - return true; - } - return $this->isMissingAtIndexBetweenHighestAndLowest(); - } - - public function hasWithValues(): bool - { - foreach ($this->expectationMocks as $expectationMock) { - if (count($expectationMock->getWithArguments()) > 1) { - return true; - } - - if (count($expectationMock->getWithArguments()) !== 1) { - continue; - } - - if ($expectationMock->getWithArguments()[0] === null) { - continue; - } - - return true; - } - - return false; - } - - public function hasReturnValues(): bool - { - foreach ($this->expectationMocks as $expectationMock) { - if ($expectationMock->getReturn() !== null) { - return true; - } - } - - return false; - } - - public function hasMissingReturnValues(): bool - { - foreach ($this->expectationMocks as $expectationMock) { - if ($expectationMock->getReturn() === null) { - return true; - } - } - - return false; - } - - public function isExpectedMethodAlwaysTheSame(): bool - { - $previousMethod = ''; - foreach ($this->expectationMocks as $expectationMock) { - $methodArgument = $expectationMock->getMethodArguments()[0]; - if ($methodArgument !== null && $methodArgument->value instanceof String_) { - if ($previousMethod === '') { - $previousMethod = $methodArgument->value->value; - } - if ($previousMethod !== $methodArgument->value->value) { - return false; - } - } - } - return true; - } -} diff --git a/rules/PHPUnit/ValueObject/FunctionNameWithAssertMethods.php b/rules/PHPUnit/ValueObject/FunctionNameWithAssertMethods.php deleted file mode 100644 index 6eb1b332c18..00000000000 --- a/rules/PHPUnit/ValueObject/FunctionNameWithAssertMethods.php +++ /dev/null @@ -1,45 +0,0 @@ -functionName = $functionName; - $this->assetMethodName = $assetMethodName; - $this->notAssertMethodName = $notAssertMethodName; - } - - public function getFunctionName(): string - { - return $this->functionName; - } - - public function getAssetMethodName(): string - { - return $this->assetMethodName; - } - - public function getNotAssertMethodName(): string - { - return $this->notAssertMethodName; - } -} diff --git a/rules/PHPUnit/ValueObject/ParamAndArg.php b/rules/PHPUnit/ValueObject/ParamAndArg.php deleted file mode 100644 index d1bd8329843..00000000000 --- a/rules/PHPUnit/ValueObject/ParamAndArg.php +++ /dev/null @@ -1,37 +0,0 @@ -variable = $variable; - $this->type = $type; - } - - public function getVariable(): Variable - { - return $this->variable; - } - - public function getType(): ?Type - { - return $this->type; - } -} diff --git a/stubs/PHPUnit/Framework/TestListener.php b/stubs/PHPUnit/Framework/TestListener.php deleted file mode 100644 index 58e8b864786..00000000000 --- a/stubs/PHPUnit/Framework/TestListener.php +++ /dev/null @@ -1,14 +0,0 @@ -