WorkerExceptionTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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\WorkerException;
  14. use PhpCsFixer\Tests\TestCase;
  15. /**
  16. * @covers \PhpCsFixer\Runner\Parallel\WorkerException
  17. *
  18. * @internal
  19. */
  20. final class WorkerExceptionTest extends TestCase
  21. {
  22. public function testFromRaw(): void
  23. {
  24. $exception = WorkerException::fromRaw([
  25. 'class' => \RuntimeException::class,
  26. 'message' => 'foo',
  27. 'file' => 'foo.php',
  28. 'line' => 1,
  29. 'code' => 1,
  30. 'trace' => '#0 bar',
  31. ]);
  32. self::assertSame('[RuntimeException] foo', $exception->getMessage());
  33. self::assertSame('foo.php', $exception->getFile());
  34. self::assertSame(1, $exception->getLine());
  35. self::assertSame(1, $exception->getCode());
  36. self::assertSame('## foo.php(1)'.PHP_EOL.'#0 bar', $exception->getOriginalTraceAsString());
  37. }
  38. }