Make WordPress Core

Ticket #49037: 49037.3.diff

File 49037.3.diff, 25.8 KB (added by spacedmonkey, 4 years ago)
  • src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php
    index 1d86d9938a..095d99ef64 100644
    a b class WP_REST_Themes_Controller extends WP_REST_Controller { 
    110110                $fields = $this->get_fields_for_response( $request );
    111111
    112112                if ( in_array( 'theme_supports', $fields, true ) ) {
     113                        $item_schemas   = $this->get_item_schema();
     114                        $theme_supports = $item_schemas['properties']['theme_supports']['properties'];
     115                        foreach ( $theme_supports as $name => $schema ) {
     116                                $data['theme_supports'][ $name ] = rest_sanitize_value_from_schema( get_theme_support( $name ), $schema );
     117                                if ( array( 'bool', 'array' ) === $schema['type'] || array( 'bool', 'object' ) === $schema['type'] ) {
     118                                        if ( is_array( $data['theme_supports'][ $name ] ) && ! empty( $data['theme_supports'][ $name ] ) ) {
     119                                                $data['theme_supports'][ $name ] = array_shift( $data['theme_supports'][ $name ] );
     120                                        } else {
     121                                                $data['theme_supports'][ $name ] = (bool) $data['theme_supports'][ $name ];
     122                                        }
     123                                }
     124                        }
     125
    113126                        $formats                           = get_theme_support( 'post-formats' );
    114127                        $formats                           = is_array( $formats ) ? array_values( $formats[0] ) : array();
    115128                        $formats                           = array_merge( array( 'standard' ), $formats );
    116129                        $data['theme_supports']['formats'] = $formats;
    117130
    118                         $data['theme_supports']['post-thumbnails']   = false;
    119                         $data['theme_supports']['responsive-embeds'] = (bool) get_theme_support( 'responsive-embeds' );
    120                         $post_thumbnails                             = get_theme_support( 'post-thumbnails' );
     131                        $post_thumbnails = get_theme_support( 'post-thumbnails' );
    121132
    122133                        if ( $post_thumbnails ) {
    123134                                // $post_thumbnails can contain a nested array of post types.
    class WP_REST_Themes_Controller extends WP_REST_Controller { 
    165176                                        'type'        => 'array',
    166177                                        'readonly'    => true,
    167178                                        'properties'  => array(
    168                                                 'formats'           => array(
     179                                                'align-wide'                => array(
     180                                                        'description' => __( 'Whether theme opts in to wide alignment CSS class.' ),
     181                                                        'type'        => 'bool',
     182                                                        'readonly'    => true,
     183                                                ),
     184                                                'automatic-feed-links'      => array(
     185                                                        'description' => __( 'Whether posts and comments RSS feed links are added to head.' ),
     186                                                        'type'        => 'bool',
     187                                                        'readonly'    => true,
     188                                                ),
     189                                                'custom-header'             => array(
     190                                                        'description' => __( 'Custom header if defined by the theme.' ),
     191                                                        'type'        => array( 'bool', 'object' ),
     192                                                        'properties'  => array(
     193                                                                'default-image'          => array(
     194                                                                        'type' => 'string',
     195                                                                ),
     196                                                                'random-default'         => array(
     197                                                                        'type' => 'bool',
     198                                                                ),
     199                                                                'width'                  => array(
     200                                                                        'type' => 'number',
     201                                                                ),
     202                                                                'height'                 => array(
     203                                                                        'type' => 'number',
     204                                                                ),
     205                                                                'flex-height'            => array(
     206                                                                        'type' => 'bool',
     207                                                                ),
     208                                                                'flex-width'             => array(
     209                                                                        'type' => 'bool',
     210                                                                ),
     211                                                                'default-text-color'     => array(
     212                                                                        'type' => 'string',
     213                                                                ),
     214                                                                'header-text'            => array(
     215                                                                        'type' => 'bool',
     216                                                                ),
     217                                                                'uploads'                => array(
     218                                                                        'type' => 'bool',
     219                                                                ),
     220                                                                'wp-head-callback'       => array(
     221                                                                        'type' => 'string',
     222                                                                ),
     223                                                                'admin-head-callback'    => array(
     224                                                                        'type' => 'string',
     225                                                                ),
     226                                                                'admin-preview-callback' => array(
     227                                                                        'type' => 'string',
     228                                                                ),
     229                                                                'video'                  => array(
     230                                                                        'type' => 'bool',
     231                                                                ),
     232                                                                'video-active-callback'  => array(
     233                                                                        'type' => 'string',
     234                                                                ),
     235                                                        ),
     236                                                        'readonly'    => true,
     237                                                ),
     238                                                'custom-logo'               => array(
     239                                                        'description' => __( 'Custom logo if defined by the theme.' ),
     240                                                        'type'        => array( 'bool', 'object' ),
     241                                                        'properties'  => array(
     242                                                                'width'       => array(
     243                                                                        'type' => 'number',
     244                                                                ),
     245                                                                'height'      => array(
     246                                                                        'type' => 'number',
     247                                                                ),
     248                                                                'flex-width'  => array(
     249                                                                        'type' => 'bool',
     250                                                                ),
     251                                                                'flex-height' => array(
     252                                                                        'type' => 'bool',
     253                                                                ),
     254                                                                'header-text' => array(
     255                                                                        'type' => 'array',
     256                                                                ),
     257                                                        ),
     258                                                        'readonly'    => true,
     259                                                ),
     260                                                'customize-selective-refresh-widgets' => array(
     261                                                        'description' => __( 'Whether the theme enables Selective Refresh for Widgets being managed with the Customizer.' ),
     262                                                        'type'        => 'bool',
     263                                                        'readonly'    => true,
     264                                                ),
     265                                                'dark-editor-style'         => array(
     266                                                        'description' => __( 'Whether theme opts in to the dark editor style UI.' ),
     267                                                        'type'        => 'bool',
     268                                                        'readonly'    => true,
     269                                                ),
     270                                                'disable-custom-colors'     => array(
     271                                                        'description' => __( 'Whether the theme disables custom colors.' ),
     272                                                        'type'        => 'bool',
     273                                                        'readonly'    => true,
     274                                                ),
     275                                                'disable-custom-font-sizes' => array(
     276                                                        'description' => __( 'Whether the theme disables custom font sizes.' ),
     277                                                        'type'        => 'bool',
     278                                                        'readonly'    => true,
     279                                                ),
     280                                                'editor-color-palette'      => array(
     281                                                        'description' => __( 'Custom color palette if defined by the theme.' ),
     282                                                        'type'        => array( 'bool', 'array' ),
     283                                                        'items'       => array(
     284                                                                'type'       => 'object',
     285                                                                'properties' => array(
     286                                                                        'name'  => array(
     287                                                                                'type' => 'string',
     288                                                                        ),
     289                                                                        'slug'  => array(
     290                                                                                'type' => 'string',
     291                                                                        ),
     292                                                                        'color' => array(
     293                                                                                'type' => 'string',
     294                                                                        ),
     295                                                                ),
     296                                                        ),
     297                                                        'readonly'    => true,
     298                                                ),
     299                                                'editor-font-sizes'         => array(
     300                                                        'description' => __( 'Custom font sizes if defined by the theme.' ),
     301                                                        'type'        => array( 'bool', 'object' ),
     302                                                        'properties'  => array(
     303                                                                'name' => array(
     304                                                                        'type' => 'string',
     305                                                                ),
     306                                                                'size' => array(
     307                                                                        'type' => 'number',
     308                                                                ),
     309                                                                'slug' => array(
     310                                                                        'type' => 'string',
     311                                                                ),
     312                                                        ),
     313                                                        'readonly'    => true,
     314                                                ),
     315                                                'editor-styles'             => array(
     316                                                        'description' => __( 'Whether theme opts in to the editor styles CSS wrapper.' ),
     317                                                        'type'        => 'bool',
     318                                                        'readonly'    => true,
     319                                                ),
     320                                                'formats'                   => array(
    169321                                                        'description' => __( 'Post formats supported.' ),
    170322                                                        'type'        => 'array',
     323                                                        'items'       => array(
     324                                                                'type' => 'string',
     325                                                        ),
     326                                                        'readonly'    => true,
     327                                                ),
     328                                                'html5'                     => array(
     329                                                        'description' => __( 'Allows use of html5 markup for search forms, comment forms, comment lists, gallery, and caption.' ),
     330                                                        'type'        => array( 'bool', 'array' ),
     331                                                        'items'       => array(
     332                                                                'type' => 'string',
     333                                                                'enum' => array(
     334                                                                        'search-form',
     335                                                                        'comment-form',
     336                                                                        'comment-list',
     337                                                                        'gallery',
     338                                                                        'caption',
     339                                                                        'script',
     340                                                                        'style',
     341                                                                ),
     342                                                        ),
    171343                                                        'readonly'    => true,
    172344                                                ),
    173                                                 'post-thumbnails'   => array(
     345                                                'post-thumbnails'           => array(
    174346                                                        'description' => __( 'Whether the theme supports post thumbnails.' ),
    175                                                         'type'        => array( 'array', 'bool' ),
     347                                                        'type'        => array( 'bool', 'array' ),
     348                                                        'items'       => array(
     349                                                                'type' => 'string',
     350                                                        ),
    176351                                                        'readonly'    => true,
    177352                                                ),
    178                                                 'responsive-embeds' => array(
     353                                                'responsive-embeds'         => array(
    179354                                                        'description' => __( 'Whether the theme supports responsive embedded content.' ),
    180355                                                        'type'        => 'bool',
    181356                                                        'readonly'    => true,
    182357                                                ),
     358                                                'title-tag'                 => array(
     359                                                        'description' => __( 'Whether the theme can manage the document title tag.' ),
     360                                                        'type'        => 'bool',
     361                                                        'readonly'    => true,
     362                                                ),
     363                                                'wp-block-styles'           => array(
     364                                                        'description' => __( 'Whether theme opts in to default WordPress block styles for viewing.' ),
     365                                                        'type'        => 'bool',
     366                                                        'readonly'    => true,
     367                                                ),
    183368                                        ),
    184369                                ),
    185370                        ),
  • tests/phpunit/tests/rest-api/rest-themes-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-themes-controller.php b/tests/phpunit/tests/rest-api/rest-themes-controller.php
    index 520dbed9d0..076b2beacd 100644
    a b class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { 
    188188                $properties = $data['schema']['properties'];
    189189                $this->assertEquals( 1, count( $properties ) );
    190190                $this->assertArrayHasKey( 'theme_supports', $properties );
    191 
    192                 $this->assertEquals( 3, count( $properties['theme_supports']['properties'] ) );
     191                $this->assertEquals( 17, count( $properties['theme_supports']['properties'] ) );
     192                $this->assertArrayHasKey( 'align-wide', $properties['theme_supports']['properties'] );
     193                $this->assertArrayHasKey( 'automatic-feed-links', $properties['theme_supports']['properties'] );
     194                $this->assertArrayHasKey( 'custom-header', $properties['theme_supports']['properties'] );
     195                $this->assertArrayHasKey( 'custom-logo', $properties['theme_supports']['properties'] );
     196                $this->assertArrayHasKey( 'customize-selective-refresh-widgets', $properties['theme_supports']['properties'] );
     197                $this->assertArrayHasKey( 'title-tag', $properties['theme_supports']['properties'] );
     198                $this->assertArrayHasKey( 'dark-editor-style', $properties['theme_supports']['properties'] );
     199                $this->assertArrayHasKey( 'disable-custom-font-sizes', $properties['theme_supports']['properties'] );
     200                $this->assertArrayHasKey( 'editor-color-palette', $properties['theme_supports']['properties'] );
     201                $this->assertArrayHasKey( 'editor-font-sizes', $properties['theme_supports']['properties'] );
     202                $this->assertArrayHasKey( 'editor-styles', $properties['theme_supports']['properties'] );
    193203                $this->assertArrayHasKey( 'formats', $properties['theme_supports']['properties'] );
     204                $this->assertArrayHasKey( 'html5', $properties['theme_supports']['properties'] );
    194205                $this->assertArrayHasKey( 'post-thumbnails', $properties['theme_supports']['properties'] );
    195206                $this->assertArrayHasKey( 'responsive-embeds', $properties['theme_supports']['properties'] );
     207                $this->assertArrayHasKey( 'title-tag', $properties['theme_supports']['properties'] );
     208                $this->assertArrayHasKey( 'wp-block-styles', $properties['theme_supports']['properties'] );
     209        }
     210
     211        /**
     212         * Test when a theme does not disable custom colors.
     213         *
     214         * @ticket 48798
     215         */
     216        public function test_theme_supports_disable_custom_colors_false() {
     217                remove_theme_support( 'disable-custom-colors' );
     218                $response = self::perform_active_theme_request();
     219                $result   = $response->get_data();
     220                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     221                $this->assertTrue( isset( $result[0]['theme_supports']['disable-custom-colors'] ) );
     222                $this->assertFalse( $result[0]['theme_supports']['disable-custom-colors'] );
     223        }
     224
     225        /**
     226         * Test when a theme disables custom colors.
     227         *
     228         * @ticket 48798
     229         */
     230        public function test_theme_supports_disable_custom_colors_true() {
     231                remove_theme_support( 'disable-custom-colors' );
     232                add_theme_support( 'disable-custom-colors' );
     233                $response = self::perform_active_theme_request();
     234                $result   = $response->get_data();
     235                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     236                $this->assertTrue( $result[0]['theme_supports']['disable-custom-colors'] );
     237        }
     238
     239        /**
     240         * Test when a theme does not disable custom font sizes.
     241         *
     242         * @ticket 48798
     243         */
     244        public function test_theme_supports_disable_custom_font_sizes_false() {
     245                remove_theme_support( 'disable-custom-font-sizes' );
     246                $response = self::perform_active_theme_request();
     247                $result   = $response->get_data();
     248                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     249                $this->assertTrue( isset( $result[0]['theme_supports']['disable-custom-font-sizes'] ) );
     250                $this->assertFalse( $result[0]['theme_supports']['disable-custom-font-sizes'] );
     251        }
     252
     253        /**
     254         * Test when a theme disables custom font sizes.
     255         *
     256         * @ticket 48798
     257         */
     258        public function test_theme_supports_disable_custom_font_sizes_true() {
     259                remove_theme_support( 'disable-custom-font-sizes' );
     260                add_theme_support( 'disable-custom-font-sizes' );
     261                $response = self::perform_active_theme_request();
     262                $result   = $response->get_data();
     263                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     264                $this->assertTrue( $result[0]['theme_supports']['disable-custom-font-sizes'] );
     265        }
     266
     267        /**
     268         * Test when a theme doesn't support custom font sizes.
     269         *
     270         * @ticket 48798
     271         */
     272        public function test_theme_supports_editor_font_sizes_false() {
     273                remove_theme_support( 'editor-font-sizes' );
     274                $response = self::perform_active_theme_request();
     275                $result   = $response->get_data();
     276                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     277                $this->assertTrue( isset( $result[0]['theme_supports']['editor-font-sizes'] ) );
     278                $this->assertFalse( $result[0]['theme_supports']['editor-font-sizes'] );
     279        }
     280
     281        /**
     282         * Test when a theme supports custom font sizes.
     283         *
     284         * @ticket 48798
     285         */
     286        public function test_theme_supports_editor_font_sizes_array() {
     287                remove_theme_support( 'editor-font-sizes' );
     288                $tiny = array(
     289                        'name' => 'Tiny',
     290                        'size' => 8,
     291                        'slug' => 'tiny',
     292                );
     293                add_theme_support( 'editor-font-sizes', array( $tiny ) );
     294                $response = self::perform_active_theme_request();
     295                $result   = $response->get_data();
     296                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     297                $this->assertEquals( array( $tiny ), $result[0]['theme_supports']['editor-font-sizes'] );
     298        }
     299
     300        /**
     301         * Test when a theme doesn't support a custom color palette.
     302         *
     303         * @ticket 48798
     304         */
     305        public function test_theme_supports_editor_color_palette_false() {
     306                remove_theme_support( 'editor-color-palette' );
     307                $response = self::perform_active_theme_request();
     308                $result   = $response->get_data();
     309                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     310                $this->assertTrue( isset( $result[0]['theme_supports']['editor-color-palette'] ) );
     311                $this->assertFalse( $result[0]['theme_supports']['editor-color-palette'] );
     312        }
     313
     314        /**
     315         * Test when a theme supports a custom color palette.
     316         *
     317         * @ticket 48798
     318         */
     319        public function test_theme_supports_editor_color_palette_array() {
     320                remove_theme_support( 'editor-color-palette' );
     321                $wordpress_blue = array(
     322                        'name'  => 'WordPress Blue',
     323                        'slug'  => 'wordpress-blue',
     324                        'color' => '#0073AA',
     325                );
     326                add_theme_support( 'editor-color-palette', array( $wordpress_blue ) );
     327                $response = self::perform_active_theme_request();
     328                $result   = $response->get_data();
     329                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     330                $this->assertEquals( array( $wordpress_blue ), $result[0]['theme_supports']['editor-color-palette'] );
     331        }
     332
     333        /**
     334         * Test when a theme enables automatic feed links.
     335         *
     336         * @ticket 49037
     337         */
     338        public function test_theme_supports_enable_automatic_feed_links() {
     339                remove_theme_support( 'automatic-feed-links' );
     340                add_theme_support( 'automatic-feed-links' );
     341                $response = self::perform_active_theme_request();
     342                $result   = $response->get_data();
     343                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     344                $this->assertTrue( $result[0]['theme_supports']['automatic-feed-links'] );
     345        }
     346
     347        /**
     348         * Test when a theme does not enable automatic feed links.
     349         *
     350         * @ticket 49037
     351         */
     352        public function test_theme_supports_does_not_enable_automatic_feed_links() {
     353                remove_theme_support( 'automatic-feed-links' );
     354                $response = self::perform_active_theme_request();
     355                $result   = $response->get_data();
     356                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     357                $this->assertTrue( isset( $result[0]['theme_supports']['automatic-feed-links'] ) );
     358                $this->assertFalse( $result[0]['theme_supports']['automatic-feed-links'] );
     359        }
     360
     361        /**
     362         * Test when a theme doesn't support a custom logo.
     363         *
     364         * @ticket 49037
     365         */
     366        public function test_theme_does_not_support_custom_logo() {
     367                remove_theme_support( 'custom-logo' );
     368                $response = self::perform_active_theme_request();
     369                $result   = $response->get_data();
     370                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     371                $this->assertTrue( isset( $result[0]['theme_supports']['custom-logo'] ) );
     372                $this->assertFalse( $result[0]['theme_supports']['custom-logo'] );
     373        }
     374
     375        /**
     376         * Test when a theme supports a custom logo.
     377         *
     378         * @ticket 49037
     379         */
     380        public function test_theme_supports_custom_logo() {
     381                remove_theme_support( 'custom-logo' );
     382                $wordpress_logo = array(
     383                        'height'      => 100,
     384                        'width'       => 400,
     385                        'flex-height' => true,
     386                        'flex-width'  => true,
     387                        'header-text' => array( 'site-title', 'site-description' ),
     388                );
     389                add_theme_support( 'custom-logo', $wordpress_logo );
     390                $response = self::perform_active_theme_request();
     391                $result   = $response->get_data();
     392                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     393                $this->assertEquals( $wordpress_logo, $result[0]['theme_supports']['custom-logo'] );
     394        }
     395
     396        /**
     397         * Test when a theme doesn't support a custom header.
     398         *
     399         * @ticket 49037
     400         */
     401        public function test_theme_does_not_support_custom_header() {
     402                remove_theme_support( 'custom-header' );
     403                $response = self::perform_active_theme_request();
     404                $result   = $response->get_data();
     405                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     406                $this->assertTrue( isset( $result[0]['theme_supports']['custom-header'] ) );
     407                $this->assertFalse( $result[0]['theme_supports']['custom-header'] );
     408        }
     409
     410        /**
     411         * Test when a theme supports a custom header.
     412         *
     413         * @ticket 49037
     414         */
     415        public function test_theme_supports_custom_header() {
     416                remove_theme_support( 'custom-header' );
     417                $wordpress_header = array(
     418                        'default-image'          => '',
     419                        'random-default'         => false,
     420                        'width'                  => 0,
     421                        'height'                 => 0,
     422                        'flex-height'            => false,
     423                        'flex-width'             => false,
     424                        'default-text-color'     => '',
     425                        'header-text'            => true,
     426                        'uploads'                => true,
     427                        'wp-head-callback'       => '',
     428                        'admin-head-callback'    => '',
     429                        'admin-preview-callback' => '',
     430                        'video'                  => false,
     431                        'video-active-callback'  => 'is_front_page',
     432                );
     433                add_theme_support( 'custom-header', $wordpress_header );
     434                $response = self::perform_active_theme_request();
     435                $result   = $response->get_data();
     436                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     437                $this->assertEquals( $wordpress_header, $result[0]['theme_supports']['custom-header'] );
     438        }
     439
     440        /**
     441         * Test when a theme doesn't support html5 markup.
     442         *
     443         * @ticket 49037
     444         */
     445        public function test_theme_does_not_support_html5() {
     446                remove_theme_support( 'html5' );
     447                $response = self::perform_active_theme_request();
     448                $result   = $response->get_data();
     449                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     450                $this->assertTrue( isset( $result[0]['theme_supports']['html5'] ) );
     451                $this->assertFalse( $result[0]['theme_supports']['html5'] );
     452        }
     453
     454        /**
     455         * Test when a theme supports html5 markup.
     456         *
     457         * @ticket 49037
     458         */
     459        public function test_theme_supports_html5() {
     460                remove_theme_support( 'html5' );
     461                $html5 = array(
     462                        'search-form',
     463                        'comment-form',
     464                        'comment-list',
     465                        'gallery',
     466                        'caption',
     467                        'script',
     468                        'style',
     469                );
     470                add_theme_support( 'html5', $html5 );
     471                $response = self::perform_active_theme_request();
     472                $result   = $response->get_data();
     473                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     474                $this->assertEquals( $html5, $result[0]['theme_supports']['html5'] );
     475        }
     476
     477        /**
     478         * Test when a theme cannot manage title tag.
     479         *
     480         * @ticket 49037
     481         */
     482        public function test_theme_cannot_manage_title_tag() {
     483                remove_theme_support( 'title-tag' );
     484                $response = self::perform_active_theme_request();
     485                $result   = $response->get_data();
     486                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     487                $this->assertTrue( isset( $result[0]['theme_supports']['title-tag'] ) );
     488                $this->assertFalse( $result[0]['theme_supports']['title-tag'] );
     489        }
     490
     491        /**
     492         * Test when a theme can manage title tag.
     493         *
     494         * @ticket 49037
     495         */
     496        public function test_theme_can_manage_title_tag() {
     497                global $_wp_theme_features;
     498                $_wp_theme_features['title-tag'] = true;
     499                $response                        = self::perform_active_theme_request();
     500                $result                          = $response->get_data();
     501                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     502                $this->assertTrue( $result[0]['theme_supports']['title-tag'] );
     503        }
     504
     505        /**
     506         * Test when a theme cannot manage Selective Refresh for Widgets.
     507         *
     508         * @ticket 49037
     509         */
     510        public function test_theme_cannot_manage_selective_refresh_for_widgets() {
     511                remove_theme_support( 'customize-selective-refresh-widgets' );
     512                $response = self::perform_active_theme_request();
     513                $result   = $response->get_data();
     514                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     515                $this->assertTrue( isset( $result[0]['theme_supports']['customize-selective-refresh-widgets'] ) );
     516                $this->assertFalse( $result[0]['theme_supports']['customize-selective-refresh-widgets'] );
     517        }
     518
     519        /**
     520         * Test when a theme can mange Selective Refresh for Widgets.
     521         *
     522         * @ticket 49037
     523         */
     524        public function test_theme_can_manage_selective_refresh_for_widgets() {
     525                remove_theme_support( 'customize-selective-refresh-widgets' );
     526                add_theme_support( 'customize-selective-refresh-widgets' );
     527                $response = self::perform_active_theme_request();
     528                $result   = $response->get_data();
     529                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     530                $this->assertTrue( $result[0]['theme_supports']['customize-selective-refresh-widgets'] );
     531        }
     532
     533        /**
     534         * Test when a theme does not opt in to the default block styles for viewing.
     535         *
     536         * @ticket 49037
     537         */
     538        public function test_theme_no_wp_block_styles() {
     539                remove_theme_support( 'wp-block-styles' );
     540                $response = self::perform_active_theme_request();
     541                $result   = $response->get_data();
     542                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     543                $this->assertTrue( isset( $result[0]['theme_supports']['wp-block-styles'] ) );
     544                $this->assertFalse( $result[0]['theme_supports']['wp-block-styles'] );
     545        }
     546
     547        /**
     548         * Test when a theme opts in to the default block styles for viewing.
     549         *
     550         * @ticket 49037
     551         */
     552        public function test_theme_wp_block_styles_optin() {
     553                remove_theme_support( 'wp-block-styles' );
     554                add_theme_support( 'wp-block-styles' );
     555                $response = self::perform_active_theme_request();
     556                $result   = $response->get_data();
     557                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     558                $this->assertTrue( $result[0]['theme_supports']['wp-block-styles'] );
     559        }
     560
     561        /**
     562         * Test when a theme does not opt in to wide alignment CSS class.
     563         *
     564         * @ticket 49037
     565         */
     566        public function test_theme_no_align_wide() {
     567                remove_theme_support( 'align-wide' );
     568                $response = self::perform_active_theme_request();
     569                $result   = $response->get_data();
     570                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     571                $this->assertTrue( isset( $result[0]['theme_supports']['align-wide'] ) );
     572                $this->assertFalse( $result[0]['theme_supports']['align-wide'] );
     573        }
     574
     575        /**
     576         * Test when a theme opts in to wide alignment CSS class.
     577         *
     578         * @ticket 49037
     579         */
     580        public function test_theme_align_wide_optin() {
     581                remove_theme_support( 'align-wide' );
     582                add_theme_support( 'align-wide' );
     583                $response = self::perform_active_theme_request();
     584                $result   = $response->get_data();
     585                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     586                $this->assertTrue( $result[0]['theme_supports']['align-wide'] );
     587        }
     588
     589        /**
     590         * Test when a theme does not opt in to the editor styles CSS wrapper.
     591         *
     592         * @ticket 49037
     593         */
     594        public function test_theme_no_editor_styles() {
     595                remove_theme_support( 'editor-styles' );
     596                $response = self::perform_active_theme_request();
     597                $result   = $response->get_data();
     598                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     599                $this->assertTrue( isset( $result[0]['theme_supports']['editor-styles'] ) );
     600                $this->assertFalse( $result[0]['theme_supports']['editor-styles'] );
     601        }
     602
     603        /**
     604         * Test when a theme opts in to the editor styles CSS wrapper.
     605         *
     606         * @ticket 49037
     607         */
     608        public function test_theme_editor_styles_optin() {
     609                remove_theme_support( 'editor-styles' );
     610                add_theme_support( 'editor-styles' );
     611                $response = self::perform_active_theme_request();
     612                $result   = $response->get_data();
     613                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     614                $this->assertTrue( $result[0]['theme_supports']['editor-styles'] );
     615        }
     616
     617        /**
     618         * Test when a theme does not opt in to the dark editor style UI.
     619         *
     620         * @ticket 49037
     621         */
     622        public function test_theme_no_dark_editor_style() {
     623                remove_theme_support( 'dark-editor-style' );
     624                $response = self::perform_active_theme_request();
     625                $result   = $response->get_data();
     626                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     627                $this->assertTrue( isset( $result[0]['theme_supports']['dark-editor-style'] ) );
     628                $this->assertFalse( $result[0]['theme_supports']['dark-editor-style'] );
     629        }
     630
     631        /**
     632         * Test when a theme opts in to the dark editor style UI.
     633         *
     634         * @ticket 49037
     635         */
     636        public function test_theme_dark_editor_style_optin() {
     637                remove_theme_support( 'dark-editor-style' );
     638                add_theme_support( 'dark-editor-style' );
     639                $response = self::perform_active_theme_request();
     640                $result   = $response->get_data();
     641                $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     642                $this->assertTrue( $result[0]['theme_supports']['dark-editor-style'] );
    196643        }
    197644
    198645        /**