ClassConstantTransformerTest.php 1.6 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\Transformer;
  13. use PhpCsFixer\Tests\Test\AbstractTransformerTestCase;
  14. use PhpCsFixer\Tokenizer\CT;
  15. /**
  16. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  17. *
  18. * @internal
  19. *
  20. * @covers \PhpCsFixer\Tokenizer\Transformer\ClassConstantTransformer
  21. *
  22. * @phpstan-import-type _TransformerTestExpectedTokens from AbstractTransformerTestCase
  23. */
  24. final class ClassConstantTransformerTest 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. CT::T_CLASS_CONSTANT,
  38. ]
  39. );
  40. }
  41. public static function provideProcessCases(): iterable
  42. {
  43. yield [
  44. '<?php echo X::class;',
  45. [
  46. 5 => CT::T_CLASS_CONSTANT,
  47. ],
  48. ];
  49. yield [
  50. '<?php echo X::cLaSS;',
  51. [
  52. 5 => CT::T_CLASS_CONSTANT,
  53. ],
  54. ];
  55. yield [
  56. '<?php echo X::bar;',
  57. ];
  58. yield [
  59. '<?php class X{}',
  60. ];
  61. }
  62. }