Ensure that wp-api.js
test fixtures do not change with WP_TESTS_*
constants.
Previously, changing these constants in `wp-tests-config` would cause PHPUnit to regenerate `wp-api-generated.js` with different values. This commit uses the existing mechanism to also "freeze" all values that would change as a result of changing these constants. Fixes #41123. git-svn-id: https://develop.svn.wordpress.org/trunk@41006 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f8efad31f9
commit
0b3663b0a2
@ -375,14 +375,43 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
|
||||
/**
|
||||
* This array contains normalized versions of object IDs and other values
|
||||
* that can change depending on how PHPUnit is executed. For details on
|
||||
* how they were generated, see #39264.
|
||||
* how they were generated, see #41123.
|
||||
*/
|
||||
private static $fixture_replacements = array(
|
||||
'oembeds.html' => '<blockquote class="wp-embedded-content">...</blockquote>',
|
||||
'Schema.name' => 'Test Blog',
|
||||
'Schema.url' => 'http://example.org',
|
||||
'Schema.home' => 'http://example.org',
|
||||
'Schema.routes./._links.self' => 'http://example.org/?rest_route=/',
|
||||
'Schema.routes./oembed/1.0._links.self' => 'http://example.org/?rest_route=/oembed/1.0',
|
||||
'Schema.routes./oembed/1.0/embed._links.self' => 'http://example.org/?rest_route=/oembed/1.0/embed',
|
||||
'Schema.routes./oembed/1.0/proxy._links.self' => 'http://example.org/?rest_route=/oembed/1.0/proxy',
|
||||
'Schema.routes./wp/v2._links.self' => 'http://example.org/?rest_route=/wp/v2',
|
||||
'Schema.routes./wp/v2/posts._links.self' => 'http://example.org/?rest_route=/wp/v2/posts',
|
||||
'Schema.routes./wp/v2/pages._links.self' => 'http://example.org/?rest_route=/wp/v2/pages',
|
||||
'Schema.routes./wp/v2/media._links.self' => 'http://example.org/?rest_route=/wp/v2/media',
|
||||
'Schema.routes./wp/v2/types._links.self' => 'http://example.org/?rest_route=/wp/v2/types',
|
||||
'Schema.routes./wp/v2/statuses._links.self' => 'http://example.org/?rest_route=/wp/v2/statuses',
|
||||
'Schema.routes./wp/v2/taxonomies._links.self' => 'http://example.org/?rest_route=/wp/v2/taxonomies',
|
||||
'Schema.routes./wp/v2/categories._links.self' => 'http://example.org/?rest_route=/wp/v2/categories',
|
||||
'Schema.routes./wp/v2/tags._links.self' => 'http://example.org/?rest_route=/wp/v2/tags',
|
||||
'Schema.routes./wp/v2/users._links.self' => 'http://example.org/?rest_route=/wp/v2/users',
|
||||
'Schema.routes./wp/v2/users/me._links.self' => 'http://example.org/?rest_route=/wp/v2/users/me',
|
||||
'Schema.routes./wp/v2/comments._links.self' => 'http://example.org/?rest_route=/wp/v2/comments',
|
||||
'Schema.routes./wp/v2/settings._links.self' => 'http://example.org/?rest_route=/wp/v2/settings',
|
||||
'oembed.routes./oembed/1.0._links.self' => 'http://example.org/?rest_route=/oembed/1.0',
|
||||
'oembed.routes./oembed/1.0/embed._links.self' => 'http://example.org/?rest_route=/oembed/1.0/embed',
|
||||
'oembed.routes./oembed/1.0/proxy._links.self' => 'http://example.org/?rest_route=/oembed/1.0/proxy',
|
||||
'oembeds.provider_name' => 'Test Blog',
|
||||
'oembeds.provider_url' => 'http://example.org',
|
||||
'oembeds.author_name' => 'Test Blog',
|
||||
'oembeds.author_url' => 'http://example.org',
|
||||
'oembeds.html' => '<blockquote class="wp-embedded-content">...</blockquote>...',
|
||||
'PostsCollection.0.id' => 3,
|
||||
'PostsCollection.0.guid.rendered' => 'http://example.org/?p=3',
|
||||
'PostsCollection.0.link' => 'http://example.org/?p=3',
|
||||
'PostsCollection.0._links.self.0.href' => 'http://example.org/?rest_route=/wp/v2/posts/3',
|
||||
'PostsCollection.0._links.collection.0.href' => 'http://example.org/?rest_route=/wp/v2/posts',
|
||||
'PostsCollection.0._links.about.0.href' => 'http://example.org/?rest_route=/wp/v2/types/post',
|
||||
'PostsCollection.0._links.replies.0.href' => 'http://example.org/?rest_route=%2Fwp%2Fv2%2Fcomments&post=3',
|
||||
'PostsCollection.0._links.version-history.0.href' => 'http://example.org/?rest_route=/wp/v2/posts/3/revisions',
|
||||
'PostsCollection.0._links.wp:attachment.0.href' => 'http://example.org/?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3',
|
||||
@ -406,6 +435,8 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
|
||||
'PagesCollection.0.guid.rendered' => 'http://example.org/?page_id=5',
|
||||
'PagesCollection.0.link' => 'http://example.org/?page_id=5',
|
||||
'PagesCollection.0._links.self.0.href' => 'http://example.org/?rest_route=/wp/v2/pages/5',
|
||||
'PagesCollection.0._links.collection.0.href' => 'http://example.org/?rest_route=/wp/v2/pages',
|
||||
'PagesCollection.0._links.about.0.href' => 'http://example.org/?rest_route=/wp/v2/types/page',
|
||||
'PagesCollection.0._links.replies.0.href' => 'http://example.org/?rest_route=%2Fwp%2Fv2%2Fcomments&post=5',
|
||||
'PagesCollection.0._links.version-history.0.href' => 'http://example.org/?rest_route=/wp/v2/pages/5/revisions',
|
||||
'PagesCollection.0._links.wp:attachment.0.href' => 'http://example.org/?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5',
|
||||
@ -426,18 +457,57 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
|
||||
'MediaCollection.0.id' => 7,
|
||||
'MediaCollection.0.guid.rendered' => 'http://example.org/?attachment_id=7',
|
||||
'MediaCollection.0.link' => 'http://example.org/?attachment_id=7',
|
||||
'MediaCollection.0.description.rendered' => '<p class="attachment"><!-- <a...><img.../></a> --></p>',
|
||||
'MediaCollection.0.source_url' => 'http://example.org/wp-content/uploads//tmp/canola.jpg',
|
||||
'MediaCollection.0._links.self.0.href' => 'http://example.org/?rest_route=/wp/v2/media/7',
|
||||
'MediaCollection.0._links.collection.0.href' => 'http://example.org/?rest_route=/wp/v2/media',
|
||||
'MediaCollection.0._links.about.0.href' => 'http://example.org/?rest_route=/wp/v2/types/attachment',
|
||||
'MediaCollection.0._links.replies.0.href' => 'http://example.org/?rest_route=%2Fwp%2Fv2%2Fcomments&post=7',
|
||||
'MediaModel.id' => 7,
|
||||
'MediaModel.guid.rendered' => 'http://example.org/?attachment_id=7',
|
||||
'MediaModel.link' => 'http://example.org/?attachment_id=7',
|
||||
'MediaModel.description.rendered' => '<p class="attachment"><!-- <a...><img.../></a> --></p>',
|
||||
'MediaModel.source_url' => 'http://example.org/wp-content/uploads//tmp/canola.jpg',
|
||||
'TypesCollection.post._links.collection.0.href' => 'http://example.org/?rest_route=/wp/v2/types',
|
||||
'TypesCollection.post._links.wp:items.0.href' => 'http://example.org/?rest_route=/wp/v2/posts',
|
||||
'TypesCollection.page._links.collection.0.href' => 'http://example.org/?rest_route=/wp/v2/types',
|
||||
'TypesCollection.page._links.wp:items.0.href' => 'http://example.org/?rest_route=/wp/v2/pages',
|
||||
'TypesCollection.attachment._links.collection.0.href' => 'http://example.org/?rest_route=/wp/v2/types',
|
||||
'TypesCollection.attachment._links.wp:items.0.href' => 'http://example.org/?rest_route=/wp/v2/media',
|
||||
'StatusesCollection.publish._links.archives.0.href' => 'http://example.org/?rest_route=/wp/v2/posts',
|
||||
'StatusesCollection.future._links.archives.0.href' => 'http://example.org/?rest_route=%2Fwp%2Fv2%2Fposts&status=future',
|
||||
'StatusesCollection.draft._links.archives.0.href' => 'http://example.org/?rest_route=%2Fwp%2Fv2%2Fposts&status=draft',
|
||||
'StatusesCollection.pending._links.archives.0.href' => 'http://example.org/?rest_route=%2Fwp%2Fv2%2Fposts&status=pending',
|
||||
'StatusesCollection.private._links.archives.0.href' => 'http://example.org/?rest_route=%2Fwp%2Fv2%2Fposts&status=private',
|
||||
'StatusesCollection.trash._links.archives.0.href' => 'http://example.org/?rest_route=%2Fwp%2Fv2%2Fposts&status=trash',
|
||||
'TaxonomiesCollection.category._links.collection.0.href' => 'http://example.org/?rest_route=/wp/v2/taxonomies',
|
||||
'TaxonomiesCollection.category._links.wp:items.0.href' => 'http://example.org/?rest_route=/wp/v2/categories',
|
||||
'TaxonomiesCollection.post_tag._links.collection.0.href' => 'http://example.org/?rest_route=/wp/v2/taxonomies',
|
||||
'TaxonomiesCollection.post_tag._links.wp:items.0.href' => 'http://example.org/?rest_route=/wp/v2/tags',
|
||||
'CategoriesCollection.0.link' => 'http://example.org/?cat=1',
|
||||
'CategoriesCollection.0._links.self.0.href' => 'http://example.org/?rest_route=/wp/v2/categories/1',
|
||||
'CategoriesCollection.0._links.collection.0.href' => 'http://example.org/?rest_route=/wp/v2/categories',
|
||||
'CategoriesCollection.0._links.about.0.href' => 'http://example.org/?rest_route=/wp/v2/taxonomies/category',
|
||||
'CategoriesCollection.0._links.wp:post_type.0.href' => 'http://example.org/?rest_route=%2Fwp%2Fv2%2Fposts&categories=1',
|
||||
'CategoryModel.link' => 'http://example.org/?cat=1',
|
||||
'TagsCollection.0.id' => 2,
|
||||
'TagsCollection.0.link' => 'http://example.org/?tag=restapi-client-fixture-tag',
|
||||
'TagsCollection.0._links.self.0.href' => 'http://example.org/?rest_route=/wp/v2/tags/2',
|
||||
'TagsCollection.0._links.collection.0.href' => 'http://example.org/?rest_route=/wp/v2/tags',
|
||||
'TagsCollection.0._links.about.0.href' => 'http://example.org/?rest_route=/wp/v2/taxonomies/post_tag',
|
||||
'TagsCollection.0._links.wp:post_type.0.href' => 'http://example.org/?rest_route=%2Fwp%2Fv2%2Fposts&tags=2',
|
||||
'TagModel.id' => 2,
|
||||
'TagModel.link' => 'http://example.org/?tag=restapi-client-fixture-tag',
|
||||
'UsersCollection.0.link' => 'http://example.org/?author=1',
|
||||
'UsersCollection.0.avatar_urls.24' => 'http://0.gravatar.com/avatar/96614ec98aa0c0d2ee75796dced6df54?s=24&d=mm&r=g',
|
||||
'UsersCollection.0.avatar_urls.48' => 'http://0.gravatar.com/avatar/96614ec98aa0c0d2ee75796dced6df54?s=48&d=mm&r=g',
|
||||
'UsersCollection.0.avatar_urls.96' => 'http://0.gravatar.com/avatar/96614ec98aa0c0d2ee75796dced6df54?s=96&d=mm&r=g',
|
||||
'UsersCollection.0._links.self.0.href' => 'http://example.org/?rest_route=/wp/v2/users/1',
|
||||
'UsersCollection.0._links.collection.0.href' => 'http://example.org/?rest_route=/wp/v2/users',
|
||||
'UsersCollection.1.id' => 2,
|
||||
'UsersCollection.1.link' => 'http://example.org/?author=2',
|
||||
'UsersCollection.1._links.self.0.href' => 'http://example.org/?rest_route=/wp/v2/users/2',
|
||||
'UsersCollection.1._links.collection.0.href' => 'http://example.org/?rest_route=/wp/v2/users',
|
||||
'UserModel.id' => 2,
|
||||
'UserModel.link' => 'http://example.org/?author=2',
|
||||
'me.id' => 2,
|
||||
@ -446,10 +516,14 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
|
||||
'CommentsCollection.0.post' => 3,
|
||||
'CommentsCollection.0.link' => 'http://example.org/?p=3#comment-2',
|
||||
'CommentsCollection.0._links.self.0.href' => 'http://example.org/?rest_route=/wp/v2/comments/2',
|
||||
'CommentsCollection.0._links.collection.0.href' => 'http://example.org/?rest_route=/wp/v2/comments',
|
||||
'CommentsCollection.0._links.up.0.href' => 'http://example.org/?rest_route=/wp/v2/posts/3',
|
||||
'CommentModel.id' => 2,
|
||||
'CommentModel.post' => 3,
|
||||
'CommentModel.link' => 'http://example.org/?p=3#comment-2',
|
||||
'settings.title' => 'Test Blog',
|
||||
'settings.url' => 'http://example.org',
|
||||
'settings.email' => 'admin@example.org',
|
||||
);
|
||||
|
||||
private function normalize_fixture( $data, $path ) {
|
||||
|
@ -3510,7 +3510,7 @@ mockedApiResponse.oembeds = {
|
||||
"type": "rich",
|
||||
"width": 600,
|
||||
"height": 338,
|
||||
"html": "<blockquote class=\"wp-embedded-content\">...</blockquote>"
|
||||
"html": "<blockquote class=\"wp-embedded-content\">...</blockquote>..."
|
||||
};
|
||||
|
||||
mockedApiResponse.oembedProxy = {
|
||||
@ -3901,7 +3901,7 @@ mockedApiResponse.MediaCollection = [
|
||||
"template": "",
|
||||
"meta": [],
|
||||
"description": {
|
||||
"rendered": "<p class=\"attachment\"><a href='http://example.org/wp-content/uploads//tmp/canola.jpg'><img width=\"1\" height=\"1\" src=\"http://example.org/wp-content/uploads//tmp/canola.jpg\" class=\"attachment-medium size-medium\" alt=\"\" /></a></p>\n"
|
||||
"rendered": "<p class=\"attachment\"><!-- <a...><img.../></a> --></p>"
|
||||
},
|
||||
"caption": {
|
||||
"rendered": "<p>A sample caption</p>\n"
|
||||
@ -3960,7 +3960,7 @@ mockedApiResponse.MediaModel = {
|
||||
"template": "",
|
||||
"meta": [],
|
||||
"description": {
|
||||
"rendered": "<p class=\"attachment\"><a href='http://example.org/wp-content/uploads//tmp/canola.jpg'><img width=\"1\" height=\"1\" src=\"http://example.org/wp-content/uploads//tmp/canola.jpg\" class=\"attachment-medium size-medium\" alt=\"\" /></a></p>\n"
|
||||
"rendered": "<p class=\"attachment\"><!-- <a...><img.../></a> --></p>"
|
||||
},
|
||||
"caption": {
|
||||
"rendered": "<p>A sample caption</p>\n"
|
||||
|
Loading…
Reference in New Issue
Block a user