diff --git a/.composer-require-checker.json b/.composer-require-checker.json index 07c620add5c..43b51fd3981 100644 --- a/.composer-require-checker.json +++ b/.composer-require-checker.json @@ -16,6 +16,7 @@ "PHPUnitGoodPractices\\Traits\\ProphesizeOnlyInterfaceTrait", "Prophecy\\Argument", "Prophecy\\PhpUnit\\ProphecyTrait", + "Symfony\\Bridge\\PhpUnit\\ExpectDeprecationTrait", "Symfony\\Component\\EventDispatcher\\Event", "Symfony\\Contracts\\EventDispatcher\\Event", "Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface", diff --git a/.php_cs.dist b/.php_cs.dist index 1c9ea9b79da..2ed2ef2a8d8 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -27,6 +27,7 @@ $config '@PHPUnit75Migration:risky' => true, '@PhpCsFixer' => true, '@PhpCsFixer:risky' => true, + 'general_phpdoc_annotation_remove' => ['annotations' => ['expectedDeprecation']], 'header_comment' => ['header' => $header], 'list_syntax' => ['syntax' => 'long'], ]) diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 95e5e377833..05b2d5b3d22 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -289,10 +289,10 @@ public function testConfigConstructorWithName() /** * @group legacy - * @expectedDeprecation PhpCsFixer\Config::create is deprecated since 2.17 and will be removed in 3.0. */ public function testDeprecatedConstructor() { + $this->expectDeprecation('PhpCsFixer\\Config::create is deprecated since 2.17 and will be removed in 3.0.'); Config::create(); } } diff --git a/tests/Console/Command/FixCommandTest.php b/tests/Console/Command/FixCommandTest.php index b8fe88c648e..bd8baa86c8f 100644 --- a/tests/Console/Command/FixCommandTest.php +++ b/tests/Console/Command/FixCommandTest.php @@ -42,10 +42,10 @@ public function testEmptyRulesValue() /** * @group legacy - * @expectedDeprecation Expected "yes" or "no" for option "using-cache", other values are deprecated and support will be removed in 3.0. Got "not today", this implicitly set the option to "false". */ public function testEmptyFormatValue() { + $this->expectDeprecation('Expected "yes" or "no" for option "using-cache", other values are deprecated and support will be removed in 3.0. Got "not today", this implicitly set the option to "false".'); $cmdTester = $this->doTestExecute( [ '--using-cache' => 'not today', diff --git a/tests/Console/ConfigurationResolverTest.php b/tests/Console/ConfigurationResolverTest.php index 4ce71eb983d..85959a389f5 100644 --- a/tests/Console/ConfigurationResolverTest.php +++ b/tests/Console/ConfigurationResolverTest.php @@ -120,10 +120,10 @@ public function testResolveProgressWithPositiveConfigAndExplicitProgress($progre * @dataProvider provideProgressTypeLegacyCases * * @group legacy - * @expectedDeprecation Passing `estimating`, `estimating-max` or `run-in` is deprecated and will not be supported in 3.0, use `none` or `dots` instead. */ public function testResolveProgressWithPositiveConfigAndExplicitProgressLegacy($progressType) { + $this->expectDeprecation('Passing `estimating`, `estimating-max` or `run-in` is deprecated and will not be supported in 3.0, use `none` or `dots` instead.'); $this->testResolveProgressWithPositiveConfigAndExplicitProgress($progressType); } @@ -152,10 +152,10 @@ public function testResolveProgressWithNegativeConfigAndExplicitProgress($progre * @dataProvider provideProgressTypeLegacyCases * * @group legacy - * @expectedDeprecation Passing `estimating`, `estimating-max` or `run-in` is deprecated and will not be supported in 3.0, use `none` or `dots` instead. */ public function testResolveProgressWithNegativeConfigAndExplicitProgressLegacy($progressType) { + $this->expectDeprecation('Passing `estimating`, `estimating-max` or `run-in` is deprecated and will not be supported in 3.0, use `none` or `dots` instead.'); $this->testResolveProgressWithNegativeConfigAndExplicitProgress($progressType); } @@ -1201,10 +1201,10 @@ public function testResolveConfigFileOverridesDefault() /** * @group legacy - * @expectedDeprecation Expected "yes" or "no" for option "allow-risky", other values are deprecated and support will be removed in 3.0. Got "yes please", this implicitly set the option to "false". */ public function testDeprecationOfPassingOtherThanNoOrYes() { + $this->expectDeprecation('Expected "yes" or "no" for option "allow-risky", other values are deprecated and support will be removed in 3.0. Got "yes please", this implicitly set the option to "false".'); $resolver = $this->createConfigurationResolver(['allow-risky' => 'yes please']); static::assertFalse($resolver->getRiskyAllowed()); @@ -1242,10 +1242,10 @@ public function testWithEmptyRules() * @dataProvider provideDeprecatedFixerConfiguredCases * * @group legacy - * @expectedDeprecation Rule "Vendor4/foo" is deprecated. Use "testA" and "testB" instead. */ public function testDeprecatedFixerConfigured($ruleConfig) { + $this->expectDeprecation('Rule "Vendor4/foo" is deprecated. Use "testA" and "testB" instead.'); $fixer = new DeprecatedFixer(); $config = new Config(); $config->registerCustomFixers([$fixer]); diff --git a/tests/Fixer/Alias/NoMixedEchoPrintFixerTest.php b/tests/Fixer/Alias/NoMixedEchoPrintFixerTest.php index 00036bcb888..bf0fe799378 100644 --- a/tests/Fixer/Alias/NoMixedEchoPrintFixerTest.php +++ b/tests/Fixer/Alias/NoMixedEchoPrintFixerTest.php @@ -290,10 +290,10 @@ public static function providePrintToEchoFixNewCases() /** * @group legacy - * @expectedDeprecation Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead. */ public function testLegacyDefaultConfig() { + $this->expectDeprecation('Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.'); $this->fixer->configure(null); static::assertCandidateTokenType(T_PRINT, $this->fixer); diff --git a/tests/Fixer/Alias/RandomApiMigrationFixerTest.php b/tests/Fixer/Alias/RandomApiMigrationFixerTest.php index 8249e96cc56..ba5dc29d665 100644 --- a/tests/Fixer/Alias/RandomApiMigrationFixerTest.php +++ b/tests/Fixer/Alias/RandomApiMigrationFixerTest.php @@ -42,10 +42,10 @@ public function testConfigureCheckReplacementType() /** * @group legacy - * @expectedDeprecation Passing "replacements" at the root of the configuration for rule "random_api_migration" is deprecated and will not be supported in 3.0, use "replacements" => array(...) option instead. */ public function testLegacyConfigure() { + $this->expectDeprecation('Passing "replacements" at the root of the configuration for rule "random_api_migration" is deprecated and will not be supported in 3.0, use "replacements" => array(...) option instead.'); $this->fixer->configure(['rand' => 'random_int']); $reflectionProperty = new \ReflectionProperty($this->fixer, 'configuration'); diff --git a/tests/Fixer/ArrayNotation/ArraySyntaxFixerTest.php b/tests/Fixer/ArrayNotation/ArraySyntaxFixerTest.php index d058715b89a..9ef64b96118 100644 --- a/tests/Fixer/ArrayNotation/ArraySyntaxFixerTest.php +++ b/tests/Fixer/ArrayNotation/ArraySyntaxFixerTest.php @@ -35,10 +35,10 @@ public function testInvalidConfiguration() /** * @group legacy - * @expectedDeprecation Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead. */ public function testLegacyFixWithDefaultConfiguration() { + $this->expectDeprecation('Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.'); $this->fixer->configure(null); $this->doTest( ' `none|one` instead. */ public function testWithDeprecatedConfig($expected, $input = null, array $config = []) { + $this->expectDeprecation('A list of elements is deprecated, use a dictionary of `const|method|property` => `none|one` instead.'); $this->fixer->configure($config); $this->doTest($expected, $input); } diff --git a/tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php b/tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php index 0d59efd3006..71f0861ccc1 100644 --- a/tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php +++ b/tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php @@ -28,10 +28,10 @@ final class ClassDefinitionFixerTest extends AbstractFixerWithAliasedOptionsTest { /** * @group legacy - * @expectedDeprecation Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead. */ public function testLegacyConfigureDefaultToNull() { + $this->expectDeprecation('Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.'); $defaultConfig = [ 'multi_line_extends_each_single_line' => false, 'single_item_single_line' => false, diff --git a/tests/Fixer/ClassNotation/OrderedClassElementsFixerTest.php b/tests/Fixer/ClassNotation/OrderedClassElementsFixerTest.php index 79744dbe762..ba11fc0ef10 100644 --- a/tests/Fixer/ClassNotation/OrderedClassElementsFixerTest.php +++ b/tests/Fixer/ClassNotation/OrderedClassElementsFixerTest.php @@ -452,10 +452,10 @@ class Foo * * @group legacy * @dataProvider provideConfigurationCases - * @expectedDeprecation Passing "order" at the root of the configuration for rule "ordered_class_elements" is deprecated and will not be supported in 3.0, use "order" => array(...) option instead. */ public function testLegacyFixWithConfiguration(array $configuration, $expected, $input) { + $this->expectDeprecation('Passing "order" at the root of the configuration for rule "ordered_class_elements" is deprecated and will not be supported in 3.0, use "order" => array(...) option instead.'); $this->fixer->configure($configuration); $this->doTest($expected, $input); } diff --git a/tests/Fixer/ClassNotation/SingleClassElementPerStatementFixerTest.php b/tests/Fixer/ClassNotation/SingleClassElementPerStatementFixerTest.php index 63c8954cb6d..fb05d95d977 100644 --- a/tests/Fixer/ClassNotation/SingleClassElementPerStatementFixerTest.php +++ b/tests/Fixer/ClassNotation/SingleClassElementPerStatementFixerTest.php @@ -622,10 +622,10 @@ class Foo * * @group legacy * @dataProvider provideConfigurationCases - * @expectedDeprecation Passing "elements" at the root of the configuration for rule "single_class_element_per_statement" is deprecated and will not be supported in 3.0, use "elements" => array(...) option instead. */ public function testLegacyFixWithConfiguration(array $configuration, $expected) { + $this->expectDeprecation('Passing "elements" at the root of the configuration for rule "single_class_element_per_statement" is deprecated and will not be supported in 3.0, use "elements" => array(...) option instead.'); static $input = <<<'EOT' array(...) option instead. */ public function testLegacyFixClassConst($expected, $input) { + $this->expectDeprecation('Passing "elements" at the root of the configuration for rule "visibility_required" is deprecated and will not be supported in 3.0, use "elements" => array(...) option instead.'); $this->fixer->configure(['const']); $this->doTest($expected, $input); } diff --git a/tests/Fixer/Comment/HeaderCommentFixerTest.php b/tests/Fixer/Comment/HeaderCommentFixerTest.php index c808b67d597..95d74ec4428 100644 --- a/tests/Fixer/Comment/HeaderCommentFixerTest.php +++ b/tests/Fixer/Comment/HeaderCommentFixerTest.php @@ -569,10 +569,10 @@ public function testDefaultConfiguration() /** * @group legacy - * @expectedDeprecation Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead. */ public function testLegacyMisconfiguration() { + $this->expectDeprecation('Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.'); $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); $this->expectExceptionMessage('[header_comment] Missing required configuration: The required option "header" is missing.'); diff --git a/tests/Fixer/ControlStructure/NoUnneededControlParenthesesFixerTest.php b/tests/Fixer/ControlStructure/NoUnneededControlParenthesesFixerTest.php index 7c1c3f7b8ed..6dd416a6784 100644 --- a/tests/Fixer/ControlStructure/NoUnneededControlParenthesesFixerTest.php +++ b/tests/Fixer/ControlStructure/NoUnneededControlParenthesesFixerTest.php @@ -60,10 +60,10 @@ public function testFix($expected, $input = null, $fixStatement = null) * * @group legacy * @dataProvider provideFixCases - * @expectedDeprecation Passing "statements" at the root of the configuration for rule "no_unneeded_control_parentheses" is deprecated and will not be supported in 3.0, use "statements" => array(...) option instead. */ public function testLegacyFix($expected, $input = null, $fixStatement = null) { + $this->expectDeprecation('Passing "statements" at the root of the configuration for rule "no_unneeded_control_parentheses" is deprecated and will not be supported in 3.0, use "statements" => array(...) option instead.'); $this->fixerTest($expected, $input, $fixStatement, true); } @@ -87,11 +87,11 @@ public function testFix70($expected, $input = null, $fixStatement = null) * * @group legacy * @dataProvider provideFix70Cases - * @expectedDeprecation Passing "statements" at the root of the configuration for rule "no_unneeded_control_parentheses" is deprecated and will not be supported in 3.0, use "statements" => array(...) option instead. * @requires PHP 7.0 */ public function testLegacyFix70($expected, $input = null, $fixStatement = null) { + $this->expectDeprecation('Passing "statements" at the root of the configuration for rule "no_unneeded_control_parentheses" is deprecated and will not be supported in 3.0, use "statements" => array(...) option instead.'); $this->fixerTest($expected, $input, $fixStatement, true); } diff --git a/tests/Fixer/DoctrineAnnotation/DoctrineAnnotationSpacesFixerTest.php b/tests/Fixer/DoctrineAnnotation/DoctrineAnnotationSpacesFixerTest.php index a1490de3e20..eb95eded543 100644 --- a/tests/Fixer/DoctrineAnnotation/DoctrineAnnotationSpacesFixerTest.php +++ b/tests/Fixer/DoctrineAnnotation/DoctrineAnnotationSpacesFixerTest.php @@ -28,11 +28,11 @@ final class DoctrineAnnotationSpacesFixerTest extends AbstractDoctrineAnnotation * * @dataProvider provideFixAllCases * @group legacy - * @expectedDeprecation Option "around_argument_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_argument_assignments" and "after_argument_assignments" instead. - * @expectedDeprecation Option "around_array_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_array_assignments_equals", "after_array_assignments_equals", "before_array_assignments_colon" and "after_array_assignments_colon" instead. */ public function testLegacyFixAll($expected, $input = null) { + $this->expectDeprecation('Option "around_argument_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_argument_assignments" and "after_argument_assignments" instead.'); + $this->expectDeprecation('Option "around_array_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_array_assignments_equals", "after_array_assignments_equals", "before_array_assignments_colon" and "after_array_assignments_colon" instead.'); $this->doTest($expected, $input); $this->fixer->configure([ @@ -73,8 +73,6 @@ public function testFixAll($expected, $input = null) * * @dataProvider provideFixAllCases * @group legacy - * @expectedDeprecation Option "around_argument_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_argument_assignments" and "after_argument_assignments" instead. - * @expectedDeprecation Option "around_array_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_array_assignments_equals", "after_array_assignments_equals", "before_array_assignments_colon" and "after_array_assignments_colon" instead. */ public function testLegacyFixAllWithDifferentLineEnding($expected, $input = null) { @@ -384,11 +382,11 @@ public function provideFixAllCases() * * @dataProvider provideFixAroundParenthesesOnlyCases * @group legacy - * @expectedDeprecation Option "around_argument_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_argument_assignments" and "after_argument_assignments" instead. - * @expectedDeprecation Option "around_array_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_array_assignments_equals", "after_array_assignments_equals", "before_array_assignments_colon" and "after_array_assignments_colon" instead. */ public function testLegacyFixAroundParenthesesOnly($expected, $input = null) { + $this->expectDeprecation('Option "around_argument_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_argument_assignments" and "after_argument_assignments" instead.'); + $this->expectDeprecation('Option "around_array_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_array_assignments_equals", "after_array_assignments_equals", "before_array_assignments_colon" and "after_array_assignments_colon" instead.'); $this->fixer->configure([ 'around_commas' => false, 'around_argument_assignments' => false, @@ -443,8 +441,6 @@ public function testFixAroundParenthesesOnly($expected, $input = null) * * @dataProvider provideFixAroundParenthesesOnlyCases * @group legacy - * @expectedDeprecation Option "around_argument_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_argument_assignments" and "after_argument_assignments" instead. - * @expectedDeprecation Option "around_array_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_array_assignments_equals", "after_array_assignments_equals", "before_array_assignments_colon" and "after_array_assignments_colon" instead. */ public function testLegacyFixAroundParenthesesOnlyWithDifferentLineEnding($expected, $input = null) { @@ -693,11 +689,11 @@ public function provideFixAroundParenthesesOnlyCases() * * @dataProvider provideFixAroundCommasOnlyCases * @group legacy - * @expectedDeprecation Option "around_argument_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_argument_assignments" and "after_argument_assignments" instead. - * @expectedDeprecation Option "around_array_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_array_assignments_equals", "after_array_assignments_equals", "before_array_assignments_colon" and "after_array_assignments_colon" instead. */ public function testLegacyFixAroundCommasOnly($expected, $input = null) { + $this->expectDeprecation('Option "around_argument_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_argument_assignments" and "after_argument_assignments" instead.'); + $this->expectDeprecation('Option "around_array_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_array_assignments_equals", "after_array_assignments_equals", "before_array_assignments_colon" and "after_array_assignments_colon" instead.'); $this->fixer->configure([ 'around_parentheses' => false, 'around_argument_assignments' => false, @@ -752,11 +748,11 @@ public function testFixAroundCommasOnly($expected, $input = null) * * @dataProvider provideFixAroundCommasOnlyCases * @group legacy - * @expectedDeprecation Option "around_argument_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_argument_assignments" and "after_argument_assignments" instead. - * @expectedDeprecation Option "around_array_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_array_assignments_equals", "after_array_assignments_equals", "before_array_assignments_colon" and "after_array_assignments_colon" instead. */ public function testLegacyFixAroundCommasOnlyWithDifferentLineEnding($expected, $input = null) { + $this->expectDeprecation('Option "around_argument_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_argument_assignments" and "after_argument_assignments" instead.'); + $this->expectDeprecation('Option "around_array_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_array_assignments_equals", "after_array_assignments_equals", "before_array_assignments_colon" and "after_array_assignments_colon" instead.'); $expected = str_replace("\n", "\r\n", $expected); if (null !== $input) { $input = str_replace("\n", "\r\n", $input); @@ -1025,11 +1021,11 @@ public function provideFixAroundCommasOnlyCases() * * @dataProvider provideFixAroundArgumentAssignmentsOnlyCases * @group legacy - * @expectedDeprecation Option "around_argument_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_argument_assignments" and "after_argument_assignments" instead. - * @expectedDeprecation Option "around_array_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_array_assignments_equals", "after_array_assignments_equals", "before_array_assignments_colon" and "after_array_assignments_colon" instead. */ public function testLegacyFixAroundArgumentAssignmentsOnly($expected, $input = null) { + $this->expectDeprecation('Option "around_argument_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_argument_assignments" and "after_argument_assignments" instead.'); + $this->expectDeprecation('Option "around_array_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_array_assignments_equals", "after_array_assignments_equals", "before_array_assignments_colon" and "after_array_assignments_colon" instead.'); $this->fixer->configure([ 'around_parentheses' => false, 'around_commas' => false, @@ -1052,8 +1048,6 @@ public function testLegacyFixAroundArgumentAssignmentsOnly($expected, $input = n * * @dataProvider provideFixAroundArgumentAssignmentsOnlyCases * @group legacy - * @expectedDeprecation Option "around_argument_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_argument_assignments" and "after_argument_assignments" instead. - * @expectedDeprecation Option "around_array_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_array_assignments_equals", "after_array_assignments_equals", "before_array_assignments_colon" and "after_array_assignments_colon" instead. */ public function testLegacyFixAroundArgumentAssignmentsOnlyWithDifferentLineEnding($expected, $input = null) { @@ -1301,11 +1295,11 @@ public function provideFixAroundArgumentAssignmentsOnlyCases() * * @dataProvider provideFixAroundArrayAssignmentsOnlyCases * @group legacy - * @expectedDeprecation Option "around_argument_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_argument_assignments" and "after_argument_assignments" instead. - * @expectedDeprecation Option "around_array_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_array_assignments_equals", "after_array_assignments_equals", "before_array_assignments_colon" and "after_array_assignments_colon" instead. */ public function testLegacyFixAroundArrayAssignmentsOnly($expected, $input = null) { + $this->expectDeprecation('Option "around_argument_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_argument_assignments" and "after_argument_assignments" instead.'); + $this->expectDeprecation('Option "around_array_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_array_assignments_equals", "after_array_assignments_equals", "before_array_assignments_colon" and "after_array_assignments_colon" instead.'); $this->fixer->configure([ 'around_parentheses' => false, 'around_commas' => false, @@ -1328,8 +1322,6 @@ public function testLegacyFixAroundArrayAssignmentsOnly($expected, $input = null * * @dataProvider provideFixAroundArrayAssignmentsOnlyCases * @group legacy - * @expectedDeprecation Option "around_argument_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_argument_assignments" and "after_argument_assignments" instead. - * @expectedDeprecation Option "around_array_assignments" for rule "doctrine_annotation_spaces" is deprecated and will be removed in version 3.0. Use options "before_array_assignments_equals", "after_array_assignments_equals", "before_array_assignments_colon" and "after_array_assignments_colon" instead. */ public function testLegacyFixAroundArrayAssignmentsOnlyWithDifferentLineEnding($expected, $input = null) { diff --git a/tests/Fixer/FunctionNotation/MethodArgumentSpaceFixerTest.php b/tests/Fixer/FunctionNotation/MethodArgumentSpaceFixerTest.php index f78e210f115..bfc8d1264bf 100644 --- a/tests/Fixer/FunctionNotation/MethodArgumentSpaceFixerTest.php +++ b/tests/Fixer/FunctionNotation/MethodArgumentSpaceFixerTest.php @@ -1073,19 +1073,19 @@ public function provideFix74Cases() /** * @group legacy - * @expectedDeprecation PhpCsFixer\Fixer\FunctionNotation\MethodArgumentSpaceFixer::fixSpace is deprecated and will be removed in 3.0. */ public function testLegacyFixSpace() { + $this->expectDeprecation('PhpCsFixer\\Fixer\\FunctionNotation\\MethodArgumentSpaceFixer::fixSpace is deprecated and will be removed in 3.0.'); $this->fixer->fixSpace(Tokens::fromCode('expectDeprecation('Option "ensure_fully_multiline" for rule "method_argument_space" is deprecated and will be removed in version 3.0. Use option "on_multiline" instead.'); $this->fixer->configure([ 'ensure_fully_multiline' => true, ]); diff --git a/tests/Fixer/FunctionNotation/ReturnTypeDeclarationFixerTest.php b/tests/Fixer/FunctionNotation/ReturnTypeDeclarationFixerTest.php index 209d4e59eca..db3973c2442 100644 --- a/tests/Fixer/FunctionNotation/ReturnTypeDeclarationFixerTest.php +++ b/tests/Fixer/FunctionNotation/ReturnTypeDeclarationFixerTest.php @@ -37,13 +37,13 @@ public function testInvalidConfiguration() /** * @group legacy * @dataProvider provideFixWithSpaceBeforeNoneCases - * @expectedDeprecation Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead. * * @param string $expected * @param null|string $input */ public function testLegacyFixWithDefaultConfiguration($expected, $input = null) { + $this->expectDeprecation('Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.'); $this->fixer->configure(null); $this->doTest($expected, $input); diff --git a/tests/Fixer/LanguageConstruct/DeclareEqualNormalizeFixerTest.php b/tests/Fixer/LanguageConstruct/DeclareEqualNormalizeFixerTest.php index 7878d55f7db..68ed03e5912 100644 --- a/tests/Fixer/LanguageConstruct/DeclareEqualNormalizeFixerTest.php +++ b/tests/Fixer/LanguageConstruct/DeclareEqualNormalizeFixerTest.php @@ -26,10 +26,10 @@ final class DeclareEqualNormalizeFixerTest extends AbstractFixerTestCase { /** * @group legacy - * @expectedDeprecation Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead. */ public function testLegacyFix() { + $this->expectDeprecation('Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.'); $this->fixer->configure(null); $this->doTest( 'expectDeprecation('Option "use_yoda_style" for rule "is_null" is deprecated and will be removed in version 3.0. Use "yoda_style" fixer instead.'); $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); $this->expectExceptionMessageMatches('#^\[is_null\] Invalid configuration: The option "use_yoda_style" with value -1 is expected to be of type "bool", but is of type "(int|integer)"\.$#'); $this->fixer->configure(['use_yoda_style' => -1]); @@ -46,10 +46,10 @@ public function testConfigurationWrongValue() /** * @group legacy - * @expectedDeprecation Option "use_yoda_style" for rule "is_null" is deprecated and will be removed in version 3.0. Use "yoda_style" fixer instead. */ public function testCorrectConfiguration() { + $this->expectDeprecation('Option "use_yoda_style" for rule "is_null" is deprecated and will be removed in version 3.0. Use "yoda_style" fixer instead.'); $this->fixer->configure(['use_yoda_style' => false]); $reflectionProperty = new \ReflectionProperty($this->fixer, 'configuration'); @@ -246,7 +246,6 @@ public function provideFixCases() /** * @group legacy - * @expectedDeprecation Option "use_yoda_style" for rule "is_null" is deprecated and will be removed in version 3.0. Use "yoda_style" fixer instead. * * @dataProvider provideNonYodaFixCases * @@ -255,6 +254,7 @@ public function provideFixCases() */ public function testNonYodaFix($expected, $input) { + $this->expectDeprecation('Option "use_yoda_style" for rule "is_null" is deprecated and will be removed in version 3.0. Use "yoda_style" fixer instead.'); $this->fixer->configure(['use_yoda_style' => false]); $this->doTest($expected, $input); } diff --git a/tests/Fixer/Operator/BinaryOperatorSpacesFixerTest.php b/tests/Fixer/Operator/BinaryOperatorSpacesFixerTest.php index 66e455b474a..d1a5066b3f7 100644 --- a/tests/Fixer/Operator/BinaryOperatorSpacesFixerTest.php +++ b/tests/Fixer/Operator/BinaryOperatorSpacesFixerTest.php @@ -816,10 +816,10 @@ public function testWrongConfigOldValue() /** * @group legacy - * @expectedDeprecation Given configuration is deprecated and will be removed in 3.0. Use configuration ['operators' => ['=' => 'align', '=>' => 'single_space']] as replacement for ['align_equals' => true, 'align_double_arrow' => false]. */ public function testWrongConfigOldDeprecated() { + $this->expectDeprecation("Given configuration is deprecated and will be removed in 3.0. Use configuration ['operators' => ['=' => 'align', '=>' => 'single_space']] as replacement for ['align_equals' => true, 'align_double_arrow' => false]."); $this->fixer->configure([ 'align_equals' => true, 'align_double_arrow' => false, @@ -828,10 +828,10 @@ public function testWrongConfigOldDeprecated() /** * @group legacy - * @expectedDeprecation Given configuration is deprecated and will be removed in 3.0. Use configuration ['operators' => ['=' => 'align']] as replacement for ['align_equals' => true, 'align_double_arrow' => null]. */ public function testWrongConfigOldDeprecated2() { + $this->expectDeprecation("Given configuration is deprecated and will be removed in 3.0. Use configuration ['operators' => ['=' => 'align']] as replacement for ['align_equals' => true, 'align_double_arrow' => null]."); $this->fixer->configure([ 'align_equals' => true, 'align_double_arrow' => null, @@ -840,10 +840,10 @@ public function testWrongConfigOldDeprecated2() /** * @group legacy - * @expectedDeprecation Given configuration is deprecated and will be removed in 3.0. Use configuration ['operators' => ['=>' => 'align']] as replacement for ['align_equals' => null, 'align_double_arrow' => true]. */ public function testWrongConfigOldDeprecated3() { + $this->expectDeprecation("Given configuration is deprecated and will be removed in 3.0. Use configuration ['operators' => ['=>' => 'align']] as replacement for ['align_equals' => null, 'align_double_arrow' => true]."); $this->fixer->configure([ 'align_equals' => null, 'align_double_arrow' => true, @@ -852,10 +852,10 @@ public function testWrongConfigOldDeprecated3() /** * @group legacy - * @expectedDeprecation Given configuration is deprecated and will be removed in 3.0. Use configuration ['operators' => ['=' => 'single_space', '=>' => 'align']] as replacement for ['align_equals' => false, 'align_double_arrow' => true]. */ public function testWrongConfigOldDeprecated4() { + $this->expectDeprecation("Given configuration is deprecated and will be removed in 3.0. Use configuration ['operators' => ['=' => 'single_space', '=>' => 'align']] as replacement for ['align_equals' => false, 'align_double_arrow' => true]."); $this->fixer->configure([ 'align_equals' => false, 'align_double_arrow' => true, @@ -864,10 +864,10 @@ public function testWrongConfigOldDeprecated4() /** * @group legacy - * @expectedDeprecation Given configuration is deprecated and will be removed in 3.0. Use configuration ['operators' => ['=' => 'align', '=>' => 'align']] as replacement for ['align_equals' => true, 'align_double_arrow' => true]. */ public function testWrongConfigOldDeprecated5() { + $this->expectDeprecation("Given configuration is deprecated and will be removed in 3.0. Use configuration ['operators' => ['=' => 'align', '=>' => 'align']] as replacement for ['align_equals' => true, 'align_double_arrow' => true]."); $this->fixer->configure([ 'align_equals' => true, 'align_double_arrow' => true, diff --git a/tests/Fixer/PhpUnit/PhpUnitConstructFixerTest.php b/tests/Fixer/PhpUnit/PhpUnitConstructFixerTest.php index 7e93e22fc42..4ff68724647 100644 --- a/tests/Fixer/PhpUnit/PhpUnitConstructFixerTest.php +++ b/tests/Fixer/PhpUnit/PhpUnitConstructFixerTest.php @@ -29,10 +29,10 @@ final class PhpUnitConstructFixerTest extends AbstractFixerTestCase * * @group legacy * @dataProvider provideTestFixCases - * @expectedDeprecation Passing "assertions" at the root of the configuration for rule "php_unit_construct" is deprecated and will not be supported in 3.0, use "assertions" => array(...) option instead. */ public function testLegacyFix($expected, $input = null) { + $this->expectDeprecation('Passing "assertions" at the root of the configuration for rule "php_unit_construct" is deprecated and will not be supported in 3.0, use "assertions" => array(...) option instead.'); $this->fixer->configure([ 'assertEquals', 'assertSame', diff --git a/tests/Fixer/PhpUnit/PhpUnitDedicateAssertFixerTest.php b/tests/Fixer/PhpUnit/PhpUnitDedicateAssertFixerTest.php index 6530e8902c9..71ce281d430 100644 --- a/tests/Fixer/PhpUnit/PhpUnitDedicateAssertFixerTest.php +++ b/tests/Fixer/PhpUnit/PhpUnitDedicateAssertFixerTest.php @@ -42,10 +42,10 @@ public function testFix($expected, $input = null, array $config = []) * * @dataProvider provideTestFixLegacyCases * @group legacy - * @expectedDeprecation Option "functions" for rule "php_unit_dedicate_assert" is deprecated and will be removed in version 3.0. Use option "target" instead. */ public function testFixLegacy($expected, $input = null) { + $this->expectDeprecation('Option "functions" for rule "php_unit_dedicate_assert" is deprecated and will be removed in version 3.0. Use option "target" instead.'); $defaultFunctions = [ 'array_key_exists', 'empty', @@ -303,10 +303,10 @@ public function provideNotFixCases() /** * @group legacy - * @expectedDeprecation Passing "functions" at the root of the configuration for rule "php_unit_dedicate_assert" is deprecated and will not be supported in 3.0, use "functions" => array(...) option instead. */ public function testLegacyConfig() { + $this->expectDeprecation('Passing "functions" at the root of the configuration for rule "php_unit_dedicate_assert" is deprecated and will not be supported in 3.0, use "functions" => array(...) option instead.'); $this->fixer->configure(['file_exists']); $this->doTest( self::generateTest(' @@ -322,10 +322,10 @@ public function testLegacyConfig() /** * @group legacy - * @expectedDeprecation Option "functions" for rule "php_unit_dedicate_assert" is deprecated and will be removed in version 3.0. Use option "target" instead. */ public function testConfig() { + $this->expectDeprecation('Option "functions" for rule "php_unit_dedicate_assert" is deprecated and will be removed in version 3.0. Use option "target" instead.'); $this->fixer->configure(['functions' => ['file_exists']]); $this->doTest( self::generateTest(' diff --git a/tests/Fixer/PhpUnit/PhpUnitStrictFixerTest.php b/tests/Fixer/PhpUnit/PhpUnitStrictFixerTest.php index 7faf5825a7e..78c4faf1670 100644 --- a/tests/Fixer/PhpUnit/PhpUnitStrictFixerTest.php +++ b/tests/Fixer/PhpUnit/PhpUnitStrictFixerTest.php @@ -29,10 +29,10 @@ final class PhpUnitStrictFixerTest extends AbstractFixerTestCase * * @group legacy * @dataProvider provideTestFixCases - * @expectedDeprecation Passing "assertions" at the root of the configuration for rule "php_unit_strict" is deprecated and will not be supported in 3.0, use "assertions" => array(...) option instead. */ public function testLegacyFix($expected, $input = null) { + $this->expectDeprecation('Passing "assertions" at the root of the configuration for rule "php_unit_strict" is deprecated and will not be supported in 3.0, use "assertions" => array(...) option instead.'); $this->fixer->configure(array_keys($this->getMethodsMap())); $this->doTest($expected, $input); } diff --git a/tests/Fixer/PhpUnit/PhpUnitTestAnnotationFixerTest.php b/tests/Fixer/PhpUnit/PhpUnitTestAnnotationFixerTest.php index 40d8e8b6956..c955c1dc720 100644 --- a/tests/Fixer/PhpUnit/PhpUnitTestAnnotationFixerTest.php +++ b/tests/Fixer/PhpUnit/PhpUnitTestAnnotationFixerTest.php @@ -984,13 +984,13 @@ public function test_test_foo() {} /** * @dataProvider provideFixLegacyCaseOptionCases * @group legacy - * @expectedDeprecation Option "case" for rule "php_unit_test_annotation" is deprecated and will be removed in version 3.0. Use "php_unit_method_casing" fixer instead. * * @param string $expected * @param null|string $input */ public function testFixLegacyCaseOption($expected, $input = null, array $config = []) { + $this->expectDeprecation('Option "case" for rule "php_unit_test_annotation" is deprecated and will be removed in version 3.0. Use "php_unit_method_casing" fixer instead.'); $this->fixer->configure($config); $this->doTest($expected, $input); } diff --git a/tests/Fixer/Phpdoc/PhpdocNoAliasTagFixerTest.php b/tests/Fixer/Phpdoc/PhpdocNoAliasTagFixerTest.php index b34acfff807..a85559ee429 100644 --- a/tests/Fixer/Phpdoc/PhpdocNoAliasTagFixerTest.php +++ b/tests/Fixer/Phpdoc/PhpdocNoAliasTagFixerTest.php @@ -90,10 +90,10 @@ public function testInvalidConfigCase6() * * @group legacy * @dataProvider providePropertyCases - * @expectedDeprecation Passing "replacements" at the root of the configuration for rule "phpdoc_no_alias_tag" is deprecated and will not be supported in 3.0, use "replacements" => array(...) option instead. */ public function testLegacyPropertyFix($expected, $input = null) { + $this->expectDeprecation('Passing "replacements" at the root of the configuration for rule "phpdoc_no_alias_tag" is deprecated and will not be supported in 3.0, use "replacements" => array(...) option instead.'); $this->fixer->configure([ 'property-read' => 'property', 'property-write' => 'property', diff --git a/tests/Fixer/Phpdoc/PhpdocReturnSelfReferenceFixerTest.php b/tests/Fixer/Phpdoc/PhpdocReturnSelfReferenceFixerTest.php index 552db3871d4..5ac2f0c58ec 100644 --- a/tests/Fixer/Phpdoc/PhpdocReturnSelfReferenceFixerTest.php +++ b/tests/Fixer/Phpdoc/PhpdocReturnSelfReferenceFixerTest.php @@ -29,10 +29,10 @@ final class PhpdocReturnSelfReferenceFixerTest extends AbstractFixerTestCase * * @group legacy * @dataProvider provideDefaultConfigurationTestCases - * @expectedDeprecation Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead. */ public function testLegacyFixWithDefaultConfiguration($expected, $input = null) { + $this->expectDeprecation('Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.'); $this->fixer->configure(null); $this->doTest($expected, $input); } @@ -75,10 +75,10 @@ public function provideDefaultConfigurationTestCases() * * @group legacy * @dataProvider provideTestCases - * @expectedDeprecation Passing "replacements" at the root of the configuration for rule "phpdoc_return_self_reference" is deprecated and will not be supported in 3.0, use "replacements" => array(...) option instead. */ public function testLegacyFix($expected, $input = null, array $configuration = []) { + $this->expectDeprecation('Passing "replacements" at the root of the configuration for rule "phpdoc_return_self_reference" is deprecated and will not be supported in 3.0, use "replacements" => array(...) option instead.'); $this->fixer->configure($configuration); $this->doTest($expected, $input); } diff --git a/tests/Fixer/Whitespace/BlankLineBeforeStatementFixerTest.php b/tests/Fixer/Whitespace/BlankLineBeforeStatementFixerTest.php index 6abfceea00b..cfaa1f18a5d 100644 --- a/tests/Fixer/Whitespace/BlankLineBeforeStatementFixerTest.php +++ b/tests/Fixer/Whitespace/BlankLineBeforeStatementFixerTest.php @@ -399,7 +399,6 @@ public function provideFixWithDefaultCases() /** * @group legacy - * @expectedDeprecation Option "die" is deprecated, use "exit" instead. * * @dataProvider provideFixWithDieCases * @@ -408,6 +407,7 @@ public function provideFixWithDefaultCases() */ public function testFixWithDie($expected, $input = null) { + $this->expectDeprecation('Option "die" is deprecated, use "exit" instead.'); $this->fixer->configure([ 'statements' => ['die'], ]); diff --git a/tests/Fixer/Whitespace/NoExtraBlankLinesFixerTest.php b/tests/Fixer/Whitespace/NoExtraBlankLinesFixerTest.php index a6250b4a774..e2393e5c874 100644 --- a/tests/Fixer/Whitespace/NoExtraBlankLinesFixerTest.php +++ b/tests/Fixer/Whitespace/NoExtraBlankLinesFixerTest.php @@ -91,10 +91,10 @@ private function test123(){ /** * @group legacy - * @expectedDeprecation Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead. */ public function testLegacyConfigNull() { + $this->expectDeprecation('Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.'); $this->fixer->configure(null); $this->doTest($this->removeLinesFromString($this->template, [23, 24]), $this->template); @@ -105,10 +105,10 @@ public function testLegacyConfigNull() * * @group legacy * @dataProvider provideWithConfigCases - * @expectedDeprecation Passing "tokens" at the root of the configuration for rule "no_extra_blank_lines" is deprecated and will not be supported in 3.0, use "tokens" => array(...) option instead. */ public function testLegacyWithConfig(array $lineNumberRemoved, array $config) { + $this->expectDeprecation('Passing "tokens" at the root of the configuration for rule "no_extra_blank_lines" is deprecated and will not be supported in 3.0, use "tokens" => array(...) option instead.'); $this->fixer->configure($config); $this->doTest($this->removeLinesFromString($this->template, $lineNumberRemoved), $this->template); @@ -778,10 +778,10 @@ private function test($b) { /** * @group legacy - * @expectedDeprecation Token "useTrait" in option "tokens" for rule "no_extra_blank_lines" is deprecated and will be removed in 3.0, use "use_trait" instead. */ public function testRemoveBetweenUseTraitsDeprecatedToken() { + $this->expectDeprecation('Token "useTrait" in option "tokens" for rule "no_extra_blank_lines" is deprecated and will be removed in 3.0, use "use_trait" instead.'); $this->fixer->configure(['tokens' => ['useTrait']]); $this->doTest( ' array(...) option instead. */ public function testLegacyFixWithConfiguration(array $configuration, $expected, $input) { + $this->expectDeprecation('Passing "positions" at the root of the configuration for rule "no_spaces_around_offset" is deprecated and will not be supported in 3.0, use "positions" => array(...) option instead.'); $this->fixer->configure($configuration); $this->doTest($expected, $input); } diff --git a/tests/FixerConfiguration/FixerConfigurationResolverRootlessTest.php b/tests/FixerConfiguration/FixerConfigurationResolverRootlessTest.php index a76b1c176cd..81596c62508 100644 --- a/tests/FixerConfiguration/FixerConfigurationResolverRootlessTest.php +++ b/tests/FixerConfiguration/FixerConfigurationResolverRootlessTest.php @@ -35,10 +35,10 @@ public function testMapRootConfigurationTo() /** * @group legacy - * @expectedDeprecation Passing "foo" at the root of the configuration for rule "bar" is deprecated and will not be supported in 3.0, use "foo" => array(...) option instead. */ public function testResolveWithMappedRoot() { + $this->expectDeprecation('Passing "foo" at the root of the configuration for rule "bar" is deprecated and will not be supported in 3.0, use "foo" => array(...) option instead.'); $options = [new FixerOption('foo', 'Bar.')]; $configuration = new FixerConfigurationResolverRootless('foo', $options, 'bar'); diff --git a/tests/FixerConfiguration/FixerConfigurationResolverTest.php b/tests/FixerConfiguration/FixerConfigurationResolverTest.php index 29f23435a49..18edf9afd74 100644 --- a/tests/FixerConfiguration/FixerConfigurationResolverTest.php +++ b/tests/FixerConfiguration/FixerConfigurationResolverTest.php @@ -203,11 +203,9 @@ public function testResolveWithAliasedDuplicateConfig() ]); } - /** - * @expectedDeprecation Option "baz" is deprecated, use "bar" instead. - */ public function testResolveWithDeprecatedAlias() { + $this->expectDeprecation('Option "baz" is deprecated, use "bar" instead.'); $configuration = new FixerConfigurationResolver([ new AliasedFixerOption(new FixerOption('bar', 'Bar.'), 'baz'), ]); diff --git a/tests/FixerDefinition/FixerDefinitionTest.php b/tests/FixerDefinition/FixerDefinitionTest.php index edc10300bff..fd238235e75 100644 --- a/tests/FixerDefinition/FixerDefinitionTest.php +++ b/tests/FixerDefinition/FixerDefinitionTest.php @@ -55,10 +55,10 @@ public function testGetDescription() /** * @group legacy - * @expectedDeprecation PhpCsFixer\FixerDefinition\FixerDefinition::getConfigurationDescription is deprecated and will be removed in 3.0. */ public function testGetConfigurationDescription() { + $this->expectDeprecation('PhpCsFixer\\FixerDefinition\\FixerDefinition::getConfigurationDescription is deprecated and will be removed in 3.0.'); $definition = new FixerDefinition('', []); static::assertNull($definition->getConfigurationDescription()); @@ -74,11 +74,11 @@ public function testGetConfigurationDescription() /** * @group legacy - * @expectedDeprecation Argument #5 of FixerDefinition::__construct() is deprecated and will be removed in 3.0. - * @expectedDeprecation PhpCsFixer\FixerDefinition\FixerDefinition::getDefaultConfiguration is deprecated and will be removed in 3.0. */ public function testGetDefaultConfiguration() { + $this->expectDeprecation('PhpCsFixer\\FixerDefinition\\FixerDefinition::getDefaultConfiguration is deprecated and will be removed in 3.0.'); + $this->expectDeprecation('Argument #5 of FixerDefinition::__construct() is deprecated and will be removed in 3.0.'); $definition = new FixerDefinition('', []); static::assertNull($definition->getDefaultConfiguration()); @@ -101,10 +101,10 @@ public function testGetRiskyDescription() /** * @group legacy - * @expectedDeprecation Arguments #5 and #6 of FixerDefinition::__construct() are deprecated and will be removed in 3.0, use argument #4 instead. */ public function testLegacyGetRiskyDescription() { + $this->expectDeprecation('Arguments #5 and #6 of FixerDefinition::__construct() are deprecated and will be removed in 3.0, use argument #4 instead.'); $definition = new FixerDefinition('', [], null, null, null, 'Foo'); static::assertSame('Foo', $definition->getRiskyDescription()); diff --git a/tests/RuleSet/RuleSetTest.php b/tests/RuleSet/RuleSetTest.php index 15ae9d25689..a27ed7ec178 100644 --- a/tests/RuleSet/RuleSetTest.php +++ b/tests/RuleSet/RuleSetTest.php @@ -418,10 +418,10 @@ public static function providePhpUnitTargetVersionHasSetCases() /** * @group legacy - * @expectedDeprecation PhpCsFixer\RuleSet\RuleSet::create is deprecated and will be removed in 3.0, use the constructor. */ public function testCreate() { + $this->expectDeprecation('PhpCsFixer\\RuleSet\\RuleSet::create is deprecated and will be removed in 3.0, use the constructor.'); $ruleSet = RuleSet::create(); static::assertInstanceOf(RuleSet::class, $ruleSet); @@ -429,10 +429,10 @@ public function testCreate() /** * @group legacy - * @expectedDeprecation PhpCsFixer\RuleSet\RuleSet::getSetDefinitionNames is deprecated and will be removed in 3.0, use PhpCsFixer\RuleSet\RuleSets::getSetDefinitionNames. */ public function testGetSetDefinitionNames() { + $this->expectDeprecation('PhpCsFixer\\RuleSet\\RuleSet::getSetDefinitionNames is deprecated and will be removed in 3.0, use PhpCsFixer\\RuleSet\\RuleSets::getSetDefinitionNames.'); $ruleSet = new RuleSet([]); $ruleSet->getSetDefinitionNames(); } diff --git a/tests/Test/AbstractFixerTestCase.php b/tests/Test/AbstractFixerTestCase.php index 5ae25a2ac26..24fcf314853 100644 --- a/tests/Test/AbstractFixerTestCase.php +++ b/tests/Test/AbstractFixerTestCase.php @@ -219,11 +219,11 @@ final public function testFixerDefinitions() /** * @group legacy - * @expectedDeprecation PhpCsFixer\FixerDefinition\FixerDefinition::getConfigurationDescription is deprecated and will be removed in 3.0. - * @expectedDeprecation PhpCsFixer\FixerDefinition\FixerDefinition::getDefaultConfiguration is deprecated and will be removed in 3.0. */ final public function testLegacyFixerDefinitions() { + $this->expectDeprecation('PhpCsFixer\\FixerDefinition\\FixerDefinition::getConfigurationDescription is deprecated and will be removed in 3.0.'); + $this->expectDeprecation('PhpCsFixer\\FixerDefinition\\FixerDefinition::getDefaultConfiguration is deprecated and will be removed in 3.0.'); $definition = $this->fixer->getDefinition(); static::assertNull($definition->getConfigurationDescription(), sprintf('[%s] No configuration description expected.', $this->fixer->getName())); diff --git a/tests/Test/IntegrationCaseTest.php b/tests/Test/IntegrationCaseTest.php index d6a678e167a..7c6e3234f16 100644 --- a/tests/Test/IntegrationCaseTest.php +++ b/tests/Test/IntegrationCaseTest.php @@ -25,10 +25,10 @@ final class IntegrationCaseTest extends TestCase { /** * @group legacy - * @expectedDeprecation The "PhpCsFixer\Test\IntegrationCase::shouldCheckPriority" method is deprecated. You should stop using it, as it will be removed in 3.0 version. */ public function testLegacyShouldCheckPriority() { + $this->expectDeprecation('The "PhpCsFixer\Test\IntegrationCase::shouldCheckPriority" method is deprecated. You should stop using it, as it will be removed in 3.0 version.'); $integrationCase = new LegacyIntegrationCase( 'foo', 'Foo', diff --git a/tests/TestCase.php b/tests/TestCase.php index 09e7e644674..8ccf9b910c4 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -20,6 +20,7 @@ use PHPUnitGoodPractices\Traits\ProphecyOverMockObjectTrait; use PHPUnitGoodPractices\Traits\ProphesizeOnlyInterfaceTrait; use Prophecy\PhpUnit\ProphecyTrait; +use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; // we check single, example DEV dependency - if it's there, we have the dev dependencies, if not, we are using PHP-CS-Fixer as library and trying to use internal TestCase... if (trait_exists(ProphesizeOnlyInterfaceTrait::class)) { @@ -52,6 +53,7 @@ abstract class InterimTestCase extends BaseTestCase abstract class TestCase extends InterimTestCase { use ExpectationViaCodeOverAnnotationTrait; + use ExpectDeprecationTrait; use ExpectOverSetExceptionTrait; use IdentityOverEqualityTrait; use PolyfillTrait; diff --git a/tests/Tokenizer/TokenTest.php b/tests/Tokenizer/TokenTest.php index a968feb02c9..ba16319b93a 100644 --- a/tests/Tokenizer/TokenTest.php +++ b/tests/Tokenizer/TokenTest.php @@ -56,10 +56,10 @@ public function provideConstructorValidationCases() /** * @group legacy - * @expectedDeprecation PhpCsFixer\Tokenizer\Token::clear is deprecated and will be removed in 3.0. */ public function testClear() { + $this->expectDeprecation('PhpCsFixer\\Tokenizer\\Token::clear is deprecated and will be removed in 3.0.'); $token = $this->getForeachToken(); $token->clear(); @@ -188,10 +188,10 @@ public function provideIsObjectOperatorCases() /** * @group legacy - * @expectedDeprecation PhpCsFixer\Tokenizer\Token::isEmpty is deprecated and will be removed in 3.0. */ public function testIsEmpty() { + $this->expectDeprecation('PhpCsFixer\\Tokenizer\\Token::isEmpty is deprecated and will be removed in 3.0.'); $braceToken = $this->getBraceToken(); static::assertFalse($braceToken->isEmpty()); @@ -481,10 +481,10 @@ public function provideIsKeyCaseSensitiveCases() /** * @group legacy - * @expectedDeprecation PhpCsFixer\Tokenizer\Token::isChanged is deprecated and will be removed in 3.0. */ public function testIsChanged() { + $this->expectDeprecation('PhpCsFixer\\Tokenizer\\Token::isChanged is deprecated and will be removed in 3.0.'); $token = new Token([T_WHITESPACE, ' ']); static::assertFalse($token->isChanged()); } diff --git a/tests/Tokenizer/TokensTest.php b/tests/Tokenizer/TokensTest.php index 2ca1b033210..7af9127fec7 100644 --- a/tests/Tokenizer/TokensTest.php +++ b/tests/Tokenizer/TokensTest.php @@ -806,22 +806,22 @@ public function testFindBlockEndInvalidStart() } /** - * @expectedDeprecation Argument #3 of Tokens::findBlockEnd is deprecated and will be removed in 3.0, use Tokens::findBlockStart instead. * @group legacy */ public function testFindBlockEndLastParameterFalseDeprecated() { + $this->expectDeprecation('Argument #3 of Tokens::findBlockEnd is deprecated and will be removed in 3.0, use Tokens::findBlockStart instead.'); $tokens = Tokens::fromCode('findBlockEnd(Tokens::BLOCK_TYPE_DYNAMIC_VAR_BRACE, 4, false)); } /** - * @expectedDeprecation Argument #3 of Tokens::findBlockEnd is deprecated and will be removed in 3.0, you can safely drop the argument. * @group legacy */ public function testFindBlockEndLastParameterTrueDeprecated() { + $this->expectDeprecation('Argument #3 of Tokens::findBlockEnd is deprecated and will be removed in 3.0, you can safely drop the argument.'); $tokens = Tokens::fromCode('findBlockEnd(Tokens::BLOCK_TYPE_DYNAMIC_VAR_BRACE, 2, true));