From f6966d20b3bc35e9ef18bf12410a16e3f0deb5d6 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 29 Aug 2013 18:58:40 +0000 Subject: [PATCH] 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 --- tests/phpunit/tests/functions.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index eee3054b96..87881eb547 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -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' ) ), + ); + } }