From 6727464c047a4327515cee4e4a0dff35a8c4f726 Mon Sep 17 00:00:00 2001 From: "S.a Mahmoudzadeh" <36761585+saMahmoudzadeh@users.noreply.github.com> Date: Fri, 17 May 2024 19:32:17 +0330 Subject: [PATCH] [11.x] Add some tests to `SupportStrTest` (#51437) * Add some tests * fixes --- tests/Support/SupportStrTest.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/Support/SupportStrTest.php b/tests/Support/SupportStrTest.php index da7d56126e75..781982f77a4a 100755 --- a/tests/Support/SupportStrTest.php +++ b/tests/Support/SupportStrTest.php @@ -125,10 +125,12 @@ public function testStringWithoutWordsDoesntProduceError(): void $this->assertSame("\t\t\t", Str::words("\t\t\t")); } - public function testStringAscii() + public function testStringAscii(): void { $this->assertSame('@', Str::ascii('@')); $this->assertSame('u', Str::ascii('ü')); + $this->assertSame('', Str::ascii('')); + $this->assertSame('a!2e', Str::ascii('a!2ë')); } public function testStringAsciiWithSpecificLocale() @@ -257,7 +259,7 @@ public function testStrExcerpt() $this->assertNull(Str::excerpt('', '/')); } - public function testStrBefore() + public function testStrBefore(): void { $this->assertSame('han', Str::before('hannah', 'nah')); $this->assertSame('ha', Str::before('hannah', 'n')); @@ -267,6 +269,12 @@ public function testStrBefore() $this->assertSame('han', Str::before('han0nah', '0')); $this->assertSame('han', Str::before('han0nah', 0)); $this->assertSame('han', Str::before('han2nah', 2)); + $this->assertSame('', Str::before('', '')); + $this->assertSame('', Str::before('', 'a')); + $this->assertSame('', Str::before('a', 'a')); + $this->assertSame('foo', Str::before('foo@bar.com', '@')); + $this->assertSame('foo', Str::before('foo@@bar.com', '@')); + $this->assertSame('', Str::before('@foo@bar.com', '@')); } public function testStrBeforeLast(): void @@ -286,7 +294,7 @@ public function testStrBeforeLast(): void $this->assertSame('yvette', Str::beforeLast("yvette\tyv0et0te", "\t")); } - public function testStrBetween() + public function testStrBetween(): void { $this->assertSame('abc', Str::between('abc', '', 'c')); $this->assertSame('abc', Str::between('abc', 'a', '')); @@ -299,6 +307,9 @@ public function testStrBetween() $this->assertSame('a]ab[b', Str::between('[a]ab[b]', '[', ']')); $this->assertSame('foo', Str::between('foofoobar', 'foo', 'bar')); $this->assertSame('bar', Str::between('foobarbar', 'foo', 'bar')); + $this->assertSame('234', Str::between('12345', 1, 5)); + $this->assertSame('45', Str::between('123456789', '123', '6789')); + $this->assertSame('nothing', Str::between('nothing', 'foo', 'bar')); } public function testStrBetweenFirst()