NamespaceOperatorTransformerTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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\Transformer;
  13. use PhpCsFixer\Tests\Test\AbstractTransformerTestCase;
  14. use PhpCsFixer\Tokenizer\CT;
  15. /**
  16. * @author Gregor Harlan <gharlan@web.de>
  17. *
  18. * @internal
  19. *
  20. * @covers \PhpCsFixer\Tokenizer\Transformer\NamespaceOperatorTransformer
  21. *
  22. * @phpstan-import-type _TransformerTestExpectedTokens from AbstractTransformerTestCase
  23. */
  24. final class NamespaceOperatorTransformerTest extends AbstractTransformerTestCase
  25. {
  26. /**
  27. * @param _TransformerTestExpectedTokens $expectedTokens
  28. *
  29. * @dataProvider provideProcessCases
  30. */
  31. public function testProcess(string $source, array $expectedTokens): void
  32. {
  33. $this->doTest(
  34. $source,
  35. $expectedTokens,
  36. [
  37. T_NAMESPACE,
  38. CT::T_NAMESPACE_OPERATOR,
  39. ]
  40. );
  41. }
  42. public static function provideProcessCases(): iterable
  43. {
  44. yield [
  45. '<?php
  46. namespace Foo;
  47. namespace\Bar\baz();
  48. ',
  49. [
  50. 1 => T_NAMESPACE,
  51. 6 => CT::T_NAMESPACE_OPERATOR,
  52. ],
  53. ];
  54. }
  55. }