Browse Source

chore: do not perform type analysis in tests (#7852)

Kuba Werłos 1 year ago
parent
commit
0c28ccaf61

+ 2 - 2
dev-tools/composer.json

@@ -7,8 +7,8 @@
         "mi-schi/phpmd-extension": "^4.3.0",
         "phpmd/phpmd": "^2.15.0",
         "phpstan/extension-installer": "^1.3.1",
-        "phpstan/phpstan": "^1.10.51",
-        "phpstan/phpstan-phpunit": "^1.3.15",
+        "phpstan/phpstan": "^1.10.59",
+        "phpstan/phpstan-phpunit": "^1.3.16",
         "phpstan/phpstan-strict-rules": "^1.5.2"
     },
     "config": {

File diff suppressed because it is too large
+ 35 - 627
dev-tools/composer.lock


+ 0 - 5
phpstan.dist.neon

@@ -22,10 +22,5 @@ parameters:
             message: '#^Method PhpCsFixer\\Tests\\.+::provide.+Cases\(\) return type has no value type specified in iterable type iterable\.$#'
             path: tests
             count: 1021
-
-        -
-            message: '#Call to static method .+ with .+ will always evaluate to true.$#'
-            path: tests
-            count: 18
     tipsOfTheDay: false
     tmpDir: dev-tools/phpstan/cache

+ 0 - 10
tests/Cache/FileHandlerTest.php

@@ -17,7 +17,6 @@ namespace PhpCsFixer\Tests\Cache;
 use PhpCsFixer\Cache\Cache;
 use PhpCsFixer\Cache\CacheInterface;
 use PhpCsFixer\Cache\FileHandler;
-use PhpCsFixer\Cache\FileHandlerInterface;
 use PhpCsFixer\Cache\Signature;
 use PhpCsFixer\Cache\SignatureInterface;
 use PhpCsFixer\Tests\TestCase;
@@ -43,15 +42,6 @@ final class FileHandlerTest extends TestCase
         }
     }
 
-    public function testImplementsHandlerInterface(): void
-    {
-        $file = $this->getFile();
-
-        $handler = new FileHandler($file);
-
-        self::assertInstanceOf(FileHandlerInterface::class, $handler);
-    }
-
     public function testConstructorSetsFile(): void
     {
         $file = $this->getFile();

+ 0 - 7
tests/ConfigurationException/InvalidConfigurationExceptionTest.php

@@ -27,13 +27,6 @@ use PhpCsFixer\Tests\TestCase;
  */
 final class InvalidConfigurationExceptionTest extends TestCase
 {
-    public function testIsInvalidArgumentException(): void
-    {
-        $exception = new InvalidConfigurationException('I cannot do that, Dave.');
-
-        self::assertInstanceOf(\InvalidArgumentException::class, $exception);
-    }
-
     public function testDefaults(): void
     {
         $message = 'I cannot do that, Dave.';

+ 0 - 8
tests/ConfigurationException/InvalidFixerConfigurationExceptionTest.php

@@ -14,7 +14,6 @@ declare(strict_types=1);
 
 namespace PhpCsFixer\Tests\ConfigurationException;
 
-use PhpCsFixer\ConfigurationException\InvalidConfigurationException;
 use PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException;
 use PhpCsFixer\Console\Command\FixCommandExitStatusCalculator;
 use PhpCsFixer\Tests\TestCase;
@@ -28,13 +27,6 @@ use PhpCsFixer\Tests\TestCase;
  */
 final class InvalidFixerConfigurationExceptionTest extends TestCase
 {
-    public function testIsInvalidArgumentException(): void
-    {
-        $exception = new InvalidFixerConfigurationException('foo', 'I cannot do that, Dave.');
-
-        self::assertInstanceOf(InvalidConfigurationException::class, $exception);
-    }
-
     public function testDefaults(): void
     {
         $fixerName = 'hal';

+ 0 - 2
tests/ConfigurationException/InvalidForEnvFixerConfigurationExceptionTest.php

@@ -14,7 +14,6 @@ declare(strict_types=1);
 
 namespace PhpCsFixer\Tests\ConfigurationException;
 
-use PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException;
 use PhpCsFixer\ConfigurationException\InvalidForEnvFixerConfigurationException;
 use PhpCsFixer\Console\Command\FixCommandExitStatusCalculator;
 use PhpCsFixer\Tests\TestCase;
@@ -36,7 +35,6 @@ final class InvalidForEnvFixerConfigurationExceptionTest extends TestCase
             $message
         );
 
-        self::assertInstanceOf(InvalidFixerConfigurationException::class, $exception);
         self::assertSame(sprintf('[%s] %s', $fixerName, $message), $exception->getMessage());
         self::assertSame(FixCommandExitStatusCalculator::EXIT_STATUS_FLAG_HAS_INVALID_FIXER_CONFIG, $exception->getCode());
         self::assertSame($fixerName, $exception->getFixerName());

+ 0 - 11
tests/ConfigurationException/RequiredFixerConfigurationExceptionTest.php

@@ -14,7 +14,6 @@ declare(strict_types=1);
 
 namespace PhpCsFixer\Tests\ConfigurationException;
 
-use PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException;
 use PhpCsFixer\ConfigurationException\RequiredFixerConfigurationException;
 use PhpCsFixer\Console\Command\FixCommandExitStatusCalculator;
 use PhpCsFixer\Tests\TestCase;
@@ -28,16 +27,6 @@ use PhpCsFixer\Tests\TestCase;
  */
 final class RequiredFixerConfigurationExceptionTest extends TestCase
 {
-    public function testIsInvalidFixerConfigurationException(): void
-    {
-        $exception = new RequiredFixerConfigurationException(
-            'hal',
-            'I cannot do that, Dave.'
-        );
-
-        self::assertInstanceOf(InvalidFixerConfigurationException::class, $exception);
-    }
-
     public function testDefaults(): void
     {
         $fixerName = 'hal';

+ 0 - 10
tests/Console/Command/DescribeNameNotFoundExceptionTest.php

@@ -26,16 +26,6 @@ use PhpCsFixer\Tests\TestCase;
  */
 final class DescribeNameNotFoundExceptionTest extends TestCase
 {
-    public function testIsInvalidArgumentException(): void
-    {
-        $exception = new DescribeNameNotFoundException(
-            'Peter',
-            'weird'
-        );
-
-        self::assertInstanceOf(\InvalidArgumentException::class, $exception);
-    }
-
     public function testConstructorSetsValues(): void
     {
         $name = 'Peter';

+ 1 - 6
tests/Console/ConfigurationResolverTest.php

@@ -17,7 +17,6 @@ namespace PhpCsFixer\Tests\Console;
 use PhpCsFixer\AbstractFixer;
 use PhpCsFixer\Cache\NullCacheManager;
 use PhpCsFixer\Config;
-use PhpCsFixer\ConfigInterface;
 use PhpCsFixer\ConfigurationException\InvalidConfigurationException;
 use PhpCsFixer\Console\Command\FixCommand;
 use PhpCsFixer\Console\ConfigurationResolver;
@@ -31,7 +30,6 @@ use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver;
 use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface;
 use PhpCsFixer\FixerConfiguration\FixerOptionBuilder;
 use PhpCsFixer\FixerDefinition\FixerDefinitionInterface;
-use PhpCsFixer\Linter\LinterInterface;
 use PhpCsFixer\Tests\TestCase;
 use PhpCsFixer\Tokenizer\Tokens;
 use PhpCsFixer\ToolInfoInterface;
@@ -171,7 +169,6 @@ final class ConfigurationResolverTest extends TestCase
         $resolver = $this->createConfigurationResolver([]);
 
         self::assertNull($resolver->getConfigFile());
-        self::assertInstanceOf(ConfigInterface::class, $resolver->getConfig());
     }
 
     public function testResolveConfigFileByPathOfFile(): void
@@ -929,9 +926,7 @@ final class ConfigurationResolverTest extends TestCase
 
         self::assertInstanceOf(NullCacheManager::class, $cacheManager);
 
-        $linter = $resolver->getLinter();
-
-        self::assertInstanceOf(LinterInterface::class, $linter);
+        self::assertFalse($resolver->getLinter()->isAsync());
     }
 
     public function testResolveCacheFileWithOption(): void

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