Repository navigation
Build/QA: Retire parameterByRef.unusedType baseline #14025
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
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| <?php | ||
| /** | ||
| * Unit tests covering _wp_scan_utf8(). | ||
| * | ||
| * @package WordPress | ||
| * @subpackage Charset | ||
| * | ||
| * @group compat | ||
| * | ||
| * @covers ::_wp_scan_utf8 | ||
| */ | ||
| class Tests_Compat_wpScanUtf8 extends WP_UnitTestCase { | ||
|
|
||
| /** | ||
| * Tests scanning a valid ASCII string. | ||
| * | ||
| * @ticket 65817 | ||
| */ | ||
| public function test_scan_ascii_string() { | ||
| $text = 'Hello, World!'; | ||
| $at = 0; | ||
| $invalid_length = 0; | ||
| $has_noncharacters = null; | ||
|
|
||
| $scanned = _wp_scan_utf8( $text, $at, $invalid_length, null, null, $has_noncharacters ); | ||
|
|
||
| $this->assertSame( 13, $scanned ); | ||
| $this->assertSame( 0, $invalid_length ); | ||
| $this->assertFalse( $has_noncharacters ); | ||
| } | ||
|
|
||
| /** | ||
| * Tests scanning UTF-8 string containing noncharacters. | ||
| * | ||
| * @ticket 65817 | ||
| * | ||
| * @dataProvider data_strings_with_noncharacters | ||
| * | ||
| * @param string $text UTF-8 string containing a noncharacter. | ||
| */ | ||
| public function test_scan_string_with_noncharacters( string $text ) { | ||
| $at = 0; | ||
| $invalid_length = 0; | ||
| $has_noncharacters = null; | ||
|
|
||
| _wp_scan_utf8( $text, $at, $invalid_length, null, null, $has_noncharacters ); | ||
|
|
||
| $this->assertTrue( $has_noncharacters ); | ||
| } | ||
|
|
||
| /** | ||
| * Data provider for noncharacters. | ||
| * | ||
| * @return array<string, array{0: string}> | ||
| */ | ||
| public static function data_strings_with_noncharacters() { | ||
| return array( | ||
| 'U+FFFF (3-byte noncharacter)' => array( "test \xEF\xBF\xBF end" ), | ||
| 'U+FFFE (3-byte noncharacter)' => array( "test \xEF\xBF\xBE end" ), | ||
| 'U+FDD0 (3-byte noncharacter)' => array( "test \xEF\xB7\x90 end" ), | ||
| 'U+1FFFF (4-byte noncharacter)' => array( "test \xF0\x9F\xBF\xBF end" ), | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Tests scanning UTF-8 string without noncharacters. | ||
| * | ||
| * @ticket 65817 | ||
| */ | ||
| public function test_scan_string_without_noncharacters() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a misleading title. it would be clearer to show variant cases of multi-byte UTF-8 code points and extended grapheme clusters, which would clarify the behavior of the function. let’s use a data provider and show interesting cases, and then use this way we can cover two-, three-, and four-byte sequences, spans of invalid bytes (covering the maximal subpart behavior), ZWJ sequences, and grapheme clusters. |
||
| $text = 'WordPress: 日本語 and Piña!'; | ||
| $at = 0; | ||
| $invalid_length = 0; | ||
| $has_noncharacters = null; | ||
|
|
||
| _wp_scan_utf8( $text, $at, $invalid_length, null, null, $has_noncharacters ); | ||
|
|
||
| $this->assertFalse( $has_noncharacters ); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please verify that this doesn’t break the docs-generation. before we start changing
@paramdeclarations, we should ensure that the published docs page isn’t broken.you can hopefully lean on dmsnell#29 to figure out how to preview the generation.
I see that this is an additional annotation beyond the
@param, but it would be ideal to double-check first.