Browse Source

PhpUnitDedicateAssertInternalTypeFixer - recover target option

Dariusz Ruminski 4 years ago
parent
commit
cb29f7285a

+ 2 - 0
doc/ruleSets/PHPUnit75MigrationRisky.rst

@@ -9,3 +9,5 @@ Rules
 
 - `@PHPUnit60Migration:risky <./PHPUnit60MigrationRisky.rst>`_
 - `php_unit_dedicate_assert_internal_type <./../rules/php_unit/php_unit_dedicate_assert_internal_type.rst>`_
+  config:
+  ``['target' => '7.5']``

+ 6 - 4
doc/rules/php_unit/php_unit_dedicate_assert_internal_type.rst

@@ -16,8 +16,6 @@ Configuration
 ``target``
 ~~~~~~~~~~
 
-.. warning:: This option is deprecated and will be removed on next major version. Option was not used.
-
 Target version of PHPUnit.
 
 Allowed values: ``'7.5'``, ``'newest'``
@@ -53,7 +51,11 @@ Rule sets
 The rule is part of the following rule sets:
 
 @PHPUnit75Migration:risky
-  Using the `@PHPUnit75Migration:risky <./../../ruleSets/PHPUnit75MigrationRisky.rst>`_ rule set will enable the ``php_unit_dedicate_assert_internal_type`` rule with the default config.
+  Using the `@PHPUnit75Migration:risky <./../../ruleSets/PHPUnit75MigrationRisky.rst>`_ rule set will enable the ``php_unit_dedicate_assert_internal_type`` rule with the config below:
+
+  ``['target' => '7.5']``
 
 @PHPUnit84Migration:risky
-  Using the `@PHPUnit84Migration:risky <./../../ruleSets/PHPUnit84MigrationRisky.rst>`_ rule set will enable the ``php_unit_dedicate_assert_internal_type`` rule with the default config.
+  Using the `@PHPUnit84Migration:risky <./../../ruleSets/PHPUnit84MigrationRisky.rst>`_ rule set will enable the ``php_unit_dedicate_assert_internal_type`` rule with the config below:
+
+  ``['target' => '7.5']``

+ 0 - 2
src/Fixer/PhpUnit/PhpUnitDedicateAssertInternalTypeFixer.php

@@ -98,13 +98,11 @@ final class MyTest extends \PHPUnit\Framework\TestCase
      */
     protected function createConfigurationDefinition()
     {
-        // @todo 3.0 drop `ConfigurationDefinitionFixerInterface`
         return new FixerConfigurationResolver([
             (new FixerOptionBuilder('target', 'Target version of PHPUnit.'))
                 ->setAllowedTypes(['string'])
                 ->setAllowedValues([PhpUnitTargetVersion::VERSION_7_5, PhpUnitTargetVersion::VERSION_NEWEST])
                 ->setDefault(PhpUnitTargetVersion::VERSION_NEWEST)
-                ->setDeprecationMessage('Option was not used.')
                 ->getOption(),
         ]);
     }

+ 3 - 1
src/RuleSet/Sets/PHPUnit75MigrationRiskySet.php

@@ -23,7 +23,9 @@ final class PHPUnit75MigrationRiskySet extends AbstractRuleSetDescription
     {
         return [
             '@PHPUnit60Migration:risky' => true,
-            'php_unit_dedicate_assert_internal_type' => true,
+            'php_unit_dedicate_assert_internal_type' => [
+                'target' => '7.5',
+            ],
         ];
     }
 

+ 2 - 7
tests/RuleSet/RuleSetsTest.php

@@ -14,7 +14,6 @@ namespace PhpCsFixer\Tests\RuleSet;
 
 use PhpCsFixer\AbstractFixer;
 use PhpCsFixer\Fixer\PhpUnit\PhpUnitTargetVersion;
-use PhpCsFixer\FixerConfiguration\DeprecatedFixerOption;
 use PhpCsFixer\FixerFactory;
 use PhpCsFixer\RuleSet\RuleSet;
 use PhpCsFixer\RuleSet\RuleSets;
@@ -197,7 +196,7 @@ Integration of %s.
         }
 
         if (!isset($allowedVersionsForFixer)) {
-            static::markTestSkipped(sprintf('The fixer "%s" does not have option "target".', $fixer->getName()));
+            throw new \Exception(sprintf('The fixer "%s" does not have option "target".', $fixer->getName()));
         }
 
         $allowedVersionsForRuleset = array_filter(
@@ -274,10 +273,6 @@ Integration of %s.
         $fixer = self::getFixerByName($ruleName);
 
         foreach ($fixer->getConfigurationDefinition()->getOptions() as $option) {
-            if ($option instanceof DeprecatedFixerOption) {
-                continue;
-            }
-
             if ('target' === $option->getName()) {
                 $targetVersion = $option->getDefault();
 
@@ -286,7 +281,7 @@ Integration of %s.
         }
 
         if (null === $targetVersion) {
-            static::markTestSkipped(sprintf('The fixer "%s" does not have option "target".', $fixer->getName()));
+            throw new \Exception(sprintf('The fixer "%s" does not have option "target".', $fixer->getName()));
         }
 
         return $targetVersion;