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

[11.x] Add some tests and improvement test coverage for Str::camel #51308

Merged
merged 1 commit into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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