php_unit_method_casing.rst 1.1 KB

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