From 8e7c0c98e59f55ffcb8859abba05005d392afd26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Machulda?= Date: Mon, 13 May 2024 17:01:21 +0200 Subject: [PATCH] Feat: Add PhpUnitMethodCasingFixer --- ecs.php | 3 +++ tests/Integration/Fixtures/PhpUnit.correct.php.inc | 5 +++++ tests/Integration/Fixtures/PhpUnit.wrong.php.inc | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/ecs.php b/ecs.php index 89701b0..9931a42 100644 --- a/ecs.php +++ b/ecs.php @@ -133,6 +133,7 @@ use PhpCsFixer\Fixer\PhpUnit\PhpUnitDedicateAssertInternalTypeFixer; use PhpCsFixer\Fixer\PhpUnit\PhpUnitExpectationFixer; use PhpCsFixer\Fixer\PhpUnit\PhpUnitFqcnAnnotationFixer; +use PhpCsFixer\Fixer\PhpUnit\PhpUnitMethodCasingFixer; use PhpCsFixer\Fixer\PhpUnit\PhpUnitMockFixer; use PhpCsFixer\Fixer\PhpUnit\PhpUnitMockShortWillReturnFixer; use PhpCsFixer\Fixer\PhpUnit\PhpUnitNoExpectationAnnotationFixer; @@ -535,6 +536,8 @@ ->withConfiguredRule(PhpdocOrderFixer::class, ['order' => ['param', 'return', 'throws']]) // Order phpdoc tags by value. ->withConfiguredRule(PhpdocOrderByValueFixer::class, ['annotations' => ['covers', 'group', 'throws']]) + // Enforce camel case for PHPUnit test methods. + ->withConfiguredRule(PhpUnitMethodCasingFixer::class, ['case' => 'camel_case']) // Calls to `PHPUnit\Framework\TestCase` static methods must all be of the same type (`$this->...`) ->withConfiguredRule(PhpUnitTestCaseStaticMethodCallsFixer::class, ['call_type' => 'this']) // An empty line feed must precede any configured statement diff --git a/tests/Integration/Fixtures/PhpUnit.correct.php.inc b/tests/Integration/Fixtures/PhpUnit.correct.php.inc index 46b3f92..642c49f 100644 --- a/tests/Integration/Fixtures/PhpUnit.correct.php.inc +++ b/tests/Integration/Fixtures/PhpUnit.correct.php.inc @@ -31,4 +31,9 @@ class PhpUnit extends TestCase // PhpUnitTestCaseStaticMethodCallsFixer $this->assertSame(1, 2); } + + public function testMethodName(): void // PhpUnitMethodCasingFixer + { + $this->assertTrue(true); + } } diff --git a/tests/Integration/Fixtures/PhpUnit.wrong.php.inc b/tests/Integration/Fixtures/PhpUnit.wrong.php.inc index a9aefd7..16f0f6a 100644 --- a/tests/Integration/Fixtures/PhpUnit.wrong.php.inc +++ b/tests/Integration/Fixtures/PhpUnit.wrong.php.inc @@ -31,4 +31,9 @@ class PhpUnit extends TestCase // PhpUnitTestCaseStaticMethodCallsFixer static::assertSame(1, 2); } + + public function test_method_name(): void // PhpUnitMethodCasingFixer + { + $this->assertTrue(true); + } }