Add AbstractConfigTestCase

by @Slamdunk

Some issues have been detected in this pull request

Issues that can be fixed by applying a patch

Review the proposed patch then download it to apply it manually or execute the following command from the repository root directory:

$ curl https://fabbot.io/patch/FriendsOfPHP/PHP-CS-Fixer/4413/919a430b35208dfc7e4626390f6260cd7a8a7580/cs.diff | patch -p0
diff -ru src/Test/AbstractConfigTestCase.php src/Test/AbstractConfigTestCase.php
--- src/Test/AbstractConfigTestCase.php	2019-05-14 08:48:45.670232877 +0000
+++ src/Test/AbstractConfigTestCase.php	2019-05-14 08:48:46.474211712 +0000
@@ -52,14 +52,14 @@
         sort($availableRules);
 
         $diff = array_diff($availableRules, $currentRules);
-        static::assertEmpty($diff, sprintf("The following fixers are missing:\n- %s", implode(\PHP_EOL.'- ', $diff)));
+        $this->assertEmpty($diff, sprintf("The following fixers are missing:\n- %s", implode(\PHP_EOL.'- ', $diff)));
 
         $diff = array_diff($currentRules, $availableRules);
-        static::assertEmpty($diff, sprintf("The following fixers are specified but non existing or deprecated:\n- %s", implode(\PHP_EOL.'- ', $diff)));
+        $this->assertEmpty($diff, sprintf("The following fixers are specified but non existing or deprecated:\n- %s", implode(\PHP_EOL.'- ', $diff)));
 
         $currentRules = array_keys($configRules);
         $orderedCurrentRules = $currentRules;
         sort($orderedCurrentRules);
-        static::assertSame($orderedCurrentRules, $currentRules, 'Fixers must be alphabetically ordered');
+        $this->assertSame($orderedCurrentRules, $currentRules, 'Fixers must be alphabetically ordered');
     }
 }
diff -ru tests/AutoReview/ProjectCodeTest.php tests/AutoReview/ProjectCodeTest.php
--- tests/AutoReview/ProjectCodeTest.php	2019-05-14 08:48:45.921226270 +0000
+++ tests/AutoReview/ProjectCodeTest.php	2019-05-14 08:48:46.812202815 +0000
@@ -59,7 +59,7 @@
             static function ($class) { return !class_exists($class) && !trait_exists($class); }
         );
 
-        static::assertSame([], $unknownClasses);
+        $this->assertSame([], $unknownClasses);
     }
 
     /**
@@ -72,12 +72,12 @@
         $testClassName = str_replace('PhpCsFixer', 'PhpCsFixer\\Tests', $className).'Test';
 
         if (\in_array($className, self::$classesWithoutTests, true)) {
-            static::assertFalse(class_exists($testClassName), sprintf('Class "%s" already has tests, so it should be removed from "%s::$classesWithoutTests".', $className, __CLASS__));
-            static::markTestIncomplete(sprintf('Class "%s" has no tests yet, please help and add it.', $className));
+            $this->assertFalse(class_exists($testClassName), sprintf('Class "%s" already has tests, so it should be removed from "%s::$classesWithoutTests".', $className, __CLASS__));
+            $this->markTestIncomplete(sprintf('Class "%s" has no tests yet, please help and add it.', $className));
         }
 
-        static::assertTrue(class_exists($testClassName), sprintf('Expected test class "%s" for "%s" not found.', $testClassName, $className));
-        static::assertTrue(is_subclass_of($testClassName, TestCase::class), sprintf('Expected test class "%s" to be a subclass of "\PhpCsFixer\Tests\TestCase".', $testClassName));
+        $this->assertTrue(class_exists($testClassName), sprintf('Expected test class "%s" for "%s" not found.', $testClassName, $className));
+        $this->assertTrue(is_subclass_of($testClassName, TestCase::class), sprintf('Expected test class "%s" to be a subclass of "\PhpCsFixer\Tests\TestCase".', $testClassName));
     }
 
     /**
@@ -128,7 +128,7 @@
 
         sort($extraMethods);
 
-        static::assertEmpty(
+        $this->assertEmpty(
             $extraMethods,
             sprintf(
                 "Class '%s' should not have public methods that are not part of implemented interfaces.\nViolations:\n%s",
@@ -150,13 +150,13 @@
         $rc = new \ReflectionClass($className);
 
         if (\PhpCsFixer\Fixer\Alias\NoMixedEchoPrintFixer::class === $className) {
-            static::markTestIncomplete(sprintf(
+            $this->markTestIncomplete(sprintf(
                 'Public properties of fixer `%s` will be removed on 3.0.',
                 \PhpCsFixer\Fixer\Alias\NoMixedEchoPrintFixer::class
             ));
         }
 
-        static::assertEmpty(
+        $this->assertEmpty(
             $rc->getProperties(\ReflectionProperty::IS_PUBLIC),
             sprintf('Class \'%s\' should not have public properties.', $className)
         );
@@ -196,7 +196,7 @@
 
         sort($extraProps);
 
-        static::assertEmpty(
+        $this->assertEmpty(
             $extraProps,
             sprintf(
                 "Class '%s' should not have protected properties.\nViolations:\n%s",
@@ -217,7 +217,7 @@
     {
         $rc = new \ReflectionClass($className);
 
-        static::assertTrue(
+        $this->assertTrue(
             $rc->isTrait() || $rc->isAbstract() || $rc->isFinal(),
             sprintf('Test class %s should be trait, abstract or final.', $className)
         );
@@ -233,7 +233,7 @@
         $rc = new \ReflectionClass($className);
         $doc = new DocBlock($rc->getDocComment());
 
-        static::assertNotEmpty(
+        $this->assertNotEmpty(
             $doc->getAnnotationsOfType('internal'),
             sprintf('Test class %s should have internal annotation.', $className)
         );
@@ -253,7 +253,7 @@
         }
 
         foreach ($dataProviderMethodNames as $dataProviderMethodName) {
-            static::assertRegExp('/^provide[A-Z]\S+Cases$/', $dataProviderMethodName, sprintf(
+            $this->assertRegExp('/^provide[A-Z]\S+Cases$/', $dataProviderMethodName, sprintf(
                 'Data provider in "%s" with name "%s" is not correctly named.',
                 $testClassName,
                 $dataProviderMethodName
@@ -284,13 +284,13 @@
         );
         $strings = array_unique($strings);
         $message = sprintf('Class %s must not use preg_*, it shall use Preg::* instead.', $className);
-        static::assertNotContains('preg_filter', $strings, $message);
-        static::assertNotContains('preg_grep', $strings, $message);
-        static::assertNotContains('preg_match', $strings, $message);
-        static::assertNotContains('preg_match_all', $strings, $message);
-        static::assertNotContains('preg_replace', $strings, $message);
-        static::assertNotContains('preg_replace_callback', $strings, $message);
-        static::assertNotContains('preg_split', $strings, $message);
+        $this->assertNotContains('preg_filter', $strings, $message);
+        $this->assertNotContains('preg_grep', $strings, $message);
+        $this->assertNotContains('preg_match', $strings, $message);
+        $this->assertNotContains('preg_match_all', $strings, $message);
+        $this->assertNotContains('preg_replace', $strings, $message);
+        $this->assertNotContains('preg_replace_callback', $strings, $message);
+        $this->assertNotContains('preg_split', $strings, $message);
     }
 
     public function provideSrcClassCases()
diff -ru tests/Test/AbstractConfigTestCaseTest.php tests/Test/AbstractConfigTestCaseTest.php
--- tests/Test/AbstractConfigTestCaseTest.php	2019-05-14 08:48:46.088221874 +0000
+++ tests/Test/AbstractConfigTestCaseTest.php	2019-05-14 08:48:46.883200946 +0000
@@ -32,9 +32,9 @@
 
         try {
             $this->doTestAllDefaultRulesAreSpecified($config);
-            static::fail('An empty config must raise an error reporting the missing fixers');
+            $this->fail('An empty config must raise an error reporting the missing fixers');
         } catch (ExpectationFailedException $expectationFailedException) {
-            static::assertContains('array_syntax', $expectationFailedException->getMessage());
+            $this->assertContains('array_syntax', $expectationFailedException->getMessage());
         }
     }
 
@@ -47,10 +47,10 @@
 
         try {
             $this->doTestAllDefaultRulesAreSpecified($config);
-            static::fail('An empty config must raise an error reporting the missing fixers');
+            $this->fail('An empty config must raise an error reporting the missing fixers');
         } catch (ExpectationFailedException $expectationFailedException) {
-            static::assertNotContains('encoding', $expectationFailedException->getMessage());
-            static::assertContains('array_syntax', $expectationFailedException->getMessage());
+            $this->assertNotContains('encoding', $expectationFailedException->getMessage());
+            $this->assertContains('array_syntax', $expectationFailedException->getMessage());
         }
     }
 
@@ -63,10 +63,10 @@
 
         try {
             $this->doTestAllDefaultRulesAreSpecified($config);
-            static::fail('A partial config must raise an error reporting the missing fixers');
+            $this->fail('A partial config must raise an error reporting the missing fixers');
         } catch (ExpectationFailedException $expectationFailedException) {
-            static::assertNotContains('encoding', $expectationFailedException->getMessage());
-            static::assertContains('array_syntax', $expectationFailedException->getMessage());
+            $this->assertNotContains('encoding', $expectationFailedException->getMessage());
+            $this->assertContains('array_syntax', $expectationFailedException->getMessage());
         }
     }
 
@@ -81,9 +81,9 @@
 
         try {
             $this->doTestAllDefaultRulesAreSpecified($config);
-            static::fail('A non existing fixer must raise an error');
+            $this->fail('A non existing fixer must raise an error');
         } catch (ExpectationFailedException $expectationFailedException) {
-            static::assertContains($nonExistingRule, $expectationFailedException->getMessage());
+            $this->assertContains($nonExistingRule, $expectationFailedException->getMessage());
         }
     }
 
@@ -98,10 +98,10 @@
 
         try {
             $this->doTestAllDefaultRulesAreSpecified($config);
-            static::fail('Fixers randomly orderer must raise an error');
+            $this->fail('Fixers randomly orderer must raise an error');
         } catch (ExpectationFailedException $expectationFailedException) {
             // Can't test $firstRule because the diff isn't in the Exception
-            static::assertContains('alphabetically', $expectationFailedException->getMessage());
+            $this->assertContains('alphabetically', $expectationFailedException->getMessage());
         }
     }
 

0
Common Typos

0
File Permissions