Browse Source

DX: unify fixer's test method names - quick wins (#7584)

Kuba Werłos 1 year ago
parent
commit
93fa899049

+ 1 - 1
phpstan.dist.neon

@@ -21,7 +21,7 @@ parameters:
         -
             message: '#^Method PhpCsFixer\\Tests\\.+::provide.+Cases\(\) return type has no value type specified in iterable type iterable\.$#'
             path: tests
-            count: 1046
+            count: 1041
 
         -
             message: '#Call to static method .+ with .+ will always evaluate to true.$#'

+ 3 - 3
tests/Fixer/ControlStructure/ControlStructureContinuationPositionFixerTest.php

@@ -271,9 +271,9 @@ final class ControlStructureContinuationPositionFixerTest extends AbstractFixerT
     /**
      * @param null|array<string, mixed> $configuration
      *
-     * @dataProvider provideFixWithWindowsLineEndingsCases
+     * @dataProvider provideWithWhitespacesConfigCases
      */
-    public function testFixWithWindowsLineEndings(string $expected, ?string $input = null, array $configuration = null): void
+    public function testWithWhitespacesConfig(string $expected, ?string $input = null, array $configuration = null): void
     {
         if (null !== $configuration) {
             $this->fixer->configure($configuration);
@@ -286,7 +286,7 @@ final class ControlStructureContinuationPositionFixerTest extends AbstractFixerT
         $this->doTest($expected, $input);
     }
 
-    public static function provideFixWithWindowsLineEndingsCases(): iterable
+    public static function provideWithWhitespacesConfigCases(): iterable
     {
         foreach (self::provideFixCases() as $label => $case) {
             yield $label => [

+ 3 - 3
tests/Fixer/ControlStructure/EmptyLoopBodyFixerTest.php

@@ -26,9 +26,9 @@ final class EmptyLoopBodyFixerTest extends AbstractFixerTestCase
     /**
      * @param array<string, mixed> $config
      *
-     * @dataProvider provideFixConfigCases
+     * @dataProvider provideFixCases
      */
-    public function testFixConfig(string $expected, ?string $input = null, array $config = []): void
+    public function testFix(string $expected, ?string $input = null, array $config = []): void
     {
         if ([] === $config) {
             $this->doTest($expected, $input);
@@ -46,7 +46,7 @@ final class EmptyLoopBodyFixerTest extends AbstractFixerTestCase
         }
     }
 
-    public static function provideFixConfigCases(): iterable
+    public static function provideFixCases(): iterable
     {
         yield 'simple "while"' => [
             '<?php while(foo());',

+ 3 - 3
tests/Fixer/ControlStructure/EmptyLoopConditionFixerTest.php

@@ -26,16 +26,16 @@ final class EmptyLoopConditionFixerTest extends AbstractFixerTestCase
     /**
      * @param array<string, mixed> $config
      *
-     * @dataProvider provideFixConfigCases
+     * @dataProvider provideFixCases
      */
-    public function testFixConfig(string $expected, ?string $input = null, array $config = []): void
+    public function testFix(string $expected, ?string $input = null, array $config = []): void
     {
         $this->fixer->configure($config);
 
         $this->doTest($expected, $input);
     }
 
-    public static function provideFixConfigCases(): iterable
+    public static function provideFixCases(): iterable
     {
         yield 'from `for` to `while`' => [
             '<?php

+ 1 - 12
tests/Fixer/FunctionNotation/LambdaNotUsedImportFixerTest.php

@@ -26,7 +26,7 @@ final class LambdaNotUsedImportFixerTest extends AbstractFixerTestCase
     /**
      * @dataProvider provideFixCases
      */
-    public function testFix(string $expected, string $input): void
+    public function testFix(string $expected, ?string $input = null): void
     {
         $this->doTest($expected, $input);
     }
@@ -125,18 +125,7 @@ $a = function() use ($b) { new class(){ public function foo($b){echo $b;}}; }; /
                     new class("bar") {};
                 };',
         ];
-    }
 
-    /**
-     * @dataProvider provideDoNotFixCases
-     */
-    public function testDoNotFix(string $expected): void
-    {
-        $this->doTest($expected);
-    }
-
-    public static function provideDoNotFixCases(): iterable
-    {
         yield 'reference' => [
             '<?php $fn = function() use(&$b) {} ?>',
         ];

+ 3 - 3
tests/Fixer/Import/NoLeadingImportSlashFixerTest.php

@@ -213,16 +213,16 @@ use const \some\Z\{ConstX,ConstY,ConstZ,};
     }
 
     /**
-     * @dataProvider provideFixPrePHP80Cases
+     * @dataProvider provideFixPre80Cases
      *
      * @requires PHP <8.0
      */
-    public function testFixPrePHP80(string $expected, ?string $input = null): void
+    public function testFixPre80(string $expected, ?string $input = null): void
     {
         $this->doTest($expected, $input);
     }
 
-    public static function provideFixPrePHP80Cases(): iterable
+    public static function provideFixPre80Cases(): iterable
     {
         yield [
             '<?php use /*1*/A\D;',

+ 1 - 14
tests/Fixer/Import/NoUnusedImportsFixerTest.php

@@ -1430,7 +1430,7 @@ use Z;
     /**
      * @requires PHP <8.0
      */
-    public function testFixPrePHP80(): void
+    public function testFixPre80(): void
     {
         $this->doTest(
             '<?php
@@ -1605,20 +1605,7 @@ function test2($param = (new Foo6)) {}
 const D = new Foo7(1,2);
 ',
         ];
-    }
 
-    /**
-     * @requires PHP 8.1
-     *
-     * @dataProvider provideFixPhp81Cases
-     */
-    public function testFixPhp81(string $expected): void
-    {
-        $this->doTest($expected);
-    }
-
-    public static function provideFixPhp81Cases(): iterable
-    {
         yield [
             '<?php
                 enum Foo: string

+ 3 - 3
tests/Fixer/Import/SingleLineAfterImportsFixerTest.php

@@ -505,16 +505,16 @@ use some\a\ClassA; use function some\a\fn_a; use const some\c;
     }
 
     /**
-     * @dataProvider provideMessyWhitespacesCases
+     * @dataProvider provideWithWhitespacesConfigCases
      */
-    public function testMessyWhitespaces(string $expected, ?string $input = null): void
+    public function testWithWhitespacesConfig(string $expected, ?string $input = null): void
     {
         $this->fixer->setWhitespacesConfig(new WhitespacesFixerConfig("\t", "\r\n"));
 
         $this->doTest($expected, $input);
     }
 
-    public static function provideMessyWhitespacesCases(): iterable
+    public static function provideWithWhitespacesConfigCases(): iterable
     {
         yield [
             "<?php namespace A\\B;\r\n    use D;\r\n\r\n    class C {}",

+ 3 - 3
tests/Fixer/LanguageConstruct/DeclareEqualNormalizeFixerTest.php

@@ -112,9 +112,9 @@ final class DeclareEqualNormalizeFixerTest extends AbstractFixerTestCase
     /**
      * @param array<mixed> $config
      *
-     * @dataProvider provideInvalidConfigCases
+     * @dataProvider provideInvalidConfigurationCases
      */
-    public function testInvalidConfig(array $config, string $expectedMessage): void
+    public function testInvalidConfiguration(array $config, string $expectedMessage): void
     {
         $this->expectException(InvalidFixerConfigurationException::class);
         $this->expectExceptionMessage(sprintf('[declare_equal_normalize] Invalid configuration: %s', $expectedMessage));
@@ -122,7 +122,7 @@ final class DeclareEqualNormalizeFixerTest extends AbstractFixerTestCase
         $this->fixer->configure($config);
     }
 
-    public static function provideInvalidConfigCases(): iterable
+    public static function provideInvalidConfigurationCases(): iterable
     {
         yield [
             [1, 2],

+ 1 - 1
tests/Fixer/LanguageConstruct/DirConstantFixerTest.php

@@ -185,7 +185,7 @@ final class DirConstantFixerTest extends AbstractFixerTestCase
     /**
      * @requires PHP <8.0
      */
-    public function testFixPrePHP80(): void
+    public function testFixPre80(): void
     {
         $this->doTest(
             '<?php $x =# A

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