Skip to content

Commit

Permalink
add some tests and improvement test coverage for Str::camel
Browse files Browse the repository at this point in the history
  • Loading branch information
saMahmoudzadeh committed May 5, 2024
1 parent a8829f7 commit 8c8c4eb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/Support/SupportStrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ public function testMask()
$this->assertSame('***************', Str::mask('[email protected]', '*', 0));
}

public function testMatch()
public function testMatch(): void
{
$this->assertSame('bar', Str::match('/bar/', 'foo bar'));
$this->assertSame('bar', Str::match('/foo (.*)/', 'foo bar'));
Expand All @@ -946,9 +946,12 @@ public function testMatch()

$this->assertEquals(['un', 'ly'], Str::matchAll('/f(\w*)/', 'bar fun bar fly')->all());
$this->assertEmpty(Str::matchAll('/nothing/', 'bar fun bar fly'));

$this->assertEmpty(Str::match('/pattern/', ''));
$this->assertEmpty(Str::matchAll('/pattern/', ''));
}

public function testCamel()
public function testCamel(): void
{
$this->assertSame('laravelPHPFramework', Str::camel('Laravel_p_h_p_framework'));
$this->assertSame('laravelPhpFramework', Str::camel('Laravel_php_framework'));
Expand All @@ -960,6 +963,13 @@ public function testCamel()
$this->assertSame('fooBar', Str::camel('foo_bar')); // test cache
$this->assertSame('fooBarBaz', Str::camel('Foo-barBaz'));
$this->assertSame('fooBarBaz', Str::camel('foo-bar_baz'));

$this->assertSame('', Str::camel(''));
$this->assertSame('lARAVELPHPFRAMEWORK', Str::camel('LARAVEL_PHP_FRAMEWORK'));
$this->assertSame('laravelPhpFramework', Str::camel(' laravel php framework '));

$this->assertSame('foo1Bar', Str::camel('foo1_bar'));
$this->assertSame('1FooBar', Str::camel('1 foo bar'));
}

public function testCharAt()
Expand Down

0 comments on commit 8c8c4eb

Please sign in to comment.