MatchAnalysisTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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\DefaultAnalysis;
  15. use PhpCsFixer\Tokenizer\Analyzer\Analysis\MatchAnalysis;
  16. /**
  17. * @covers \PhpCsFixer\Tokenizer\Analyzer\Analysis\MatchAnalysis
  18. *
  19. * @internal
  20. */
  21. final class MatchAnalysisTest extends TestCase
  22. {
  23. public function testMatchAnalysis(): void
  24. {
  25. $analysis = new MatchAnalysis(10, 11, 15, null);
  26. self::assertSame(10, $analysis->getIndex());
  27. self::assertSame(11, $analysis->getOpenIndex());
  28. self::assertSame(15, $analysis->getCloseIndex());
  29. self::assertNull($analysis->getDefaultAnalysis());
  30. }
  31. public function testMatchAnalysis2(): void
  32. {
  33. $defaultAnalysis = new DefaultAnalysis(45, 48);
  34. $analysis = new MatchAnalysis(22, 26, 290, $defaultAnalysis);
  35. self::assertSame(22, $analysis->getIndex());
  36. self::assertSame(26, $analysis->getOpenIndex());
  37. self::assertSame(290, $analysis->getCloseIndex());
  38. self::assertSame($defaultAnalysis, $analysis->getDefaultAnalysis());
  39. }
  40. }