Browse Source

Merge branch '2.2'

Dariusz Ruminski 7 years ago
parent
commit
5b874a0061

+ 7 - 1
src/Console/Command/DescribeCommand.php

@@ -225,7 +225,13 @@ final class DescribeCommand extends Command
                 $old = $codeSample->getCode();
                 $tokens = Tokens::fromCode($old);
                 if ($fixer instanceof ConfigurableFixerInterface) {
-                    $fixer->configure($codeSample->getConfiguration());
+                    $configuration = $codeSample->getConfiguration();
+
+                    if (null === $configuration) {
+                        $configuration = [];
+                    }
+
+                    $fixer->configure($configuration);
                 }
 
                 $file = $codeSample instanceof FileSpecificCodeSampleInterface

+ 2 - 1
src/Fixer/Basic/Psr0Fixer.php

@@ -41,7 +41,8 @@ final class Psr0Fixer extends AbstractPsrAutoloadingFixer implements Configurati
 namespace PhpCsFixer\FIXER\Basic;
 class InvalidName {}
 ',
-                    new \SplFileInfo(__FILE__)
+                    new \SplFileInfo(__FILE__),
+                    ['dir' => realpath(__DIR__.'/../..')]
                 ),
                 new FileSpecificCodeSample(
                     '<?php

+ 64 - 0
tests/AutoReview/DescribeCommandTest.php

@@ -0,0 +1,64 @@
+<?php
+
+/*
+ * This file is part of PHP CS Fixer.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *     Dariusz Rumiński <dariusz.ruminski@gmail.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace PhpCsFixer\Tests\AutoReview;
+
+use PhpCsFixer\Console\Application;
+use PhpCsFixer\Console\Command\DescribeCommand;
+use PhpCsFixer\FixerFactory;
+use PHPUnit\Framework\TestCase;
+use Symfony\Component\Console\Tester\CommandTester;
+
+/**
+ * @internal
+ *
+ * @coversNothing
+ * @group auto-review
+ */
+final class DescribeCommandTest extends TestCase
+{
+    /**
+     * @dataProvider provideDescribeCommandCases
+     *
+     * @param FixerFactory $factory
+     * @param string       $fixerName
+     */
+    public function testDescribeCommand(FixerFactory $factory, $fixerName)
+    {
+        $command = new DescribeCommand($factory);
+
+        $application = new Application();
+        $application->add($command);
+
+        $commandTester = new CommandTester($command);
+        $commandTester->execute([
+            'command' => $command->getName(),
+            'name' => $fixerName,
+        ]);
+
+        $this->assertSame(0, $commandTester->getStatusCode());
+    }
+
+    public function provideDescribeCommandCases()
+    {
+        $factory = new FixerFactory();
+        $factory->registerBuiltInFixers();
+
+        $cases = [];
+
+        foreach ($factory->getFixers() as $fixer) {
+            $cases[] = [$factory, $fixer->getName()];
+        }
+
+        return $cases;
+    }
+}

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

@@ -169,7 +169,7 @@ EOT;
         ));
 
         $things = false;
-        $fixer->configure(null)->will(function () use (&$things) {
+        $fixer->configure([])->will(function () use (&$things) {
             $things = false;
         });
         $fixer->configure(['things' => true])->will(function () use (&$things) {