Skip to content
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

Add PHPUnit tests for wp_parse_id_list function #5851

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions tests/phpunit/tests/wpParseIdList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

/**
* Tests for the wp_parse_id_list function.
*
* @group functions
*
* @covers ::wp_parse_id_list
*/
class Tests_functions_wpParseIdList extends WP_UnitTestCase {

/**
* @ticket 60218
*
* @dataProvider data_wp_parse_id_list
*/
public function test_wp_parse_id_list( $input_list, $expected ) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

$this->assertSameSets( $expected, wp_parse_id_list( $input_list ) );
}

/**
* data for test_wp_parse_id_list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* data for test_wp_parse_id_list
* Data provider for test_wp_parse_id_list().

*
* @ticket 60218
*
Comment on lines +25 to +26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @ticket 60218
*

No needs to add @ticket annotation for Data Provider.

* @return array[]
*/
public function data_wp_parse_id_list() {
return array(
'simple' => array(
'input_list' => array( '1', 2, 'string with spaces' ),
'expected' => array( 0, 1, 2 ),
),
'simple_with_comma' => array(
'input_list' => '1,2,string with spaces',
'expected' => array( 0, 1, 2 ),
),
'array_with_spaces' => array(
'input_list' => array( '1 2 string with spaces' ),
'expected' => array( 1 ),
),
'simple_with_spaces' => array(
'input_list' => '1 2 string with spaces',
'expected' => array( 0, 1, 2 ),
),
'array_html' => array(
'input_list' => array( '1', 2, 'string <strong>with</strong> <h1>HEADING</h1>' ),
'expected' => array( 0, 1, 2 ),
),
'simple_html_spaces' => array(
'input_list' => '1 2 string <strong>with</strong> <h1>HEADING</h1>',
'expected' => array( 0, 1, 2 ),
),
'dup_id' => array(
'input_list' => '1 1 string string',
'expected' => array( 0, 1 ),
),
);
}
}
Loading