Browse Source

Merge branch 'master' into 3.0

# Conflicts:
#	.php_cs.dist
#	tests/Console/ConfigurationResolverTest.php
#	tests/Fixer/LanguageConstruct/IsNullFixerTest.php
#	tests/Fixer/Operator/BinaryOperatorSpacesFixerTest.php
Dariusz Ruminski 4 years ago
parent
commit
223d0c297d

+ 1 - 0
.composer-require-checker.json

@@ -6,6 +6,7 @@
         "PHPUnit\\Framework\\Constraint\\IsIdentical",
         "PHPUnit\\Framework\\TestCase",
         "PHPUnit\\Runner\\Version",
+        "PHPUnitGoodPractices\\Polyfill\\PolyfillTrait",
         "PHPUnitGoodPractices\\Traits\\ExpectationViaCodeOverAnnotationTrait",
         "PHPUnitGoodPractices\\Traits\\ExpectOverSetExceptionTrait",
         "PHPUnitGoodPractices\\Traits\\IdentityOverEqualityTrait",

+ 1 - 1
.php_cs.dist

@@ -23,7 +23,7 @@ $config = (new PhpCsFixer\Config())
     ->setRiskyAllowed(true)
     ->setRules([
         '@PHP56Migration:risky' => true,
-        '@PHPUnit60Migration:risky' => true,
+        '@PHPUnit75Migration:risky' => true,
         '@PhpCsFixer' => true,
         '@PhpCsFixer:risky' => true,
         'header_comment' => ['header' => $header],

+ 1 - 0
composer.json

@@ -41,6 +41,7 @@
         "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2",
         "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1",
         "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.1",
+        "phpunitgoodpractices/polyfill": "^1.5",
         "phpunitgoodpractices/traits": "^1.9.1",
         "symfony/phpunit-bridge": "^5.1",
         "symfony/yaml": "^3.0 || ^4.0 || ^5.0"

+ 3 - 3
tests/AutoReview/ProjectCodeTest.php

@@ -254,8 +254,8 @@ final class ProjectCodeTest extends TestCase
         }
 
         foreach ($publicMethods as $method) {
-            static::assertRegExp(
-                '/^(test|provide|setUpBeforeClass$|tearDownAfterClass$)/',
+            static::assertMatchesRegularExpression(
+                '/^(test|expect|provide|setUpBeforeClass$|tearDownAfterClass$)/',
                 $method->getName(),
                 sprintf('Public method "%s::%s" is not properly named.', $reflectionClass->getName(), $method->getName())
             );
@@ -278,7 +278,7 @@ final class ProjectCodeTest extends TestCase
         }
 
         foreach ($usedDataProviderMethodNames as $dataProviderMethodName) {
-            static::assertRegExp('/^provide[A-Z]\S+Cases$/', $dataProviderMethodName, sprintf(
+            static::assertMatchesRegularExpression('/^provide[A-Z]\S+Cases$/', $dataProviderMethodName, sprintf(
                 'Data provider in "%s" with name "%s" is not correctly named.',
                 $testClassName,
                 $dataProviderMethodName

+ 4 - 4
tests/Cache/FileHandlerTest.php

@@ -99,7 +99,7 @@ final class FileHandlerTest extends TestCase
         $file = __DIR__.'/non-existent-directory/.php_cs.cache';
 
         $this->expectException(\Symfony\Component\Filesystem\Exception\IOException::class);
-        $this->expectExceptionMessageRegExp(sprintf(
+        $this->expectExceptionMessageMatches(sprintf(
             '#^Directory of cache file "%s" does not exists.#',
             preg_quote($file, '#')
         ));
@@ -135,7 +135,7 @@ final class FileHandlerTest extends TestCase
         $handler = new FileHandler($dir);
 
         $this->expectException(\Symfony\Component\Filesystem\Exception\IOException::class);
-        $this->expectExceptionMessageRegExp(sprintf(
+        $this->expectExceptionMessageMatches(sprintf(
             '#^%s$#',
             preg_quote('Cannot write cache file "'.realpath($dir).'" as the location exists as directory.', '#')
         ));
@@ -153,7 +153,7 @@ final class FileHandlerTest extends TestCase
         $handler = new FileHandler($file);
 
         $this->expectException(\Symfony\Component\Filesystem\Exception\IOException::class);
-        $this->expectExceptionMessageRegExp(sprintf(
+        $this->expectExceptionMessageMatches(sprintf(
             '#^%s$#',
             preg_quote('Cannot write to file "'.realpath($file).'" as it is not writable.', '#')
         ));
@@ -166,7 +166,7 @@ final class FileHandlerTest extends TestCase
         $file = __DIR__.'/../Fixtures/cache-file-handler/rw_cache.test';
         @unlink($file);
 
-        static::assertFileNotExists($file);
+        static::assertFileDoesNotExist($file);
 
         $handler = new FileHandler($file);
         $handler->write(new Cache($this->createSignature()));

+ 4 - 4
tests/ConfigTest.php

@@ -44,7 +44,7 @@ final class ConfigTest extends TestCase
             new ToolInfo()
         );
 
-        static::assertArraySubset(
+        static::assertSame(
             [
                 'cast_spaces' => true,
                 'braces' => true,
@@ -65,7 +65,7 @@ final class ConfigTest extends TestCase
             new ToolInfo()
         );
 
-        static::assertArraySubset(
+        static::assertSame(
             [
                 'array_syntax' => [
                     'syntax' => 'short',
@@ -190,7 +190,7 @@ final class ConfigTest extends TestCase
     public function testRegisterCustomFixersWithInvalidArgument()
     {
         $this->expectException(\InvalidArgumentException::class);
-        $this->expectExceptionMessageRegExp('/^Argument must be an array or a Traversable, got "\w+"\.$/');
+        $this->expectExceptionMessageMatches('/^Argument must be an array or a Traversable, got "\w+"\.$/');
 
         $config = new Config();
         $config->registerCustomFixers('foo');
@@ -257,7 +257,7 @@ final class ConfigTest extends TestCase
         $config = new Config();
 
         $this->expectException(\InvalidArgumentException::class);
-        $this->expectExceptionMessageRegExp('/^Argument must be an array or a Traversable, got "integer"\.$/');
+        $this->expectExceptionMessageMatches('/^Argument must be an array or a Traversable, got "integer"\.$/');
 
         $config->setFinder(123);
     }

+ 5 - 5
tests/Console/Command/DescribeCommandTest.php

@@ -129,7 +129,7 @@ Fixing examples:
         $commandTester = new CommandTester($command);
 
         $this->expectException(\InvalidArgumentException::class);
-        $this->expectExceptionMessageRegExp('#^Rule "Foo/bar" not found\.$#');
+        $this->expectExceptionMessageMatches('#^Rule "Foo/bar" not found\.$#');
         $commandTester->execute([
             'command' => $command->getName(),
             'name' => 'Foo/bar',
@@ -146,7 +146,7 @@ Fixing examples:
         $commandTester = new CommandTester($command);
 
         $this->expectException(\InvalidArgumentException::class);
-        $this->expectExceptionMessageRegExp('#^Set "@NoSuchSet" not found\.$#');
+        $this->expectExceptionMessageMatches('#^Set "@NoSuchSet" not found\.$#');
         $commandTester->execute([
             'command' => $command->getName(),
             'name' => '@NoSuchSet',
@@ -163,7 +163,7 @@ Fixing examples:
         $commandTester = new CommandTester($command);
 
         $this->expectException(\RuntimeException::class);
-        $this->expectExceptionMessageRegExp('/^Not enough arguments( \(missing: "name"\))?\.$/');
+        $this->expectExceptionMessageMatches('/^Not enough arguments( \(missing: "name"\))?\.$/');
         $commandTester->execute([
             'command' => $command->getName(),
         ]);
@@ -172,7 +172,7 @@ Fixing examples:
     public function testGetAlternativeSuggestion()
     {
         $this->expectException(\InvalidArgumentException::class);
-        $this->expectExceptionMessageRegExp('#^Rule "Foo2/bar" not found\. Did you mean "Foo/bar"\?$#');
+        $this->expectExceptionMessageMatches('#^Rule "Foo2/bar" not found\. Did you mean "Foo/bar"\?$#');
         $this->execute('Foo2/bar', false);
     }
 
@@ -206,7 +206,7 @@ Fixing examples:
             ]
         );
 
-        static::assertContains(\get_class($mock), $commandTester->getDisplay(true));
+        static::assertStringContainsString(\get_class($mock), $commandTester->getDisplay(true));
     }
 
     /**

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

@@ -31,7 +31,7 @@ final class FixCommandTest extends TestCase
         $this->expectException(
             \PhpCsFixer\ConfigurationException\InvalidConfigurationException::class
         );
-        $this->expectExceptionMessageRegExp(
+        $this->expectExceptionMessageMatches(
             '#^Empty rules value is not allowed\.$#'
         );
 

+ 6 - 6
tests/Console/ConfigurationResolverTest.php

@@ -38,7 +38,7 @@ final class ConfigurationResolverTest extends TestCase
     public function testSetOptionWithUndefinedOption()
     {
         $this->expectException(InvalidConfigurationException::class);
-        $this->expectExceptionMessageRegExp('/^Unknown option name: "foo"\.$/');
+        $this->expectExceptionMessageMatches('/^Unknown option name: "foo"\.$/');
 
         $this->createConfigurationResolver(['foo' => 'bar']);
     }
@@ -241,7 +241,7 @@ final class ConfigurationResolverTest extends TestCase
     public function testResolveConfigFileChooseFileWithInvalidFile()
     {
         $this->expectException(InvalidConfigurationException::class);
-        $this->expectExceptionMessageRegExp(
+        $this->expectExceptionMessageMatches(
             '#^The config file: ".+[\/\\\]Fixtures[\/\\\]ConfigurationResolverConfigFile[\/\\\]case_5[\/\\\]\.php_cs\.dist" does not return a "PhpCsFixer\\\ConfigInterface" instance\. Got: "string"\.$#'
         );
 
@@ -255,7 +255,7 @@ final class ConfigurationResolverTest extends TestCase
     public function testResolveConfigFileChooseFileWithInvalidFormat()
     {
         $this->expectException(InvalidConfigurationException::class);
-        $this->expectExceptionMessageRegExp('/^The format "xls" is not defined, supported are "checkstyle", "gitlab", "json", "junit", "txt", "xml"\.$/');
+        $this->expectExceptionMessageMatches('/^The format "xls" is not defined, supported are "checkstyle", "gitlab", "json", "junit", "txt", "xml"\.$/');
 
         $dirBase = $this->getFixtureDir();
 
@@ -267,7 +267,7 @@ final class ConfigurationResolverTest extends TestCase
     public function testResolveConfigFileChooseFileWithPathArrayWithoutConfig()
     {
         $this->expectException(InvalidConfigurationException::class);
-        $this->expectExceptionMessageRegExp('/^For multiple paths config parameter is required\.$/');
+        $this->expectExceptionMessageMatches('/^For multiple paths config parameter is required\.$/');
 
         $dirBase = $this->getFixtureDir();
 
@@ -1127,7 +1127,7 @@ final class ConfigurationResolverTest extends TestCase
         ]);
 
         $this->expectException(\InvalidArgumentException::class);
-        $this->expectExceptionMessageRegExp('#^"diff\-format" must be any of "null", "udiff", got "XXX"\.$#');
+        $this->expectExceptionMessageMatches('#^"diff\-format" must be any of "null", "udiff", got "XXX"\.$#');
 
         $resolver->getDiffer();
     }
@@ -1177,7 +1177,7 @@ final class ConfigurationResolverTest extends TestCase
         $resolver = $this->createConfigurationResolver(['rules' => '']);
 
         $this->expectException(InvalidConfigurationException::class);
-        $this->expectExceptionMessageRegExp('/^Empty rules value is not allowed\.$/');
+        $this->expectExceptionMessageMatches('/^Empty rules value is not allowed\.$/');
 
         $resolver->getRules();
     }

+ 5 - 5
tests/Console/Output/ErrorOutputTest.php

@@ -134,13 +134,13 @@ EOT;
 
         $displayed = $this->readFullStreamOutput($output);
 
-        static::assertContains($fixerName, $displayed);
-        static::assertContains($diffSpecificContext, $displayed);
+        static::assertStringContainsString($fixerName, $displayed);
+        static::assertStringContainsString($diffSpecificContext, $displayed);
 
-        static::assertContains($noDiffLintFixerName, $displayed);
+        static::assertStringContainsString($noDiffLintFixerName, $displayed);
 
-        static::assertNotContains($invalidErrorFixerName, $displayed);
-        static::assertNotContains($invalidDiff, $displayed);
+        static::assertStringNotContainsString($invalidErrorFixerName, $displayed);
+        static::assertStringNotContainsString($invalidDiff, $displayed);
     }
 
     /**

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