diff --git a/tests/Unit/Base/Support/StrTest.php b/tests/Unit/Base/Support/StrTest.php index 5b313f6bf..6f461002d 100644 --- a/tests/Unit/Base/Support/StrTest.php +++ b/tests/Unit/Base/Support/StrTest.php @@ -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'], +]);