Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Implement Test Coverage for Str::convertCase Method #48730

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions tests/Support/SupportStrTest.php
Expand Up @@ -302,6 +302,29 @@ public function testStrContainsAll($haystack, $needles, $expected, $ignoreCase =
$this->assertEquals($expected, Str::containsAll($haystack, $needles, $ignoreCase));
}

public function testConvertCase()
{
// Upper Case Conversion
$this->assertSame('HELLO', Str::convertCase('hello', MB_CASE_UPPER));
$this->assertSame('WORLD', Str::convertCase('WORLD', MB_CASE_UPPER));

// Lower Case Conversion
$this->assertSame('hello', Str::convertCase('HELLO', MB_CASE_LOWER));
$this->assertSame('world', Str::convertCase('WORLD', MB_CASE_LOWER));

// Case Folding
$this->assertSame('hello', Str::convertCase('HeLLo', MB_CASE_FOLD));
$this->assertSame('world', Str::convertCase('WoRLD', MB_CASE_FOLD));

// Multi-byte String
$this->assertSame('ÜÖÄ', Str::convertCase('üöä', MB_CASE_UPPER, 'UTF-8'));
$this->assertSame('üöä', Str::convertCase('ÜÖÄ', MB_CASE_LOWER, 'UTF-8'));

// Unsupported Mode
$this->expectException(\ValueError::class);
Str::convertCase('Hello', -1);
}

public function testParseCallback()
{
$this->assertEquals(['Class', 'method'], Str::parseCallback('Class@method', 'foo'));
Expand Down