fix: replace substr with mb_substr in Str::beforeLast to ensure multibyte string compatibility and correct TeamCity test names for datasets in "describe" blocks
#1606
+15
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What:
Description:
Problem:
When running Pest tests with --teamcity flag inside a describe block with datasets, the last 2 characters of the test suite name are incorrectly cut off.
Root Cause:
The Str::beforeLast() method in src/Support/Str.php has a byte/character position mismatch bug:
The describe block format uses the arrow character → (U+2192), which is:
When mb_strrpos finds the position of with data set in a string like
my_block→ my_test with data set "1", it returns a character position. But substr interprets this as a byte position, causing a 2-byte offset (3 bytes for → minus 1 character = 2 bytes difference).Example:
my_block→ my_test with data set "1"my_block→ my_testmy_block→ my_teSolution
Change substr to mb_substr in Str::beforeLast() to ensure character-based substring operation matches the character based position from mb_strrpos.
Impact
It will allow to support navigation for such tests from the Test Results tool window in PhpStorm to source code in the file.