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 in SupportStrTest class #51235

Merged
merged 4 commits into from
Apr 29, 2024

Conversation

saMahmoudzadeh
Copy link
Contributor

This PR, enhances the test coverage for the SupportStrTest class by adding new tests.

1. testStringCanBeLimitedByWords()

Testing negative values for the word count and an empty string are important edge cases to cover.

$this->assertSame('Taylor Otwell', Str::words('Taylor Otwell', -1, '...'));
$this->assertSame('', Str::words('', 3, '...')); 

2. testStringWithoutWordsDoesntProduceError

Testing multiple space and tabs

$this->assertSame('   ', Str::words('   '));
$this->assertSame("\t\t\t", Str::words("\t\t\t"));

3. testStrBeforeLast

$this->assertSame('', Str::beforeLast('', 'test')); // empty string
$this->assertSame('', Str::beforeLast('yvette', 'yvette')); // search parater equal subject parameter
$this->assertSame('laravel', Str::beforeLast("laravel framework", ' ')); // check space
$this->assertSame('yvette', Str::beforeLast("yvette\tyv0et0te", "\t")); // check tab space

Copy link

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@saMahmoudzadeh saMahmoudzadeh marked this pull request as ready for review April 28, 2024 22:51
@taylorotwell taylorotwell merged commit e38d945 into laravel:11.x Apr 29, 2024
28 checks passed
@saMahmoudzadeh saMahmoudzadeh deleted the test/support-str-test branch April 29, 2024 13:53
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