Browse Source

Always lint test cases with the stricter process linter

Graham Campbell 4 years ago
parent
commit
1d2f24b9d0

+ 1 - 0
.appveyor.yml

@@ -6,6 +6,7 @@ clone_folder: C:\projects\php-cs-fixer
 environment:
     matrix:
         - php_ver: 7.3.1
+          FAST_LINT_TEST_CASES: 1
         - php_ver: 5.6.40
           SKIP_LINT_TEST_CASES: 1
 

+ 1 - 0
phpunit.xml.dist

@@ -53,6 +53,7 @@
     <php>
         <ini name="zend.enable_gc" value="0"/>
         <ini name="memory_limit" value="1G"/>
+        <env name="FAST_LINT_TEST_CASES" value="0"/>
         <env name="SKIP_LINT_TEST_CASES" value="0"/>
         <env name="PHP_CS_FIXER_TEST_ALLOW_SKIPPING_SMOKE_TESTS" value="1"/>
         <env name="PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER" value="0"/>

+ 16 - 5
tests/Fixer/Alias/PowToExponentiationFixerTest.php

@@ -37,7 +37,7 @@ final class PowToExponentiationFixerTest extends AbstractFixerTestCase
 
     public function provideFixCases()
     {
-        return [
+        $tests = [
             [
                 '<?php 1**2;',
                 '<?php pow(1,2);',
@@ -134,10 +134,6 @@ final class PowToExponentiationFixerTest extends AbstractFixerTestCase
                 '<?php echo ${$bar}** ${$foo};',
                 '<?php echo pow(${$bar}, ${$foo});',
             ],
-            [
-                '<?php echo $a{1}** $b{2+5};',
-                '<?php echo pow($a{1}, $b{2+5});',
-            ],
             [
                 '<?php echo $a[2^3+1]->test(1,2)** $b[2+$c];',
                 '<?php echo pow($a[2^3+1]->test(1,2), $b[2+$c]);',
@@ -222,7 +218,22 @@ final class PowToExponentiationFixerTest extends AbstractFixerTestCase
                     public function &pow($a, $b);
                 }',
             ],
+            [
+                '<?php echo $a[1]** $b[2+5];',
+                '<?php echo pow($a[1], $b[2+5]);',
+            ],
         ];
+
+        foreach ($tests as $index => $test) {
+            yield $index => $test;
+        }
+
+        if (\PHP_VERSION_ID < 80000) {
+            yield [
+                '<?php echo $a{1}** $b{2+5};',
+                '<?php echo pow($a{1}, $b{2+5});',
+            ];
+        }
     }
 
     /**

+ 1 - 0
tests/Fixer/ArrayNotation/NormalizeIndexBraceFixerTest.php

@@ -20,6 +20,7 @@ use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  * @internal
  *
  * @covers \PhpCsFixer\Fixer\ArrayNotation\NormalizeIndexBraceFixer
+ * @requires PHP <8.0
  */
 final class NormalizeIndexBraceFixerTest extends AbstractFixerTestCase
 {

+ 0 - 2
tests/Fixer/Basic/EncodingFixerTest.php

@@ -40,8 +40,6 @@ final class EncodingFixerTest extends AbstractFixerTestCase
 
         yield $this->prepareTestCase('test-utf8.case2.php', 'test-utf8.case2-bom.php');
 
-        yield ['<?php'];
-
         yield ['<?php '];
     }
 

+ 4 - 0
tests/Fixer/Casing/MagicConstantCasingFixerTest.php

@@ -93,6 +93,10 @@ final class MagicConstantCasingFixerTest extends AbstractFixerTestCase
      */
     public function testFix74($expected, $input = null)
     {
+        if (\PHP_VERSION_ID >= 80000) {
+            static::markTestSkipped('PHP < 8.0 is required.');
+        }
+
         $this->doTest($expected, $input);
     }
 

+ 6 - 6
tests/Fixer/Casing/MagicMethodCasingFixerTest.php

@@ -57,8 +57,8 @@ final class MagicMethodCasingFixerTest extends AbstractFixerTestCase
 
         // static version of '__set_state'
         yield 'method declaration for "__set_state".' => [
-            '<?php class Foo {public static function __set_state($a, $b){}}',
-            '<?php class Foo {public static function __set_STATE($a, $b){}}',
+            '<?php class Foo {public static function __set_state($a){}}',
+            '<?php class Foo {public static function __set_STATE($a){}}',
         ];
 
         yield 'static call to "__set_state".' => [
@@ -72,7 +72,7 @@ final class MagicMethodCasingFixerTest extends AbstractFixerTestCase
             '<?php class Foo {public function __CLONE(){}}',
         ];
 
-        unset($allMethodNames['__clone']);
+        unset($allMethodNames['__clone'], $allMethodNames['__set_state']);
 
         // two arguments
         $methodNames = ['__call', '__set'];
@@ -94,7 +94,7 @@ final class MagicMethodCasingFixerTest extends AbstractFixerTestCase
         }
 
         // single argument
-        $methodNames = ['__get', '__isset', '__unset'];
+        $methodNames = ['__get', '__isset', '__unset', '__unserialize'];
 
         foreach ($methodNames as $i => $name) {
             unset($allMethodNames[$name]);
@@ -148,7 +148,7 @@ class Foo extends Bar
     }
 
     public function __unserialize($payload) {
-        $this->__unserialize($this_>$a);
+        $this->__unserialize($this->$a);
     }
 }
 ',
@@ -161,7 +161,7 @@ class Foo extends Bar
     }
 
     public function __unSERIALIZE($payload) {
-        $this->__unSERIALIZE($this_>$a);
+        $this->__unSERIALIZE($this->$a);
     }
 }
 ',

+ 7 - 1
tests/Fixer/CastNotation/LowercaseCastFixerTest.php

@@ -72,7 +72,13 @@ final class LowercaseCastFixerTest extends AbstractFixerTestCase
 
     public function provideFixCases()
     {
-        foreach (['boolean', 'bool', 'integer', 'int', 'double', 'float', 'float', 'string', 'array', 'object', 'unset', 'binary'] as $from) {
+        $types = ['boolean', 'bool', 'integer', 'int', 'double', 'float', 'float', 'string', 'array', 'object', 'binary'];
+
+        if (\PHP_VERSION_ID < 80000) {
+            $types[] = 'unset';
+        }
+
+        foreach ($types as $from) {
             foreach ($this->createCasesFor($from) as $case) {
                 yield $case;
             }

+ 11 - 4
tests/Fixer/CastNotation/ModernizeTypesCastingFixerTest.php

@@ -179,7 +179,7 @@ OVERRIDDEN;
 
     public function provideFix70Cases()
     {
-        return [
+        $tests = [
             [
                 '<?php $foo = ((string) $x)[0];',
                 '<?php $foo = strval($x)[0];',
@@ -188,11 +188,18 @@ OVERRIDDEN;
                 '<?php $foo = ((string) ($x + $y))[0];',
                 '<?php $foo = strval($x + $y)[0];',
             ],
-            [
+        ];
+
+        foreach ($tests as $index => $test) {
+            yield $index => $test;
+        }
+
+        if (\PHP_VERSION_ID < 80000) {
+            yield [
                 '<?php $foo = ((string) ($x + $y)){0};',
                 '<?php $foo = strval($x + $y){0};',
-            ],
-        ];
+            ];
+        }
     }
 
     /**

+ 1 - 0
tests/Fixer/CastNotation/NoUnsetCastFixerTest.php

@@ -18,6 +18,7 @@ use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  * @internal
  *
  * @covers \PhpCsFixer\Fixer\CastNotation\NoUnsetCastFixer
+ * @requires PHP <8.0
  */
 final class NoUnsetCastFixerTest extends AbstractFixerTestCase
 {

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