Make WordPress Core

Changeset 52938


Ignore:
Timestamp:
03/16/2022 03:04:40 AM (2 years ago)
Author:
peterwilsoncc
Message:

Tests: Include special characters in term names for wp_set_term_objects().

Test wp_set_term_objects() using terms with special characters in the name, for example ampersand, bullet and other symbols and punctuation.

Props kapacity, costdev.
Fixes #53152.
See #54725.

File:
1 edited

Legend:

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

    r52654 r52938  
    254254
    255255    /**
     256     * @ticket 53152
     257     * @dataProvider data_wp_set_term_objects_finds_term_name_with_special_characters
     258     *
     259     * @param string $name  A term name containing special characters.
     260     */
     261    public function test_wp_set_term_objects_finds_term_name_with_special_characters( $name ) {
     262        $post_id  = self::$post_ids[0];
     263        $expected = wp_set_object_terms( $post_id, $name, 'category', false );
     264        $actual   = wp_set_object_terms( $post_id, $name, 'category', false );
     265        $this->assertEquals( $expected, $actual );
     266    }
     267
     268    /**
     269     * Data provider.
     270     *
     271     * @return array
     272     */
     273    public function data_wp_set_term_objects_finds_term_name_with_special_characters() {
     274        return array(
     275            'ampersand'               => array( 'name' => 'Foo & Bar' ),
     276            'ndash and mdash'         => array( 'name' => 'Foo – Bar' ),
     277            'trademark'               => array( 'name' => 'Foo Bar™' ),
     278            'copyright'               => array( 'name' => 'Foo Bar©' ),
     279            'registered'              => array( 'name' => 'Foo Bar®' ),
     280            'degree'                  => array( 'name' => 'Foo ° Bar' ),
     281            'forward slash'           => array( 'name' => 'Fo/o Ba/r' ),
     282            'back slash'              => array( 'name' => 'F\oo \Bar' ),
     283            'multiply'                => array( 'name' => 'Foo × Bar' ),
     284            'standalone diacritic'    => array( 'name' => 'Foo Bāáǎàr' ),
     285            'acute accents'           => array( 'name' => 'ááa´aˊ' ),
     286            'iexcel and iquest'       => array( 'name' => '¡Foo ¿Bar' ),
     287            'angle quotes'            => array( 'name' => '‹Foo« »Bar›' ),
     288            'curly quotes'            => array( 'name' => '“F‘o„o‚ „ ‟ ‛B“a’r”' ),
     289            'bullet'                  => array( 'name' => 'Foo • Bar' ),
     290            'unencoded percent'       => array( 'name' => 'Foo % Bar' ),
     291            'encoded ampersand'       => array( 'name' => 'Foo & Bar' ),
     292            'encoded ndash and mdash' => array( 'name' => 'Foo — – Bar' ),
     293            'encoded trademark'       => array( 'name' => 'Foo Bar ™' ),
     294            'encoded copyright'       => array( 'name' => 'Foo Bar ©' ),
     295            'encoded registered'      => array( 'name' => 'Foo Bar ®' ),
     296            'encoded bullet'          => array( 'name' => 'Foo • Bar' ),
     297        );
     298    }
     299
     300    /**
    256301     * @ticket 19205
    257302     */
Note: See TracChangeset for help on using the changeset viewer.