Block Editor: Fix unit tests after new blocks addition.

- Regenerate the REST API fixtures.
 - Remove the block registration hooks in the unit tests.

Refs #46429.


git-svn-id: https://develop.svn.wordpress.org/trunk@44812 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Riad Benguella 2019-03-07 11:53:15 +00:00
parent 0ad7b1a169
commit ccfb76d26f
4 changed files with 169 additions and 1 deletions

View File

@ -549,7 +549,7 @@ function wp_default_packages_inline_scripts( &$scripts ) {
' wp.data',
' .use( wp.data.plugins.persistence, { storageKey: storageKey } )',
' .use( wp.data.plugins.controls );',
' wp.data.plugins.persistence.__unstableMigrate( { storageKey: storageKey } );',
' wp.data.plugins.persistence.__unstableMigrate( { storageKey: storageKey } );',
'} )();',
)
)

View File

@ -237,8 +237,12 @@ tests_add_filter( 'send_auth_cookies', '__return_false' );
*/
function _unhook_block_registration() {
remove_action( 'init', 'register_block_core_archives' );
remove_action( 'init', 'register_block_core_calendar' );
remove_action( 'init', 'register_block_core_categories' );
remove_action( 'init', 'register_block_core_latest_posts' );
remove_action( 'init', 'register_block_core_rss' );
remove_action( 'init', 'register_block_core_search' );
remove_action( 'init', 'register_block_core_shortcode' );
remove_action( 'init', 'register_block_core_tag_cloud' );
}
tests_add_filter( 'init', '_unhook_block_registration', 1000 );

View File

@ -122,9 +122,13 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
'/wp/v2/block-renderer/(?P<name>core/block)',
'/wp/v2/block-renderer/(?P<name>core/latest-comments)',
'/wp/v2/block-renderer/(?P<name>core/archives)',
'/wp/v2/block-renderer/(?P<name>core/calendar)',
'/wp/v2/block-renderer/(?P<name>core/categories)',
'/wp/v2/block-renderer/(?P<name>core/latest-posts)',
'/wp/v2/block-renderer/(?P<name>core/rss)',
'/wp/v2/block-renderer/(?P<name>core/search)',
'/wp/v2/block-renderer/(?P<name>core/shortcode)',
'/wp/v2/block-renderer/(?P<name>core/tag-cloud)',
'/wp/v2/settings',
'/wp/v2/themes',
);

View File

@ -4410,6 +4410,46 @@ mockedApiResponse.Schema = {
}
]
},
"/wp/v2/block-renderer/(?P<name>core/calendar)": {
"namespace": "wp/v2",
"methods": [
"GET"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"name": {
"required": false,
"description": "Unique registered name for the block.",
"type": "string"
},
"context": {
"required": false,
"default": "view",
"enum": [
"edit"
],
"description": "Scope under which the request is made; determines fields present in response.",
"type": "string"
},
"attributes": {
"required": false,
"default": [],
"description": "Attributes for core/calendar block",
"type": "object"
},
"post_id": {
"required": false,
"description": "ID of the post context.",
"type": "integer"
}
}
}
]
},
"/wp/v2/block-renderer/(?P<name>core/categories)": {
"namespace": "wp/v2",
"methods": [
@ -4490,6 +4530,86 @@ mockedApiResponse.Schema = {
}
]
},
"/wp/v2/block-renderer/(?P<name>core/rss)": {
"namespace": "wp/v2",
"methods": [
"GET"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"name": {
"required": false,
"description": "Unique registered name for the block.",
"type": "string"
},
"context": {
"required": false,
"default": "view",
"enum": [
"edit"
],
"description": "Scope under which the request is made; determines fields present in response.",
"type": "string"
},
"attributes": {
"required": false,
"default": [],
"description": "Attributes for core/rss block",
"type": "object"
},
"post_id": {
"required": false,
"description": "ID of the post context.",
"type": "integer"
}
}
}
]
},
"/wp/v2/block-renderer/(?P<name>core/search)": {
"namespace": "wp/v2",
"methods": [
"GET"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"name": {
"required": false,
"description": "Unique registered name for the block.",
"type": "string"
},
"context": {
"required": false,
"default": "view",
"enum": [
"edit"
],
"description": "Scope under which the request is made; determines fields present in response.",
"type": "string"
},
"attributes": {
"required": false,
"default": [],
"description": "Attributes for core/search block",
"type": "object"
},
"post_id": {
"required": false,
"description": "ID of the post context.",
"type": "integer"
}
}
}
]
},
"/wp/v2/block-renderer/(?P<name>core/shortcode)": {
"namespace": "wp/v2",
"methods": [
@ -4530,6 +4650,46 @@ mockedApiResponse.Schema = {
}
]
},
"/wp/v2/block-renderer/(?P<name>core/tag-cloud)": {
"namespace": "wp/v2",
"methods": [
"GET"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"name": {
"required": false,
"description": "Unique registered name for the block.",
"type": "string"
},
"context": {
"required": false,
"default": "view",
"enum": [
"edit"
],
"description": "Scope under which the request is made; determines fields present in response.",
"type": "string"
},
"attributes": {
"required": false,
"default": [],
"description": "Attributes for core/tag-cloud block",
"type": "object"
},
"post_id": {
"required": false,
"description": "ID of the post context.",
"type": "integer"
}
}
}
]
},
"/wp/v2/settings": {
"namespace": "wp/v2",
"methods": [