我有一个要测试的应用程序列表(超过1000个应用程序)
function custom_add_postmeta_ordering_args( $sort_args ) {
$orderby_value = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
switch( $orderby_value ) {
// Name your sortby key whatever you'd like; must correspond to the $sortby in the next function
case '_start_date':
$sort_args['orderby'] = 'meta_value';
// Sort by meta_value because we're using alphabetic sorting
$sort_args['order'] = 'desc';
$sort_args['meta_key'] = '_start_date';
// use the meta key you've set for your custom field, i.e., something like "location" or "_wholesale_price"
break;
}
return $sort_args;
}
add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_add_postmeta_ordering_args' );
// Add these new sorting arguments to the sortby options on the frontend
function custom_add_new_postmeta_orderby( $sortby ) {
// Adjust the text as desired
$sortby['_start_date'] = __( 'Sort by start date', 'woocommerce' );
return $sortby;
}
add_filter( 'woocommerce_default_catalog_orderby_options', 'custom_add_new_postmeta_orderby' );
add_filter( 'woocommerce_catalog_orderby', 'custom_add_new_postmeta_orderby' );
我有单元测试
list_of_apps=[app1, app2, app3, ...]
我想对app_to_test列表中的每个应用程序进行单元测试