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 ae700fc
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/Support/SupportStrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,29 @@ public function testStrContainsAll($haystack, $needles, $expected, $ignoreCase =
$this->assertEquals($expected, Str::containsAll($haystack, $needles, $ignoreCase));
}

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

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

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

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

// Test Unsupported Mode (Let's assume '-1' is unsupported)
$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 ae700fc

Please sign in to comment.