Make WordPress Core


Ignore:
Timestamp:
04/11/2022 10:36:02 AM (3 years ago)
Author:
gziolo
Message:

Editor: Add functionality required for theme export in the site editor

This bring across changes to theme export functionality, and related code, and tests. Relates issue in Gutenberg: https://github.com/WordPress/gutenberg/issues/39889.

Props scruffian, timothyblynjacobs, oandregal, ajlende, zieleadam.
See #55505.

File:
1 edited

Legend:

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

    r53044 r53129  
    21742174        $this->assertEquals( 111, wp_filesize( $file ) );
    21752175    }
     2176
     2177    /**
     2178     * @ticket 55505
     2179     * @covers ::wp_recursive_ksort
     2180     */
     2181    function test_wp_recursive_ksort() {
     2182        // Create an array to test.
     2183        $theme_json = array(
     2184            'version'  => 1,
     2185            'settings' => array(
     2186                'typography' => array(
     2187                    'fontFamilies' => array(
     2188                        'fontFamily' => 'DM Sans, sans-serif',
     2189                        'slug'       => 'dm-sans',
     2190                        'name'       => 'DM Sans',
     2191                    ),
     2192                ),
     2193                'color'      => array(
     2194                    'palette' => array(
     2195                        array(
     2196                            'slug'  => 'foreground',
     2197                            'color' => '#242321',
     2198                            'name'  => 'Foreground',
     2199                        ),
     2200                        array(
     2201                            'slug'  => 'background',
     2202                            'color' => '#FCFBF8',
     2203                            'name'  => 'Background',
     2204                        ),
     2205                        array(
     2206                            'slug'  => 'primary',
     2207                            'color' => '#71706E',
     2208                            'name'  => 'Primary',
     2209                        ),
     2210                        array(
     2211                            'slug'  => 'tertiary',
     2212                            'color' => '#CFCFCF',
     2213                            'name'  => 'Tertiary',
     2214                        ),
     2215                    ),
     2216                ),
     2217            ),
     2218        );
     2219
     2220        // Sort the array.
     2221        wp_recursive_ksort( $theme_json );
     2222
     2223        // Expected result.
     2224        $expected_theme_json = array(
     2225            'settings' => array(
     2226                'color'      => array(
     2227                    'palette' => array(
     2228                        array(
     2229                            'color' => '#242321',
     2230                            'name'  => 'Foreground',
     2231                            'slug'  => 'foreground',
     2232                        ),
     2233                        array(
     2234                            'color' => '#FCFBF8',
     2235                            'name'  => 'Background',
     2236                            'slug'  => 'background',
     2237                        ),
     2238                        array(
     2239                            'color' => '#71706E',
     2240                            'name'  => 'Primary',
     2241                            'slug'  => 'primary',
     2242                        ),
     2243                        array(
     2244                            'color' => '#CFCFCF',
     2245                            'name'  => 'Tertiary',
     2246                            'slug'  => 'tertiary',
     2247                        ),
     2248                    ),
     2249                ),
     2250                'typography' => array(
     2251                    'fontFamilies' => array(
     2252                        'fontFamily' => 'DM Sans, sans-serif',
     2253                        'name'       => 'DM Sans',
     2254                        'slug'       => 'dm-sans',
     2255                    ),
     2256                ),
     2257            ),
     2258            'version'  => 1,
     2259        );
     2260        $this->assertEquals( $theme_json, $expected_theme_json );
     2261    }
     2262
    21762263}
Note: See TracChangeset for help on using the changeset viewer.