diff --git a/src/Console/Command/ListFilesCommand.php b/src/Console/Command/ListFilesCommand.php index cda21bddca3..78c258dfa72 100644 --- a/src/Console/Command/ListFilesCommand.php +++ b/src/Console/Command/ListFilesCommand.php @@ -20,6 +20,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Finder\SplFileInfo; /** * @author Markus Staab @@ -79,10 +80,10 @@ protected function execute(InputInterface $input, OutputInterface $output) $finder = $resolver->getFinder(); - /** @var \SplFileInfo $file */ + /** @var SplFileInfo $file */ foreach ($finder as $file) { if ($file->isFile()) { - $output->writeln(escapeshellarg($file->getPath().DIRECTORY_SEPARATOR.$file->getFilename())); + $output->writeln(escapeshellarg($file->getRelativePathname())); } } diff --git a/tests/Console/Command/ListFilesCommandTest.php b/tests/Console/Command/ListFilesCommandTest.php index 335050b3ca1..88e419079e9 100644 --- a/tests/Console/Command/ListFilesCommandTest.php +++ b/tests/Console/Command/ListFilesCommandTest.php @@ -25,17 +25,18 @@ */ final class ListFilesCommandTest extends TestCase { - public function testEmptyRulesValue() + public function testListWithConfig() { - $commandTester = $this->doTestExecute(); - // TODO adjust expectation - $this->assertSame('', $commandTester->getDisplay()); + $commandTester = $this->doTestExecute([ + '--config' => __DIR__.'/test-project/.php_cs' + ]); + $this->assertSame('"needs-fixing.php"', $commandTester->getDisplay()); } /** * @return CommandTester */ - private function doTestExecute(/*array $arguments*/) + private function doTestExecute(array $arguments) { $application = new Application(); $application->add(new ListFilesCommand(new ToolInfo())); @@ -43,10 +44,7 @@ private function doTestExecute(/*array $arguments*/) $command = $application->find('list-files'); $commandTester = new CommandTester($command); - $commandTester->execute([ - '--config' => __DIR__.'/test-project/.php_cs' - ] - ); + $commandTester->execute($arguments); return $commandTester; }