mirror of
git://develop.git.wordpress.org/
synced 2025-01-17 21:08:44 +01:00
REST API: improve code quality for class_list field fixtures.
Follow-up to [58326], #61360. Props antonvlasenko, oandregal. Fixes #61369. git-svn-id: https://develop.svn.wordpress.org/trunk@58340 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
df05478ccb
commit
c4dd762c62
@ -577,6 +577,7 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
|
||||
'oembeds.author_url' => 'http://example.org',
|
||||
'oembeds.html' => '<blockquote class="wp-embedded-content">...</blockquote>...',
|
||||
'PostsCollection.0.id' => 4,
|
||||
'PostsCollection.0.class_list.0' => 'post-4',
|
||||
'PostsCollection.0.guid.rendered' => 'http://example.org/?p=4',
|
||||
'PostsCollection.0.link' => 'http://example.org/?p=4',
|
||||
'PostsCollection.0._links.self.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/posts/4',
|
||||
@ -590,6 +591,7 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
|
||||
'PostsCollection.0._links.wp:term.0.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4',
|
||||
'PostsCollection.0._links.wp:term.1.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4',
|
||||
'PostModel.id' => 4,
|
||||
'PostModel.class_list.0' => 'post-4',
|
||||
'PostModel.guid.rendered' => 'http://example.org/?p=4',
|
||||
'PostModel.link' => 'http://example.org/?p=4',
|
||||
'postRevisions.0.author' => 2,
|
||||
@ -621,6 +623,7 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
|
||||
'autosave.slug' => '4-autosave-v1',
|
||||
'autosave.guid.rendered' => 'http://example.org/?p=6',
|
||||
'PagesCollection.0.id' => 7,
|
||||
'PagesCollection.0.class_list.0' => 'post-7',
|
||||
'PagesCollection.0.guid.rendered' => 'http://example.org/?page_id=7',
|
||||
'PagesCollection.0.link' => 'http://example.org/?page_id=7',
|
||||
'PagesCollection.0._links.self.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/pages/7',
|
||||
@ -632,6 +635,7 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
|
||||
'PagesCollection.0._links.predecessor-version.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/pages/7/revisions/9',
|
||||
'PagesCollection.0._links.wp:attachment.0.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7',
|
||||
'PageModel.id' => 7,
|
||||
'PageModel.class_list.0' => 'post-7',
|
||||
'PageModel.guid.rendered' => 'http://example.org/?page_id=7',
|
||||
'PageModel.link' => 'http://example.org/?page_id=7',
|
||||
'pageRevisions.0.author' => 2,
|
||||
@ -663,6 +667,7 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
|
||||
'pageAutosave.slug' => '7-autosave-v1',
|
||||
'pageAutosave.guid.rendered' => 'http://example.org/?p=9',
|
||||
'MediaCollection.0.id' => 10,
|
||||
'MediaCollection.0.class_list.0' => 'post-10',
|
||||
'MediaCollection.0.guid.rendered' => 'http://example.org/?attachment_id=10',
|
||||
'MediaCollection.0.link' => 'http://example.org/?attachment_id=10',
|
||||
'MediaCollection.0.description.rendered' => '<p class="attachment"><!-- <a...><img.../></a> --></p>',
|
||||
@ -672,6 +677,7 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
|
||||
'MediaCollection.0._links.about.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/types/attachment',
|
||||
'MediaCollection.0._links.replies.0.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10',
|
||||
'MediaModel.id' => 10,
|
||||
'MediaModel.class_list.0' => 'post-10',
|
||||
'MediaModel.guid.rendered' => 'http://example.org/?attachment_id=10',
|
||||
'MediaModel.link' => 'http://example.org/?attachment_id=10',
|
||||
'MediaModel.description.rendered' => '<p class="attachment"><!-- <a...><img.../></a> --></p>',
|
||||
@ -762,17 +768,9 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
|
||||
$datetime_keys = array( 'date', 'date_gmt', 'modified', 'modified_gmt' );
|
||||
|
||||
foreach ( $data as $key => $value ) {
|
||||
if ( is_string( $value ) ) {
|
||||
if ( in_array( $key, $datetime_keys, true ) ) {
|
||||
$data[ $key ] = '2017-02-14T00:00:00';
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( 1 === preg_match( '/^post-\d+$/', $value ) ) {
|
||||
// Normalize the class value to ensure test stability.
|
||||
$data[ $key ] = 'post-1073';
|
||||
continue;
|
||||
}
|
||||
if ( is_string( $value ) && in_array( $key, $datetime_keys, true ) ) {
|
||||
$data[ $key ] = '2017-02-14T00:00:00';
|
||||
continue;
|
||||
}
|
||||
|
||||
$data[ $key ] = $this->normalize_fixture( $value, "$path.$key" );
|
||||
|
@ -12323,7 +12323,7 @@ mockedApiResponse.PostsCollection = [
|
||||
],
|
||||
"tags": [],
|
||||
"class_list": [
|
||||
"post-1073",
|
||||
"post-4",
|
||||
"post",
|
||||
"type-post",
|
||||
"status-publish",
|
||||
@ -12432,7 +12432,7 @@ mockedApiResponse.PostModel = {
|
||||
],
|
||||
"tags": [],
|
||||
"class_list": [
|
||||
"post-1073",
|
||||
"post-4",
|
||||
"post",
|
||||
"type-post",
|
||||
"status-publish",
|
||||
@ -12632,7 +12632,7 @@ mockedApiResponse.PagesCollection = [
|
||||
"meta_key": ""
|
||||
},
|
||||
"class_list": [
|
||||
"post-1073",
|
||||
"post-7",
|
||||
"page",
|
||||
"type-page",
|
||||
"status-publish",
|
||||
@ -12723,7 +12723,7 @@ mockedApiResponse.PageModel = {
|
||||
"meta_key": ""
|
||||
},
|
||||
"class_list": [
|
||||
"post-1073",
|
||||
"post-7",
|
||||
"page",
|
||||
"type-page",
|
||||
"status-publish",
|
||||
@ -12911,7 +12911,7 @@ mockedApiResponse.MediaCollection = [
|
||||
"meta_key": ""
|
||||
},
|
||||
"class_list": [
|
||||
"post-1073",
|
||||
"post-10",
|
||||
"attachment",
|
||||
"type-attachment",
|
||||
"status-inherit",
|
||||
@ -12980,7 +12980,7 @@ mockedApiResponse.MediaModel = {
|
||||
"meta_key": ""
|
||||
},
|
||||
"class_list": [
|
||||
"post-1073",
|
||||
"post-10",
|
||||
"attachment",
|
||||
"type-attachment",
|
||||
"status-inherit",
|
||||
|
Loading…
x
Reference in New Issue
Block a user