From 8c8c4eb8fa7cee086bacd153466823b613753350 Mon Sep 17 00:00:00 2001 From: "S.a Mahmoudzadeh" Date: Mon, 6 May 2024 00:32:32 +0330 Subject: [PATCH] add some tests and improvement test coverage for Str::camel --- tests/Support/SupportStrTest.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/Support/SupportStrTest.php b/tests/Support/SupportStrTest.php index 1bd26cbde1c3..da7d56126e75 100755 --- a/tests/Support/SupportStrTest.php +++ b/tests/Support/SupportStrTest.php @@ -936,7 +936,7 @@ public function testMask() $this->assertSame('***************', Str::mask('maria@email.com', '*', 0)); } - public function testMatch() + public function testMatch(): void { $this->assertSame('bar', Str::match('/bar/', 'foo bar')); $this->assertSame('bar', Str::match('/foo (.*)/', 'foo bar')); @@ -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')); @@ -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()