RunnerConfigTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of PHP CS Fixer.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. namespace PhpCsFixer\Tests\Runner;
  13. use PhpCsFixer\Runner\Parallel\ParallelConfig;
  14. use PhpCsFixer\Runner\RunnerConfig;
  15. use PhpCsFixer\Tests\TestCase;
  16. /**
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\Runner\RunnerConfig
  20. */
  21. final class RunnerConfigTest extends TestCase
  22. {
  23. /**
  24. * @dataProvider provideGettersReturnCorrectDataCases
  25. */
  26. public function testGettersReturnCorrectData(
  27. bool $isDryRun,
  28. bool $stopOnViolation,
  29. ParallelConfig $parallelConfig,
  30. ?string $configFile = null
  31. ): void {
  32. $config = new RunnerConfig($isDryRun, $stopOnViolation, $parallelConfig, $configFile);
  33. self::assertSame($isDryRun, $config->isDryRun());
  34. self::assertSame($stopOnViolation, $config->shouldStopOnViolation());
  35. self::assertSame($parallelConfig, $config->getParallelConfig());
  36. self::assertSame($configFile, $config->getConfigFile());
  37. }
  38. /**
  39. * @return iterable<array{0: bool, 1: bool, 2: ParallelConfig, 3?: null|string}>
  40. */
  41. public static function provideGettersReturnCorrectDataCases(): iterable
  42. {
  43. yield 'null config file' => [
  44. false,
  45. false,
  46. new ParallelConfig(1, 2, 3),
  47. null,
  48. ];
  49. yield 'config file provided' => [
  50. false,
  51. false,
  52. new ParallelConfig(1, 2, 3),
  53. __DIR__.'/../../../.php-cs-fixer.dist.php',
  54. ];
  55. }
  56. }