ParallelConfigTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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\Parallel;
  13. use PhpCsFixer\Runner\Parallel\ParallelConfig;
  14. use PhpCsFixer\Tests\TestCase;
  15. /**
  16. * @internal
  17. *
  18. * @covers \PhpCsFixer\Runner\Parallel\ParallelConfig
  19. */
  20. final class ParallelConfigTest extends TestCase
  21. {
  22. /**
  23. * @dataProvider provideExceptionIsThrownOnNegativeValuesCases
  24. */
  25. public function testExceptionIsThrownOnNegativeValues(
  26. int $maxProcesses,
  27. int $filesPerProcess,
  28. int $processTimeout
  29. ): void {
  30. $this->expectException(\InvalidArgumentException::class);
  31. // @phpstan-ignore-next-line False-positive, we pass negative values to the constructor on purpose.
  32. new ParallelConfig($maxProcesses, $filesPerProcess, $processTimeout);
  33. }
  34. /**
  35. * @return iterable<array{0: int, 1: int, 2: int}>
  36. */
  37. public static function provideExceptionIsThrownOnNegativeValuesCases(): iterable
  38. {
  39. yield [-1, 1, 1];
  40. yield [1, -1, 1];
  41. yield [1, 1, -1];
  42. }
  43. public function testGettersAreReturningProperValues(): void
  44. {
  45. $config = new ParallelConfig(2, 10, 120);
  46. self::assertSame(2, $config->getMaxProcesses());
  47. self::assertSame(10, $config->getFilesPerProcess());
  48. self::assertSame(120, $config->getProcessTimeout());
  49. }
  50. }