Ticket #45016: 45016.4.diff
File 45016.4.diff, 3.7 KB (added by , 6 years ago) |
---|
-
src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php
111 111 $formats = array_merge( array( 'standard' ), $formats ); 112 112 $data['theme_supports']['formats'] = $formats; 113 113 114 $data['theme_supports']['post-thumbnails'] = false; 115 $post_thumbnails = get_theme_support( 'post-thumbnails' ); 114 $data['theme_supports']['post-thumbnails'] = false; 115 $data['theme_supports']['responsive-embeds'] = (bool) get_theme_support( 'responsive-embeds' ); 116 $post_thumbnails = get_theme_support( 'post-thumbnails' ); 116 117 117 118 if ( $post_thumbnails ) { 118 119 // $post_thumbnails can contain a nested array of post types. … … 156 157 'type' => 'array', 157 158 'readonly' => true, 158 159 'properties' => array( 159 'formats' => array(160 'formats' => array( 160 161 'description' => __( 'Post formats supported.' ), 161 162 'type' => 'array', 162 163 'readonly' => true, 163 164 ), 164 'post-thumbnails' => array(165 'post-thumbnails' => array( 165 166 'description' => __( 'Whether the theme supports post thumbnails.' ), 166 167 'type' => array( 'array', 'bool' ), 167 168 'readonly' => true, 168 169 ), 170 'responsive-embeds' => array( 171 'description' => __( 'Whether the theme supports responsive embedded content.', 'gutenberg' ), 172 'type' => 'bool', 173 'readonly' => true, 174 ), 169 175 ), 170 176 ), 171 177 ), -
tests/phpunit/tests/rest-api/rest-themes-controller.php
189 189 $this->assertEquals( 1, count( $properties ) ); 190 190 $this->assertArrayHasKey( 'theme_supports', $properties ); 191 191 192 $this->assertEquals( 2, count( $properties['theme_supports']['properties'] ) );192 $this->assertEquals( 3, count( $properties['theme_supports']['properties'] ) ); 193 193 $this->assertArrayHasKey( 'formats', $properties['theme_supports']['properties'] ); 194 194 $this->assertArrayHasKey( 'post-thumbnails', $properties['theme_supports']['properties'] ); 195 $this->assertArrayHasKey( 'responsive-embeds', $properties['theme_supports']['properties'] ); 195 196 } 196 197 197 198 /** … … 223 224 } 224 225 225 226 /** 227 * Test when a theme does not support responsive embeds. 228 * 229 * @ticket 45016 230 */ 231 public function test_theme_supports_responsive_embeds_false() { 232 remove_theme_support( 'responsive-embeds' ); 233 $response = self::perform_active_theme_request(); 234 235 $result = $response->get_data(); 236 $this->assertTrue( isset( $result[0]['theme_supports'] ) ); 237 $this->assertTrue( isset( $result[0]['theme_supports']['responsive-embeds'] ) ); 238 $this->assertFalse( $result[0]['theme_supports']['responsive-embeds'] ); 239 } 240 241 /** 242 * Test when a theme supports responsive embeds. 243 * 244 * @ticket 45016 245 */ 246 public function test_theme_supports_responsive_embeds_true() { 247 remove_theme_support( 'responsive-embeds' ); 248 add_theme_support( 'responsive-embeds' ); 249 $response = self::perform_active_theme_request(); 250 $result = $response->get_data(); 251 $this->assertTrue( isset( $result[0]['theme_supports'] ) ); 252 $this->assertTrue( $result[0]['theme_supports']['responsive-embeds'] ); 253 } 254 255 /** 226 256 * Test when a theme does not support post thumbnails. 227 257 * 228 258 * @ticket 45016