You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
core/content: align the content tests with the instance classes and core
Drive the Content and Show_In_Abilities tests through instances (held on the
test case so the same instance detaches its hooks on tear down) instead of the
old static calls. Bring ContentTest in line with core's wpRegisterCoreContentAbility:
assert show_in_rest + destructive/idempotent annotations on registration, assert
the input schema type and additionalProperties, add output-schema coverage, and
add a test that a post type registered by another active plugin (flagged
show_in_abilities) is exposed in the input enum and in query results.
@@ -85,6 +100,32 @@ private function ensure_content_category(): void {
85
100
}
86
101
}
87
102
103
+
/**
104
+
* Ensures the `site` ability category exists, used by the plugin's `core/settings`
105
+
* ability which registers on the same hook as `core/content`.
106
+
*
107
+
* @since x.x.x
108
+
*/
109
+
privatefunctionensure_site_category(): void {
110
+
if ( wp_has_ability_category( 'site' ) ) {
111
+
return;
112
+
}
113
+
114
+
global$wp_current_filter;
115
+
$wp_current_filter[] = 'wp_abilities_api_categories_init'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Faking the action context to register within it.
116
+
try {
117
+
wp_register_ability_category(
118
+
'site',
119
+
array(
120
+
'label' => 'Site',
121
+
'description' => 'Site.',
122
+
)
123
+
);
124
+
} finally {
125
+
array_pop( $wp_current_filter );
126
+
}
127
+
}
128
+
88
129
/**
89
130
* Registers the plugin's core/content ability inside a faked init action.
90
131
*
@@ -94,7 +135,7 @@ private function register_ability(): void {
94
135
global$wp_current_filter;
95
136
$wp_current_filter[] = 'wp_abilities_api_init'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Faking the action context to register within it.
96
137
try {
97
-
Content::register();
138
+
( newContent() )->register();
98
139
} finally {
99
140
array_pop( $wp_current_filter );
100
141
}
@@ -125,9 +166,12 @@ public function test_registers_core_content_ability(): void {
0 commit comments