Skip to content

Commit

Permalink
add convertCase tests
Browse files Browse the repository at this point in the history
  • Loading branch information
salehhashemi1992 committed Oct 14, 2023
1 parent 967dab6 commit 91000bf
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/Support/SupportStrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,28 @@ 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->assertSame('Hello', Str::convertCase('Hello', -1));
}

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

0 comments on commit 91000bf

Please sign in to comment.