InvalidConfigurationExceptionTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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\ConfigurationException;
  13. use PhpCsFixer\ConfigurationException\InvalidConfigurationException;
  14. use PhpCsFixer\Console\Command\FixCommandExitStatusCalculator;
  15. use PhpCsFixer\Tests\TestCase;
  16. /**
  17. * @author Andreas Möller <am@localheinz.com>
  18. *
  19. * @internal
  20. *
  21. * @covers \PhpCsFixer\ConfigurationException\InvalidConfigurationException
  22. */
  23. final class InvalidConfigurationExceptionTest extends TestCase
  24. {
  25. public function testDefaults(): void
  26. {
  27. $message = 'I cannot do that, Dave.';
  28. $exception = new InvalidConfigurationException($message);
  29. self::assertSame($message, $exception->getMessage());
  30. self::assertSame(FixCommandExitStatusCalculator::EXIT_STATUS_FLAG_HAS_INVALID_CONFIG, $exception->getCode());
  31. self::assertNull($exception->getPrevious());
  32. }
  33. public function testConstructorSetsValues(): void
  34. {
  35. $message = 'I cannot do that, Dave.';
  36. $code = 9_000;
  37. $previous = new \RuntimeException();
  38. $exception = new InvalidConfigurationException(
  39. $message,
  40. $code,
  41. $previous
  42. );
  43. self::assertSame($message, $exception->getMessage());
  44. self::assertSame($code, $exception->getCode());
  45. self::assertSame($previous, $exception->getPrevious());
  46. }
  47. }