NamespaceAnalysisTest.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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\NamespaceAnalysis;
  15. /**
  16. * @author VeeWee <toonverwerft@gmail.com>
  17. *
  18. * @internal
  19. *
  20. * @covers \PhpCsFixer\Tokenizer\Analyzer\Analysis\NamespaceAnalysis
  21. */
  22. final class NamespaceAnalysisTest extends TestCase
  23. {
  24. public function testFullName(): void
  25. {
  26. $analysis = new NamespaceAnalysis('Full\NamespaceName', 'NamespaceName', 1, 2, 1, 10);
  27. self::assertSame('Full\NamespaceName', $analysis->getFullName());
  28. }
  29. public function testShortName(): void
  30. {
  31. $analysis = new NamespaceAnalysis('Full\NamespaceName', 'NamespaceName', 1, 2, 1, 10);
  32. self::assertSame('NamespaceName', $analysis->getShortName());
  33. self::assertFalse($analysis->isGlobalNamespace());
  34. }
  35. public function testStartIndex(): void
  36. {
  37. $analysis = new NamespaceAnalysis('Full\NamespaceName', 'NamespaceName', 1, 2, 1, 10);
  38. self::assertSame(1, $analysis->getStartIndex());
  39. }
  40. public function testEndIndex(): void
  41. {
  42. $analysis = new NamespaceAnalysis('Full\NamespaceName', 'NamespaceName', 1, 2, 1, 10);
  43. self::assertSame(2, $analysis->getEndIndex());
  44. }
  45. public function testScopeStartIndex(): void
  46. {
  47. $analysis = new NamespaceAnalysis('Full\NamespaceName', 'NamespaceName', 1, 2, 1, 10);
  48. self::assertSame(1, $analysis->getScopeStartIndex());
  49. }
  50. public function testScopeEndIndex(): void
  51. {
  52. $analysis = new NamespaceAnalysis('Full\NamespaceName', 'NamespaceName', 1, 2, 1, 10);
  53. self::assertSame(10, $analysis->getScopeEndIndex());
  54. }
  55. public function testGlobal(): void
  56. {
  57. $analysis = new NamespaceAnalysis('', '', 1, 2, 1, 10);
  58. self::assertTrue($analysis->isGlobalNamespace());
  59. }
  60. }