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] improvement test for string title #51015

Merged
merged 4 commits into from
Apr 10, 2024

Conversation

saMahmoudzadeh
Copy link
Contributor

This PR, improvement test for Str::title

The added tests include:

  • Testing an empty string to ensure that Str::title('') returns an empty string.
$this->assertSame('', Str::title(''));
  • Testing a string containing numbers to ensure that Str::title('123 laravel') correctly capitalizes the first letter of each word.
$this->assertSame('123 Laravel', Str::title('123 laravel'));
  • Testing a string containing a special character (heart emoji) to ensure that Str::title('❤laravel') capitalizes the first letter of each word correctly.
$this->assertSame('❤Laravel', Str::title('❤laravel'));
$this->assertSame('Laravel ❤', Str::title('laravel ❤'));
  • Testing a string containing both letters and numbers to ensure that Str::title('laravel123') correctly capitalizes the first letter of each word.
$this->assertSame('Laravel123', Str::title('laravel123'));
  • Testing a string starting with a capital letter and containing numbers to ensure that Str::title('Laravel123') does not modify the original capitalization.
$this->assertSame('Laravel123', Str::title('Laravel123'));
  • Testing a long string to ensure that Str::title() works efficiently and accurately for large inputs.
$longString = 'lorem ipsum ' . str_repeat('dolor sit amet ', 1000);
$expectedResult = 'Lorem Ipsum Dolor Sit Amet ' . str_repeat('Dolor Sit Amet ', 999);
$this->assertSame($expectedResult, Str::title($longString));

Thanks!

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
Copy link
Contributor Author

The test Illuminate\Tests\Integration\Database\AfterQueryTest::testAfterQueryOnBaseBuilderPluck has failed, and it is related to SQL Server. It has no correlation with my changes.

@saMahmoudzadeh saMahmoudzadeh marked this pull request as ready for review April 10, 2024 21:24
@taylorotwell taylorotwell merged commit 57c6823 into laravel:11.x Apr 10, 2024
27 of 28 checks passed
@saMahmoudzadeh saMahmoudzadeh deleted the test/string-title branch April 10, 2024 21:30
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