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 to SupportStrTest #51437

Merged
merged 2 commits into from
May 17, 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
17 changes: 14 additions & 3 deletions tests/Support/SupportStrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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'));
Expand All @@ -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('[email protected]', '@'));
$this->assertSame('foo', Str::before('foo@@bar.com', '@'));
$this->assertSame('', Str::before('@[email protected]', '@'));
}

public function testStrBeforeLast(): void
Expand All @@ -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', ''));
Expand All @@ -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()
Expand Down