Make WordPress Core


Ignore:
Timestamp:
05/24/2021 12:24:14 PM (5 years ago)
Author:
SergeyBiryukov
Message:

General: Some documentation and test improvements for the _wp_array_set():

  • Update the function DocBlock per the documentation standards.
  • Move the unit tests to a more appropriate place.
  • Rename and reorder the tests for consistency with _wp_array_get() tests.

Follow-up to [50958], [50962], [50964].

See #53175, #52625.

File:
1 edited

Legend:

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

    r50964 r50965  
    5858
    5959        /**
    60          * Test _wp_array_get() with non subtree paths.
     60         * Test _wp_array_get() with non-subtree paths.
    6161         *
    6262         * @ticket 51720
    6363         */
    6464        public function test_wp_array_get_simple_non_subtree() {
    65                 // Simple non sub tree test.
     65                // Simple non-subtree test.
    6666                $this->assertSame(
    6767                        _wp_array_get(
     
    7474                );
    7575
    76                 // Simple non sub tree not found.
     76                // Simple non-subtree not found.
    7777                $this->assertSame(
    7878                        _wp_array_get(
     
    8585                );
    8686
    87                 // Simple non sub tree not found with a default.
     87                // Simple non-subtree not found with a default.
    8888                $this->assertSame(
    8989                        _wp_array_get(
     
    9797                );
    9898
    99                 // Simple non sub tree integer path.
     99                // Simple non-subtree integer path.
    100100                $this->assertSame(
    101101                        _wp_array_get(
     
    112112
    113113        /**
     114         * Test _wp_array_get() with subtrees.
     115         *
     116         * @ticket 51720
     117         */
     118        public function test_wp_array_get_subtree() {
     119                $this->assertSame(
     120                        _wp_array_get(
     121                                array(
     122                                        'a' => array(
     123                                                'b' => array(
     124                                                        'c' => 1,
     125                                                ),
     126                                        ),
     127                                ),
     128                                array( 'a', 'b' )
     129                        ),
     130                        array( 'c' => 1 )
     131                );
     132
     133                $this->assertSame(
     134                        _wp_array_get(
     135                                array(
     136                                        'a' => array(
     137                                                'b' => array(
     138                                                        'c' => 1,
     139                                                ),
     140                                        ),
     141                                ),
     142                                array( 'a', 'b', 'c' )
     143                        ),
     144                        1
     145                );
     146
     147                $this->assertSame(
     148                        _wp_array_get(
     149                                array(
     150                                        'a' => array(
     151                                                'b' => array(
     152                                                        'c' => 1,
     153                                                ),
     154                                        ),
     155                                ),
     156                                array( 'a', 'b', 'c', 'd' )
     157                        ),
     158                        null
     159                );
     160        }
     161
     162        /**
    114163         * Test _wp_array_get() with zero strings.
    115164         *
     
    159208                        ),
    160209                        'b'
    161                 );
    162         }
    163 
    164 
    165         /**
    166          * Test _wp_array_get() with subtrees.
    167          *
    168          * @ticket 51720
    169          */
    170         public function test_wp_array_get_subtree() {
    171                 $this->assertSame(
    172                         _wp_array_get(
    173                                 array(
    174                                         'a' => array(
    175                                                 'b' => array(
    176                                                         'c' => 1,
    177                                                 ),
    178                                         ),
    179                                 ),
    180                                 array( 'a', 'b' )
    181                         ),
    182                         array( 'c' => 1 )
    183                 );
    184 
    185                 $this->assertSame(
    186                         _wp_array_get(
    187                                 array(
    188                                         'a' => array(
    189                                                 'b' => array(
    190                                                         'c' => 1,
    191                                                 ),
    192                                         ),
    193                                 ),
    194                                 array( 'a', 'b', 'c' )
    195                         ),
    196                         1
    197                 );
    198 
    199                 $this->assertSame(
    200                         _wp_array_get(
    201                                 array(
    202                                         'a' => array(
    203                                                 'b' => array(
    204                                                         'c' => 1,
    205                                                 ),
    206                                         ),
    207                                 ),
    208                                 array( 'a', 'b', 'c', 'd' )
    209                         ),
    210                         null
    211210                );
    212211        }
Note: See TracChangeset for help on using the changeset viewer.