php_unit_method_casing.rst 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ===============================
  2. Rule ``php_unit_method_casing``
  3. ===============================
  4. Enforce camel (or snake) case for PHPUnit test methods, following configuration.
  5. Configuration
  6. -------------
  7. ``case``
  8. ~~~~~~~~
  9. Apply camel or snake case to test methods.
  10. Allowed values: ``'camel_case'`` and ``'snake_case'``
  11. Default value: ``'camel_case'``
  12. Examples
  13. --------
  14. Example #1
  15. ~~~~~~~~~~
  16. *Default* configuration.
  17. .. code-block:: diff
  18. --- Original
  19. +++ New
  20. <?php
  21. class MyTest extends \PhpUnit\FrameWork\TestCase
  22. {
  23. - public function test_my_code() {}
  24. + public function testMyCode() {}
  25. }
  26. Example #2
  27. ~~~~~~~~~~
  28. With configuration: ``['case' => 'snake_case']``.
  29. .. code-block:: diff
  30. --- Original
  31. +++ New
  32. <?php
  33. class MyTest extends \PhpUnit\FrameWork\TestCase
  34. {
  35. - public function testMyCode() {}
  36. + public function test_my_code() {}
  37. }
  38. Rule sets
  39. ---------
  40. The rule is part of the following rule sets:
  41. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  42. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  43. References
  44. ----------
  45. - Fixer class: `PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitMethodCasingFixer <./../../../src/Fixer/PhpUnit/PhpUnitMethodCasingFixer.php>`_
  46. - Test class: `PhpCsFixer\\Tests\\Fixer\\PhpUnit\\PhpUnitMethodCasingFixerTest <./../../../tests/Fixer/PhpUnit/PhpUnitMethodCasingFixerTest.php>`_
  47. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.