Changeset 55951
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php
r53760 r55951 327 327 } 328 328 329 if ( rest_is_field_included( 'is_block_theme', $fields ) ) { 330 $data['is_block_theme'] = $theme->is_block_theme(); 331 } 332 329 333 $data = $this->add_additional_fields_to_object( $data, $request ); 330 334 … … 495 499 ), 496 500 ), 501 'is_block_theme' => array( 502 'description' => __( 'Whether the theme is a block-based theme.' ), 503 'type' => 'boolean', 504 'readonly' => true, 505 ), 497 506 'name' => array( 498 507 'description' => __( 'The name of the theme.' ), -
trunk/tests/phpunit/tests/rest-api/rest-themes-controller.php
r55822 r55951 173 173 'author_uri', 174 174 'description', 175 'is_block_theme', 175 176 'name', 176 177 'requires_php', … … 186 187 'version', 187 188 ); 189 $this->assertIsArray( $data ); 190 $this->assertNotEmpty( $data ); 188 191 $this->assertSameSets( $fields, array_keys( $data[0] ) ); 189 192 } … … 209 212 'author_uri', 210 213 'description', 214 'is_block_theme', 211 215 'name', 212 216 'requires_php', … … 221 225 'version', 222 226 ); 227 $this->assertIsArray( $data ); 228 $this->assertNotEmpty( $data ); 223 229 $this->assertSameSets( $fields, array_keys( $data[0] ) ); 224 230 … … 344 350 $data = $response->get_data(); 345 351 $properties = $data['schema']['properties']; 346 $this->assertCount( 1 5, $properties );352 $this->assertCount( 16, $properties ); 347 353 348 354 $this->assertArrayHasKey( 'author', $properties ); … … 357 363 $this->assertArrayHasKey( 'raw', $properties['description']['properties'] ); 358 364 $this->assertArrayHasKey( 'rendered', $properties['description']['properties'] ); 365 366 $this->assertArrayHasKey( 'is_block_theme', $properties ); 359 367 360 368 $this->assertArrayHasKey( 'name', $properties ); … … 473 481 474 482 /** 483 * @ticket 58123 484 * @covers WP_REST_Themes_Controller::prepare_item_for_response 485 */ 486 public function test_theme_is_block_theme() { 487 // Test classic theme, activated in test setup. 488 $response = self::perform_active_theme_request(); 489 $result = $response->get_data(); 490 491 $this->assertArrayHasKey( 'is_block_theme', $result[0] ); 492 $this->assertFalse( $result[0]['is_block_theme'] ); 493 494 // Test block theme. 495 switch_theme( 'block-theme' ); 496 $response = self::perform_active_theme_request(); 497 $result = $response->get_data(); 498 499 $this->assertArrayHasKey( 'is_block_theme', $result[0] ); 500 $this->assertTrue( $result[0]['is_block_theme'] ); 501 } 502 503 /** 475 504 * @ticket 49906 476 505 */ … … 1235 1264 'author_uri', 1236 1265 'description', 1266 'is_block_theme', 1237 1267 'name', 1238 1268 'requires_php',
Note: See TracChangeset
for help on using the changeset viewer.