Skip to content

Commit

Permalink
Merge pull request #43 from julien-boudry/patch-1
Browse files Browse the repository at this point in the history
Improve function name conversion to description
  • Loading branch information
mandisma authored May 5, 2024
2 parents 8c07c1a + c99d762 commit d481b6e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Rules/ConvertTestMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function filter(ClassMethod $classMethod): bool
private function methodNameToDescription(string $name): string
{
$newName = (string) preg_replace(
['/^(test|it)/', '/_/', '/(?=[A-Z])/'],
['/^(test|it)/', '/(?<![A-Z]|_)(?=[A-Z])/', '/_(?<![A-Z])/'],
['', ' ', ' '],
$name
);
Expand Down
6 changes: 6 additions & 0 deletions tests/Converters/CodeConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ public function test_true_is_true() {}
public function testFalseIsFalse() {}
public function testPHP8() {}
public function testPHP_IS_Great() {}
/** @test */
public function it_works() {}
}
Expand All @@ -119,6 +123,8 @@ public function it_works() {}
expect($convertedCode)
->toContain("test('true is true', function () {")
->toContain("test('false is false', function () {")
->toContain("test('php8', function () {")
->toContain("test('php is great', function () {")
->toContain("it('works', function () {")
->not->toContain('/** @test */');
});
Expand Down

0 comments on commit d481b6e

Please sign in to comment.