php_unit_method_casing.rst 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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'``, ``'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
  42. Using the `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ rule set will enable the ``php_unit_method_casing`` rule with the default config.
  43. @Symfony
  44. Using the `@Symfony <./../../ruleSets/Symfony.rst>`_ rule set will enable the ``php_unit_method_casing`` rule with the default config.