Skip to content

Commit

Permalink
test: add test for changing string case
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Nov 15, 2024
1 parent 2e6389f commit df18f4e
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/Unit/Base/Support/StrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,32 @@
['short enough', 40, '_-.', 'short enough'],
['broccoli', 5, '~', 'broc~'],
]);

it('changes string case', function (string $string, ?int $flags, string $result) {
expect(Str::changeCase($string, $flags))->toBe($result);
})->with([
['my string', null, 'myString'],
['my string', Str::CASE_KEBAB, 'my-string'],
['my string', Str::CASE_SNAKE, 'my_string'],
['my string', Str::CASE_STUDLY, 'MyString'],

['myString', null, 'myString'],
['myString', Str::CASE_SNAKE, 'my_string'],
['myString', Str::CASE_KEBAB, 'my-string'],
['myString', Str::CASE_STUDLY, 'MyString'],

['my-string', null, 'myString'],
// Kebab can't be converted to snake
['my-string', Str::CASE_KEBAB, 'my-string'],
['my-string', Str::CASE_STUDLY, 'MyString'],

['my_string', null, 'myString'],
['my_string', Str::CASE_SNAKE, 'my_string'],
// Snake can't be converted to kebab
['my_string', Str::CASE_STUDLY, 'MyString'],

['MyString', null, 'myString'],
['MyString', Str::CASE_SNAKE, 'my_string'],
['MyString', Str::CASE_KEBAB, 'my-string'],
['MyString', Str::CASE_STUDLY, 'MyString'],
]);

0 comments on commit df18f4e

Please sign in to comment.