mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PHPUnit tests for wp_parse_slug_list function
A new phpunit test file is added specifically for testing the 'wp_parse_slug_list' function. Different scenarios are covered including handling of plain numbers, strings with spaces, strings with commas, and HTML. This ensures that the function responds correctly to a wide array of inputs, improving overall software reliability and stability.
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/** | ||
* Tests for the wp_parse_slug_list function. | ||
* | ||
* @group functions | ||
* | ||
* @covers ::wp_parse_slug_list | ||
*/ | ||
class Tests_functions_wpParseSlugList extends WP_UnitTestCase { | ||
|
||
/** | ||
* @ticket 60217 | ||
* | ||
* @dataProvider data_wp_parse_slug_list | ||
*/ | ||
public function test_wp_parse_slug_list( $list, $expected ) { | ||
|
||
$this->assertSameSets( $expected, wp_parse_slug_list( $list ) ); | ||
} | ||
|
||
public function data_wp_parse_slug_list() { | ||
return array( | ||
'simple' => array( | ||
'list' => array( '1', 2, 'string with spaces' ), | ||
'expected' => array( '1', '2', 'string-with-spaces' ), | ||
), | ||
'simple_with_comma' => array( | ||
'list' => '1,2,string with spaces', | ||
'expected' => array( '1', '2', 'string', 'with', 'spaces' ), | ||
), | ||
'array_with_spaces' => array( | ||
'list' => array( '1 2 string with spaces' ), | ||
'expected' => array( '1-2-string-with-spaces' ), | ||
), | ||
'simple_with_spaces' => array( | ||
'list' => '1 2 string with spaces', | ||
'expected' => array( '1', '2', 'string', 'with', 'spaces' ), | ||
), | ||
'array_html' => array( | ||
'list' => array( '1', 2, 'string <strong>with</strong> <h1>HEADING</h1>' ), | ||
'expected' => array( '1', '2', 'string-with-heading' ), | ||
), | ||
'simple_html_spaces' => array( | ||
'list' => '1 2 string <strong>with</strong> <h1>HEADING</h1>', | ||
'expected' => array( '1', '2', 'string', 'with', 'heading' ), | ||
), | ||
); | ||
} | ||
} |