Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for WooCommerce #3259

Merged
merged 21 commits into from
Feb 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge branch 'develop' into chore/3219
  • Loading branch information
felipeelia committed Feb 24, 2023
commit 8d654caded76444d8aab4e55f319ab01924007cf
58 changes: 57 additions & 1 deletion tests/php/features/TestWooCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ public function testSearchQueryForCouponWhenProtectedContentIsNotEnable() {
$this->assertEquals( 1, $query->post_count );
}


/**
* Test all the product attributes are synced.
*
Expand Down Expand Up @@ -1027,4 +1026,61 @@ public function testSkuOptionAddInWeightDashboard() {
$this->assertEquals( 'meta._variations_skus.value', $fields['attributes']['children']['meta._variations_skus.value']['key'] );
$this->assertEquals( 'Variations SKUs', $fields['attributes']['children']['meta._variations_skus.value']['label'] );
}

/**
* Test the `is_orders_autosuggest_available` method
*
* @since 4.5.0
*/
public function testIsOrdersAutosuggestAvailable() {
$woocommerce_feature = ElasticPress\Features::factory()->get_registered_feature( 'woocommerce' );

$this->assertSame( $woocommerce_feature->is_orders_autosuggest_available(), \ElasticPress\Utils\is_epio() );

/**
* Test the `ep_woocommerce_orders_autosuggest_available` filter
*/
add_filter( 'ep_woocommerce_orders_autosuggest_available', '__return_true' );
$this->assertTrue( $woocommerce_feature->is_orders_autosuggest_available() );

add_filter( 'ep_woocommerce_orders_autosuggest_available', '__return_false' );
$this->assertFalse( $woocommerce_feature->is_orders_autosuggest_available() );
}

/**
* Test the `is_orders_autosuggest_available` method
*
* @since 4.5.0
*/
public function testIsOrdersAutosuggestEnabled() {
$woocommerce_feature = ElasticPress\Features::factory()->get_registered_feature( 'woocommerce' );

$this->assertFalse( $woocommerce_feature->is_orders_autosuggest_enabled() );

/**
* Make it available but it won't be enabled
*/
add_filter( 'ep_woocommerce_orders_autosuggest_available', '__return_true' );
$this->assertFalse( $woocommerce_feature->is_orders_autosuggest_enabled() );

/**
* Enable it
*/
$filter = function() {
return [
'woocommerce' => [
'orders' => '1',
],
];
};
add_filter( 'pre_site_option_ep_feature_settings', $filter );
add_filter( 'pre_option_ep_feature_settings', $filter );
$this->assertTrue( $woocommerce_feature->is_orders_autosuggest_enabled() );

/**
* Make it unavailable. Even activated, it should not be considered enabled if not available anymore.
*/
remove_filter( 'ep_woocommerce_orders_autosuggest_available', '__return_true' );
$this->assertFalse( $woocommerce_feature->is_orders_autosuggest_enabled() );
}
}
You are viewing a condensed version of this merge commit. You can view the full changes here.