Basic tests for wp_parse_id_list() to ensure positive integers. see [25169].

git-svn-id: https://develop.svn.wordpress.org/trunk@25170 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2013-08-29 18:58:40 +00:00
parent 59b9a3a6f8
commit f6966d20b3
1 changed files with 19 additions and 0 deletions

View File

@ -336,4 +336,23 @@ class Tests_Functions extends WP_UnitTestCase {
update_option( 'blog_charset', $orig_blog_charset );
}
/**
* @dataProvider data_wp_parse_id_list
*/
function test_wp_parse_id_list( $expected, $actual ) {
$this->assertSame( $expected, array_values( wp_parse_id_list( $actual ) ) );
}
function data_wp_parse_id_list() {
return array(
array( array( 1, 2, 3, 4 ), '1,2,3,4' ),
array( array( 1, 2, 3, 4 ), '1, 2,,3,4' ),
array( array( 1, 2, 3, 4 ), '1,2,2,3,4' ),
array( array( 1, 2, 3, 4 ), array( '1', '2', '3', '4', '3' ) ),
array( array( 1, 2, 3, 4 ), array( 1, '2', 3, '4' ) ),
array( array( 1, 2, 3, 4 ), '-1,2,-3,4' ),
array( array( 1, 2, 3, 4 ), array( -1, 2, '-3', '4' ) ),
);
}
}