@@ -125,6 +125,38 @@ mod tests {
125
125
validate_endpoint ( plugins_endpoint. list ( context, Some ( & params) ) , expected_path) ;
126
126
}
127
127
128
+ #[ rstest]
129
+ #[ case(
130
+ WPContext :: Edit ,
131
+ generate!( PluginListParams , ( search, Some ( "foo" . to_string( ) ) ) ) ,
132
+ & [ SparsePluginField :: Author ] ,
133
+ "/plugins?context=edit&search=foo&_fields=author"
134
+ ) ]
135
+ #[ case(
136
+ WPContext :: Embed ,
137
+ generate!( PluginListParams , ( status, Some ( PluginStatus :: Active ) ) ) ,
138
+ & [ SparsePluginField :: Name , SparsePluginField :: PluginUri ] ,
139
+ "/plugins?context=embed&status=active&_fields=name%2Cplugin_uri"
140
+ ) ]
141
+ #[ case(
142
+ WPContext :: View ,
143
+ generate!( PluginListParams , ( search, Some ( "foo" . to_string( ) ) ) , ( status, Some ( PluginStatus :: Inactive ) ) ) ,
144
+ & [ SparsePluginField :: NetworkOnly , SparsePluginField :: RequiresPhp , SparsePluginField :: Textdomain ] ,
145
+ "/plugins?context=view&search=foo&status=inactive&_fields=network_only%2Crequires_php%2Ctextdomain"
146
+ ) ]
147
+ fn filter_list_plugins_with_params (
148
+ plugins_endpoint : PluginsEndpoint ,
149
+ #[ case] context : WPContext ,
150
+ #[ case] params : PluginListParams ,
151
+ #[ case] fields : & [ SparsePluginField ] ,
152
+ #[ case] expected_path : & str ,
153
+ ) {
154
+ validate_endpoint (
155
+ plugins_endpoint. filter_list ( context, Some ( & params) , fields) ,
156
+ expected_path,
157
+ ) ;
158
+ }
159
+
128
160
#[ rstest]
129
161
#[ case(
130
162
"hello-dolly/hello" . into( ) ,
@@ -154,6 +186,44 @@ mod tests {
154
186
) ;
155
187
}
156
188
189
+ #[ rstest]
190
+ #[ case(
191
+ "hello-dolly/hello" . into( ) ,
192
+ WPContext :: View ,
193
+ & [ SparsePluginField :: Name ] ,
194
+ "/plugins/hello-dolly/hello?context=view&_fields=name"
195
+ ) ]
196
+ #[ case(
197
+ "classic-editor/classic-editor" . into( ) ,
198
+ WPContext :: Embed ,
199
+ & [ SparsePluginField :: Description , SparsePluginField :: Plugin ] ,
200
+ "/plugins/classic-editor/classic-editor?context=embed&_fields=description%2Cplugin"
201
+ ) ]
202
+ #[ case(
203
+ "foo/bar%baz" . into( ) ,
204
+ WPContext :: Edit ,
205
+ & [ SparsePluginField :: Status , SparsePluginField :: Version ] ,
206
+ "/plugins/foo/bar%25baz?context=edit&_fields=status%2Cversion"
207
+ ) ]
208
+ #[ case(
209
+ "foo/です" . into( ) ,
210
+ WPContext :: View ,
211
+ & [ SparsePluginField :: NetworkOnly , SparsePluginField :: RequiresPhp , SparsePluginField :: Textdomain ] ,
212
+ "/plugins/foo/%E3%81%A7%E3%81%99?context=view&_fields=network_only%2Crequires_php%2Ctextdomain"
213
+ ) ]
214
+ fn filter_retrieve_plugin (
215
+ plugins_endpoint : PluginsEndpoint ,
216
+ #[ case] plugin_slug : PluginSlug ,
217
+ #[ case] context : WPContext ,
218
+ #[ case] fields : & [ SparsePluginField ] ,
219
+ #[ case] expected_path : & str ,
220
+ ) {
221
+ validate_endpoint (
222
+ plugins_endpoint. filter_retrieve ( context, & plugin_slug, fields) ,
223
+ expected_path,
224
+ ) ;
225
+ }
226
+
157
227
#[ rstest]
158
228
#[ case( "hello-dolly/hello" . into( ) , "/plugins/hello-dolly/hello" ) ]
159
229
#[ case(
0 commit comments