Changeset 58326
- Timestamp:
- 06/04/2024 10:21:11 AM (11 months ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
r58065 r58326 1998 1998 $data['generated_slug'] = $sample_permalink[1]; 1999 1999 } 2000 } 2001 2002 if ( rest_is_field_included( 'class_list', $fields ) ) { 2003 $data['class_list'] = get_post_class( array(), $post->ID ); 2000 2004 } 2001 2005 } … … 2354 2358 'readonly' => true, 2355 2359 ); 2360 2361 $schema['properties']['class_list'] = array( 2362 'description' => __( 'An array of the class names for the post container element.' ), 2363 'type' => 'array', 2364 'context' => array( 'view', 'edit' ), 2365 'readonly' => true, 2366 'items' => array( 2367 'type' => 'string', 2368 ), 2369 ); 2356 2370 } 2357 2371 -
trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php
r58130 r58326 1647 1647 $data = $response->get_data(); 1648 1648 $properties = $data['schema']['properties']; 1649 $this->assertCount( 2 8, $properties );1649 $this->assertCount( 29, $properties ); 1650 1650 $this->assertArrayHasKey( 'author', $properties ); 1651 1651 $this->assertArrayHasKey( 'alt_text', $properties ); … … 1682 1682 $this->assertArrayHasKey( 'missing_image_sizes', $properties ); 1683 1683 $this->assertArrayHasKey( 'featured_media', $properties ); 1684 $this->assertArrayHasKey( 'class_list', $properties ); 1684 1685 } 1685 1686 -
trunk/tests/phpunit/tests/rest-api/rest-pages-controller.php
r56547 r58326 749 749 $data = $response->get_data(); 750 750 $properties = $data['schema']['properties']; 751 $this->assertCount( 2 4, $properties );751 $this->assertCount( 25, $properties ); 752 752 $this->assertArrayHasKey( 'author', $properties ); 753 753 $this->assertArrayHasKey( 'comment_status', $properties ); … … 774 774 $this->assertArrayHasKey( 'title', $properties ); 775 775 $this->assertArrayHasKey( 'type', $properties ); 776 $this->assertArrayHasKey( 'class_list', $properties ); 776 777 } 777 778 -
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r58065 r58326 4363 4363 $data = $response->get_data(); 4364 4364 $properties = $data['schema']['properties']; 4365 $this->assertCount( 2 6, $properties );4365 $this->assertCount( 27, $properties ); 4366 4366 $this->assertArrayHasKey( 'author', $properties ); 4367 4367 $this->assertArrayHasKey( 'comment_status', $properties ); … … 4390 4390 $this->assertArrayHasKey( 'tags', $properties ); 4391 4391 $this->assertArrayHasKey( 'categories', $properties ); 4392 $this->assertArrayHasKey( 'class_list', $properties ); 4392 4393 } 4393 4394 … … 4419 4420 'author', 4420 4421 'categories', 4422 'class_list', 4421 4423 'comment_status', 4422 4424 'content', … … 4457 4459 'author', 4458 4460 'categories', 4461 'class_list', 4459 4462 'comment_status', 4460 4463 'content', -
trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php
r58097 r58326 760 760 } 761 761 762 $datetime_keys = array( 'date', 'date_gmt', 'modified', 'modified_gmt' ); 763 762 764 foreach ( $data as $key => $value ) { 763 if ( is_string( $value ) && ( 764 'date' === $key || 765 'date_gmt' === $key || 766 'modified' === $key || 767 'modified_gmt' === $key 768 ) ) { 769 $data[ $key ] = '2017-02-14T00:00:00'; 770 } else { 771 $data[ $key ] = $this->normalize_fixture( $value, "$path.$key" ); 765 if ( is_string( $value ) ) { 766 if ( in_array( $key, $datetime_keys, true ) ) { 767 $data[ $key ] = '2017-02-14T00:00:00'; 768 continue; 769 } 770 771 if ( 1 === preg_match( '/^post-\d+$/', $value ) ) { 772 // Normalize the class value to ensure test stability. 773 $data[ $key ] = 'post-1073'; 774 continue; 775 } 772 776 } 777 778 $data[ $key ] = $this->normalize_fixture( $value, "$path.$key" ); 773 779 } 774 780 -
trunk/tests/qunit/fixtures/wp-api-generated.js
r58283 r58326 12323 12323 ], 12324 12324 "tags": [], 12325 "class_list": [ 12326 "post-1073", 12327 "post", 12328 "type-post", 12329 "status-publish", 12330 "format-standard", 12331 "hentry", 12332 "category-uncategorized" 12333 ], 12325 12334 "_links": { 12326 12335 "self": [ … … 12422 12431 1 12423 12432 ], 12424 "tags": [] 12433 "tags": [], 12434 "class_list": [ 12435 "post-1073", 12436 "post", 12437 "type-post", 12438 "status-publish", 12439 "format-standard", 12440 "hentry", 12441 "category-uncategorized" 12442 ] 12425 12443 }; 12426 12444 … … 12614 12632 "meta_key": "" 12615 12633 }, 12634 "class_list": [ 12635 "post-1073", 12636 "page", 12637 "type-page", 12638 "status-publish", 12639 "hentry" 12640 ], 12616 12641 "_links": { 12617 12642 "self": [ … … 12697 12722 "meta": { 12698 12723 "meta_key": "" 12699 } 12724 }, 12725 "class_list": [ 12726 "post-1073", 12727 "page", 12728 "type-page", 12729 "status-publish", 12730 "hentry" 12731 ] 12700 12732 }; 12701 12733 … … 12879 12911 "meta_key": "" 12880 12912 }, 12913 "class_list": [ 12914 "post-1073", 12915 "attachment", 12916 "type-attachment", 12917 "status-inherit", 12918 "hentry" 12919 ], 12881 12920 "description": { 12882 12921 "rendered": "<p class=\"attachment\"><!-- <a...><img.../></a> --></p>" … … 12941 12980 "meta_key": "" 12942 12981 }, 12982 "class_list": [ 12983 "post-1073", 12984 "attachment", 12985 "type-attachment", 12986 "status-inherit", 12987 "hentry" 12988 ], 12943 12989 "description": { 12944 12990 "rendered": "<p class=\"attachment\"><!-- <a...><img.../></a> --></p>"
Note: See TracChangeset
for help on using the changeset viewer.