diff --git a/projects/plugins/wpcomsh/changelog/add-wpcom-features-edge-rules b/projects/plugins/wpcomsh/changelog/add-wpcom-features-edge-rules new file mode 100644 index 000000000000..659b4a199e50 --- /dev/null +++ b/projects/plugins/wpcomsh/changelog/add-wpcom-features-edge-rules @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +Features: Add the edge-rules feature for paid Business and Commerce plans. diff --git a/projects/plugins/wpcomsh/tests/WpcomFeaturesMapTest.php b/projects/plugins/wpcomsh/tests/WpcomFeaturesMapTest.php index 8d13a6f35e77..862e6531e448 100644 --- a/projects/plugins/wpcomsh/tests/WpcomFeaturesMapTest.php +++ b/projects/plugins/wpcomsh/tests/WpcomFeaturesMapTest.php @@ -248,6 +248,37 @@ public static function woo_bundle_extensions_plan_provider() { ); } + /** + * Catches a map entry widened to WPCOM_BUSINESS_PLANS, which would also grant the trials and Student. + * + * @dataProvider edge_rules_plan_provider + * @param string $slug Product slug. + * @param bool $expected Whether the plan grants Edge Rules. + */ + #[DataProvider( 'edge_rules_plan_provider' )] + public function test_edge_rules_needs_a_paid_business_or_commerce_plan( $slug, $expected ) { + $purchases = array( $this->purchase( $slug ) ); + + $this->assertSame( $expected, WPCOM_Features::has_feature( WPCOM_Features::EDGE_RULES, $purchases, 'wpcom' ) ); + } + + /** + * Plans checked for Edge Rules. + * + * @return array + */ + public static function edge_rules_plan_provider() { + return array( + 'business' => array( 'business-bundle', true ), + 'commerce' => array( 'ecommerce-bundle', true ), + 'premium' => array( 'value_bundle', false ), + 'pro' => array( 'pro-plan', false ), + 'hosting trial' => array( 'wp_bundle_hosting_trial_monthly', false ), + 'commerce trial' => array( 'ecommerce-trial-bundle-monthly', false ), + 'student' => array( 'wp_bundle_student_yearly', false ), + ); + } + public function test_sticker_not_present_withdraws_the_definition_once_the_sticker_lands() { $map = array( array( diff --git a/projects/plugins/wpcomsh/wpcom-features/class-wpcom-features.php b/projects/plugins/wpcomsh/wpcom-features/class-wpcom-features.php index 9b03cb0ce5e8..f0d2c36eaa79 100644 --- a/projects/plugins/wpcomsh/wpcom-features/class-wpcom-features.php +++ b/projects/plugins/wpcomsh/wpcom-features/class-wpcom-features.php @@ -463,6 +463,7 @@ class WPCOM_Features { public const ECOMMERCE_MANAGED_PLUGINS_SMALL = 'ecommerce-managed-plugins-small'; public const ECOMMERCE_MANAGED_PLUGINS_MEDIUM = 'ecommerce-managed-plugins-medium'; public const ECOMMERCE_MANAGED_PLUGINS_TRIAL = 'ecommerce-managed-plugins-trial'; + public const EDGE_RULES = 'edge-rules'; public const EDIT_PLUGINS = 'edit-plugins'; public const EDIT_THEMES = 'edit-themes'; public const EMAIL_PROFESSIONAL = 'email-professional'; @@ -872,6 +873,9 @@ class WPCOM_Features { self::ECOMMERCE_MANAGED_PLUGINS_TRIAL => array( self::WPCOM_ECOMMERCE_TRIAL_PLANS, ), + self::EDGE_RULES => array( + self::WPCOM_PAID_BUSINESS_AND_COMMERCE_PLANS, + ), // EDIT_PLUGINS - Provides the edit_plugins capability on atomic sites, does nothing on simple sites. self::EDIT_PLUGINS => array( self::WPCOM_PRO_PLANS,