Skip to content

Commit

Permalink
Use snake_case for PHPUnit method names
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald committed Oct 9, 2024
1 parent 57383e8 commit f93d67a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions resources/presets/laravel.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_var_without_name' => true,
'php_unit_method_casing' => ['case' => 'snake_case'],
'psr_autoloading' => false,
'return_type_declaration' => ['space_before' => 'none'],
'self_accessor' => false,
Expand Down
18 changes: 18 additions & 0 deletions tests/Feature/Fixers/PhpUnitCasingTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

use function Illuminate\Filesystem\join_paths;

it('fixes the code', function () {
[$statusCode, $output] = run('default', [
'path' => base_path('tests/Fixtures/fixers/phpunit_method_casing.php'),
'--preset' => 'laravel',
]);

expect($statusCode)->toBe(1)
->and($output)
->toContain(''.join_paths('tests', 'Fixtures', 'fixers', 'phpunit_method_casing.php'))
->toContain(<<<'DIFF'
- public function testItConvertsToSnakeCase()
+ public function test_it_converts_to_snake_case()
DIFF);
});
13 changes: 13 additions & 0 deletions tests/Fixtures/fixers/phpunit_method_casing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Tests\Feature;

use Tests\TestCase;

class PhpUnitCasingTest extends TestCase
{
public function testItConvertsToSnakeCase()
{
$this->assertTrue(true);
}
}

0 comments on commit f93d67a

Please sign in to comment.