Skip to content

Conversation

JohnnyWalkerDigital
Copy link
Contributor

@JohnnyWalkerDigital JohnnyWalkerDigital commented May 19, 2023

Update naming convention to match official Laravel documentation. (These "best practices" are currently out-of-step with modern Laravel standards.)

Reasoning:

Update naming convention to match official Laravel documentation. These best practices are currently out-of-step with modern Laravel standards.

 * Laravel [officially changed to snake_case](laravel/laravel#5574) for test case methods in version 8.0. 
 * [Official Laravel documentation](https://laravel.com/docs/10.x/testing) uses snake_case. 
 * [Laracast videos](https://laracasts.com/series/phpunit-testing-in-laravel/episodes/2) use snake_case. 
 * The [previous discussion's](alexeymezenin#28) conclusions on this matter are no longer correct.
@JohnnyWalkerDigital
Copy link
Contributor Author

@alexeymezenin You seem to be engaging with this repo again... How about bringing it up to speed with current Laravel standards?

@Tpojka
Copy link

Tpojka commented Oct 24, 2023

Snake case should be used in tests regardless Laravel.

It differs from regular methods and force developer to pay extreme attention to those.
It differs from regular (app) methods that should be written following PSR standards.
Personally, I comply/obey 100% PSR standards which means I use camelCase for methods, but for testing methods I use snake_case.

Updated to show the official support for Pest
@JohnnyWalkerDigital JohnnyWalkerDigital changed the title Change test case methods to snake_case Change test case methods to snake_case and mention Pest support Sep 11, 2024
@JohnnyWalkerDigital
Copy link
Contributor Author

JohnnyWalkerDigital commented Sep 11, 2024

@alexeymezenin Are you ever going to address this issue? I want to use this repo as a reference, but I can't while it's outdated.

@alexeymezenin
Copy link
Owner

@JohnnyWalkerDigital Hi. I believe this was discussed before, I also remember mentioning huge discussion on this topic which took place many years ago. Long story short, there is no reason to use snake case just for PHPUnit tests just because some people got used to it.

Laravel is following PSR coding standards and snake case clearly violates those https://laravel.com/docs/11.x/contributions#coding-style

@JohnnyWalkerDigital
Copy link
Contributor Author

JohnnyWalkerDigital commented Jun 30, 2025

@alexeymezenin I have linked to the previous discussion and mentioned the problems with that discussion already. I have included official Laravel documentation demonstrating that the Laravel project uses snake_case in Test methods names. I have even linked to the actual PR request when that decision was codified (4 years ago).

@driesvints "We decided a while back to go for snake case as our convention for methods names in tests."

Even typing php artisan make:test AnotherExampleTest creates a class with the example method: public function test_example(): void

It's sad that these so-called "best practices" are now years behind actual real-world Laravel conventions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants