Browse Source

Use method expectDeprecation from Symfony Bridge instead of annotation

Kuba Werłos 3 years ago
parent
commit
c9ec8a678e

+ 1 - 0
.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",

+ 1 - 0
.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'],
     ])

+ 1 - 1
tests/ConfigTest.php

@@ -289,10 +289,10 @@ final class ConfigTest extends TestCase
 
     /**
      * @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();
     }
 }

+ 1 - 1
tests/Console/Command/FixCommandTest.php

@@ -42,10 +42,10 @@ final class FixCommandTest extends TestCase
 
     /**
      * @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',

+ 4 - 4
tests/Console/ConfigurationResolverTest.php

@@ -120,10 +120,10 @@ final class ConfigurationResolverTest extends TestCase
      * @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 @@ final class ConfigurationResolverTest extends TestCase
      * @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 @@ final class ConfigurationResolverTest extends TestCase
 
     /**
      * @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 @@ final class ConfigurationResolverTest extends TestCase
      * @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]);

+ 1 - 1
tests/Fixer/Alias/NoMixedEchoPrintFixerTest.php

@@ -290,10 +290,10 @@ final class NoMixedEchoPrintFixerTest 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 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);

+ 1 - 1
tests/Fixer/Alias/RandomApiMigrationFixerTest.php

@@ -42,10 +42,10 @@ final class RandomApiMigrationFixerTest extends AbstractFixerTestCase
 
     /**
      * @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');

+ 1 - 1
tests/Fixer/ArrayNotation/ArraySyntaxFixerTest.php

@@ -35,10 +35,10 @@ final class ArraySyntaxFixerTest 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 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(
             '<?php $a = array(); $b = array();',

+ 0 - 3
tests/Fixer/CastNotation/LowercaseCastFixerTest.php

@@ -13,7 +13,6 @@
 namespace PhpCsFixer\Tests\Fixer\CastNotation;
 
 use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
-use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
 
 /**
  * @author SpacePossum
@@ -24,8 +23,6 @@ use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
  */
 final class LowercaseCastFixerTest extends AbstractFixerTestCase
 {
-    use ExpectDeprecationTrait;
-
     /**
      * @param string      $expected
      * @param null|string $input

+ 0 - 3
tests/Fixer/CastNotation/ShortScalarCastFixerTest.php

@@ -13,7 +13,6 @@
 namespace PhpCsFixer\Tests\Fixer\CastNotation;
 
 use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
-use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
 
 /**
  * @author SpacePossum
@@ -24,8 +23,6 @@ use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
  */
 final class ShortScalarCastFixerTest extends AbstractFixerTestCase
 {
-    use ExpectDeprecationTrait;
-
     /**
      * @param string      $expected
      * @param null|string $input

Some files were not shown because too many files changed in this diff