PhpUnitFqcnAnnotationFixerTest.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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\Fixer\PhpUnit;
  13. use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  14. /**
  15. * @author Roland Franssen <franssen.roland@gmail.com>
  16. *
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\Fixer\PhpUnit\PhpUnitFqcnAnnotationFixer
  20. *
  21. * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\PhpUnit\PhpUnitFqcnAnnotationFixer>
  22. */
  23. final class PhpUnitFqcnAnnotationFixerTest extends AbstractFixerTestCase
  24. {
  25. /**
  26. * @dataProvider provideFixCases
  27. */
  28. public function testFix(string $expected, ?string $input = null): void
  29. {
  30. $this->doTest($expected, $input);
  31. }
  32. /**
  33. * @return iterable<array{0: string, 1?: string}>
  34. */
  35. public static function provideFixCases(): iterable
  36. {
  37. yield [
  38. <<<'EOF'
  39. <?php
  40. /**
  41. * @covers \Foo
  42. * @covers ::fooMethod
  43. * @coversDefaultClass \Bar
  44. */
  45. class FooTest extends TestCase {
  46. /**
  47. * @ExpectedException Value
  48. * @expectedException \X
  49. * @expectedException
  50. * @expectedException \Exception
  51. * @expectedException \Some\Exception\ClassName
  52. * @expectedExceptionCode 123
  53. * @expectedExceptionMessage Foo bar
  54. *
  55. * @uses \Baz
  56. * @uses \selfieGenerator
  57. * @uses self::someFunction
  58. * @uses static::someOtherFunction
  59. */
  60. }
  61. EOF,
  62. <<<'EOF'
  63. <?php
  64. /**
  65. * @covers Foo
  66. * @covers ::fooMethod
  67. * @coversDefaultClass Bar
  68. */
  69. class FooTest extends TestCase {
  70. /**
  71. * @ExpectedException Value
  72. * @expectedException X
  73. * @expectedException
  74. * @expectedException \Exception
  75. * @expectedException Some\Exception\ClassName
  76. * @expectedExceptionCode 123
  77. * @expectedExceptionMessage Foo bar
  78. *
  79. * @uses Baz
  80. * @uses selfieGenerator
  81. * @uses self::someFunction
  82. * @uses static::someOtherFunction
  83. */
  84. }
  85. EOF,
  86. ];
  87. yield [
  88. '<?php
  89. class Foo {
  90. /**
  91. * @expectedException Some\Exception\ClassName
  92. * @covers Foo
  93. * @uses Baz
  94. * @uses self::someFunction
  95. */
  96. }
  97. ',
  98. ];
  99. }
  100. }