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

Conversation

saMahmoudzadeh
Copy link
Contributor

@saMahmoudzadeh saMahmoudzadeh commented May 17, 2024

This PR, Add some tests to SupportStrTest.php

testStringAscii()

// the empty string and a combination of letters, numbers, and special characters have been tested.
$this->assertSame('', Str::ascii(''));
$this->assertSame('a!2e', Str::ascii('a!2ë'));

testStrBefore()

// test empty string, and first character
$this->assertSame('', Str::before('', ''));
$this->assertSame('', Str::before('', 'a'));
$this->assertSame('', Str::before('a', 'a'));

// testing the search for the special character '@'
$this->assertSame('foo', Str::before('[email protected]', '@'));
$this->assertSame('foo', Str::before('foo@@bar.com', '@'));
$this->assertSame('', Str::before('@[email protected]', '@'));

testStrBetween()

// testing numbers
$this->assertSame('234', Str::between('12345', 1, 5));
$this->assertSame('45', Str::between('123456789', '123', '6789'));

// testing the scenario where 'foo' and 'bar' are not found within the string 'nothing'.
$this->assertSame('nothing', Str::between('nothing', 'foo', 'bar'));

Thanks!

@taylorotwell taylorotwell merged commit 6727464 into laravel:11.x May 17, 2024
28 checks passed
@saMahmoudzadeh saMahmoudzadeh deleted the tests/str branch May 17, 2024 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants