php_unit_test_annotation.rst 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. =================================
  2. Rule ``php_unit_test_annotation``
  3. =================================
  4. Adds or removes @test annotations from tests, following configuration.
  5. Warning
  6. -------
  7. Using this rule is risky
  8. ~~~~~~~~~~~~~~~~~~~~~~~~
  9. This fixer may change the name of your tests, and could cause incompatibility
  10. with abstract classes or interfaces.
  11. Configuration
  12. -------------
  13. ``style``
  14. ~~~~~~~~~
  15. Whether to use the @test annotation or not.
  16. Allowed values: ``'annotation'`` and ``'prefix'``
  17. Default value: ``'prefix'``
  18. Examples
  19. --------
  20. Example #1
  21. ~~~~~~~~~~
  22. *Default* configuration.
  23. .. code-block:: diff
  24. --- Original
  25. +++ New
  26. <?php
  27. class Test extends \PhpUnit\FrameWork\TestCase
  28. {
  29. /**
  30. - * @test
  31. + *
  32. */
  33. - public function itDoesSomething() {} }
  34. + public function testItDoesSomething() {} }
  35. Example #2
  36. ~~~~~~~~~~
  37. With configuration: ``['style' => 'annotation']``.
  38. .. code-block:: diff
  39. --- Original
  40. +++ New
  41. <?php
  42. class Test extends \PhpUnit\FrameWork\TestCase
  43. {
  44. -public function testItDoesSomething() {}}
  45. +/**
  46. + * @test
  47. + */
  48. +public function itDoesSomething() {}}
  49. Rule sets
  50. ---------
  51. The rule is part of the following rule sets:
  52. - `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
  53. - `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_
  54. References
  55. ----------
  56. - Fixer class: `PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitTestAnnotationFixer <./../../../src/Fixer/PhpUnit/PhpUnitTestAnnotationFixer.php>`_
  57. - Test class: `PhpCsFixer\\Tests\\Fixer\\PhpUnit\\PhpUnitTestAnnotationFixerTest <./../../../tests/Fixer/PhpUnit/PhpUnitTestAnnotationFixerTest.php>`_
  58. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.