SwitchAnalysisTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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\Tokenizer\Analyzer\Analysis;
  13. use PhpCsFixer\Tests\TestCase;
  14. use PhpCsFixer\Tokenizer\Analyzer\Analysis\CaseAnalysis;
  15. use PhpCsFixer\Tokenizer\Analyzer\Analysis\DefaultAnalysis;
  16. use PhpCsFixer\Tokenizer\Analyzer\Analysis\SwitchAnalysis;
  17. /**
  18. * @author Kuba Werłos <werlos@gmail.com>
  19. *
  20. * @covers \PhpCsFixer\Tokenizer\Analyzer\Analysis\SwitchAnalysis
  21. *
  22. * @internal
  23. */
  24. final class SwitchAnalysisTest extends TestCase
  25. {
  26. public function testSwitchAnalysis(): void
  27. {
  28. $analysis = new SwitchAnalysis(10, 11, 15, [], null);
  29. self::assertSame(10, $analysis->getIndex());
  30. self::assertSame(11, $analysis->getOpenIndex());
  31. self::assertSame(15, $analysis->getCloseIndex());
  32. self::assertSame([], $analysis->getCases());
  33. self::assertNull($analysis->getDefaultAnalysis());
  34. }
  35. public function testSwitchAnalysis2(): void
  36. {
  37. $caseAnalysis = new CaseAnalysis(20, 21);
  38. $defaultAnalysis = new DefaultAnalysis(45, 48);
  39. $analysis = new SwitchAnalysis(15, 17, 190, [$caseAnalysis], $defaultAnalysis);
  40. self::assertSame(15, $analysis->getIndex());
  41. self::assertSame(17, $analysis->getOpenIndex());
  42. self::assertSame(190, $analysis->getCloseIndex());
  43. self::assertSame([$caseAnalysis], $analysis->getCases());
  44. self::assertSame($defaultAnalysis, $analysis->getDefaultAnalysis());
  45. }
  46. }