php_unit_test_annotation.rst 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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>`_