Make WordPress Core


Ignore:
Timestamp:
02/28/2024 06:09:38 PM (13 months ago)
Author:
SergeyBiryukov
Message:

Tests: Expand wp_parse_id_list() unit tests.

Includes:

  • Moving pre-existing wp_parse_id_list() tests to their own file.
  • Merging new and pre-existing wp_parse_slug_list() tests.
  • Using named data provider in wp_parse_list() tests.

Follow-up to [25170], [40044], [44546], [57284], [57725].

Props pbearne, mukesh27, SergeyBiryukov.
Fixes #60218. See #60217, #59647.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/functions.php

    r57524 r57737  
    725725
    726726        update_option( 'blog_charset', $orig_blog_charset );
    727     }
    728 
    729     /**
    730      * @dataProvider data_wp_parse_id_list
    731      */
    732     public function test_wp_parse_id_list( $expected, $actual ) {
    733         $this->assertSame( $expected, array_values( wp_parse_id_list( $actual ) ) );
    734     }
    735 
    736     public function data_wp_parse_id_list() {
    737         return array(
    738             array( array( 1, 2, 3, 4 ), '1,2,3,4' ),
    739             array( array( 1, 2, 3, 4 ), '1, 2,,3,4' ),
    740             array( array( 1, 2, 3, 4 ), '1,2,2,3,4' ),
    741             array( array( 1, 2, 3, 4 ), array( '1', '2', '3', '4', '3' ) ),
    742             array( array( 1, 2, 3, 4 ), array( 1, '2', 3, '4' ) ),
    743             array( array( 1, 2, 3, 4 ), '-1,2,-3,4' ),
    744             array( array( 1, 2, 3, 4 ), array( -1, 2, '-3', '4' ) ),
    745         );
    746     }
    747 
    748     /**
    749      * @dataProvider data_wp_parse_slug_list
    750      */
    751     public function test_wp_parse_slug_list( $expected, $actual ) {
    752         $this->assertSame( $expected, array_values( wp_parse_slug_list( $actual ) ) );
    753     }
    754 
    755     public function data_wp_parse_slug_list() {
    756         return array(
    757             array( array( 'apple', 'banana', 'carrot', 'dog' ), 'apple,banana,carrot,dog' ),
    758             array( array( 'apple', 'banana', 'carrot', 'dog' ), 'apple, banana,,carrot,dog' ),
    759             array( array( 'apple', 'banana', 'carrot', 'dog' ), 'apple banana carrot dog' ),
    760             array( array( 'apple', 'banana-carrot', 'd-o-g' ), array( 'apple ', 'banana carrot', 'd o g' ) ),
    761         );
    762727    }
    763728
Note: See TracChangeset for help on using the changeset viewer.