@@ -36,7 +36,6 @@ class TestWooCommerceOrdersAutosuggest extends BaseTestCase {
3636 */
3737 public function set_up () {
3838 parent ::set_up ();
39- ElasticPress \Features::factory ()->activate_feature ( 'protected_content ' );
4039 ElasticPress \Features::factory ()->activate_feature ( 'woocommerce ' );
4140
4241 $ this ->woocommerce_feature = ElasticPress \Features::factory ()->get_registered_feature ( 'woocommerce ' );
@@ -46,6 +45,11 @@ public function set_up() {
4645
4746 ElasticPress \Features::factory ()->setup_features ();
4847
48+ ElasticPress \Elasticsearch::factory ()->delete_all_indices ();
49+ ElasticPress \Indexables::factory ()->get ( 'post ' )->put_mapping ();
50+
51+ ElasticPress \Indexables::factory ()->get ( 'post ' )->sync_manager ->reset_sync_queue ();
52+
4953 $ this ->orders_autosuggest = $ this ->woocommerce_feature ->orders_autosuggest ;
5054 }
5155
@@ -438,4 +442,41 @@ public function test_get_setting_help_message_feature_not_available() {
438442 $ new_settings_schema = $ this ->orders_autosuggest ->add_settings_schema ( [] );
439443 $ this ->assertStringContainsString ( 'Due to the sensitive nature of orders ' , $ new_settings_schema [0 ]['help ' ] );
440444 }
445+
446+ /**
447+ * Test shop_order with password is synced without Protected Content feature enabled.
448+ *
449+ * @since 5.3.3
450+ * @group woocommerce
451+ * @group woocommerce-orders-autosuggest
452+ */
453+ public function test_order_with_password_is_synced () {
454+ add_filter ( 'ep_woocommerce_orders_autosuggest_available ' , '__return_true ' );
455+
456+ /**
457+ * Enable the orders autosuggest feature
458+ */
459+ $ filter = function () {
460+ return [
461+ 'woocommerce ' => [
462+ 'orders ' => '1 ' ,
463+ ],
464+ ];
465+ };
466+ add_filter ( 'pre_site_option_ep_feature_settings ' , $ filter );
467+
468+ $ this ->orders_autosuggest ->setup ();
469+
470+ $ order = new \WC_Order ();
471+ $ order ->set_order_key ( '1234567890 ' ); // save in the post_password field
472+ $ order ->save ();
473+
474+ $ order_id = $ order ->get_id ();
475+
476+ ElasticPress \Indexables::factory ()->get ( 'post ' )->index ( $ order_id );
477+ ElasticPress \Elasticsearch::factory ()->refresh_indices ();
478+
479+ $ order = ElasticPress \Indexables::factory ()->get ( 'post ' )->get ( $ order_id );
480+ $ this ->assertNotEmpty ( $ order );
481+ }
441482}
0 commit comments