diff --git a/includes/Admin.php b/includes/Admin.php index e8cd0ac9..033b4f26 100755 --- a/includes/Admin.php +++ b/includes/Admin.php @@ -161,38 +161,6 @@ public function dismiss_new_tc_notice() { $this->ensure_ajax_response( $response ); } - /** - * Decide if the business/agency variant of the onboarding promo text should be shown. - * - * @return bool - */ - private function should_show_business_agency_promo_text() { - $license_data = License::get_license_data(); - $license_key = isset( $license_data->key ) ? strtolower( trim( (string) $license_data->key ) ) : ''; - $license_tier = License::get_license_tier( 0 ); - $raw_tier = isset( $license_data->tier ) ? absint( $license_data->tier ) : 0; - $neve_plan = $this->neve_license_plan(); - - if ( $license_key === '' || $license_key === 'free' ) { - return false; - } - - if ( ! License::has_active_license() || ! $this->has_valid_addons() ) { - return false; - } - - if ( -1 !== $neve_plan ) { - // The normalized Neve plan uses mapped TPC tiers, where Business and Agency are 2 and 3. - return in_array( $neve_plan, array( 2, 3 ), true ); - } - - if ( in_array( $raw_tier, array( 1, 2, 7, 12, 18 ), true ) ) { - return false; - } - - return in_array( $license_tier, array( 2, 3 ), true ); - } - /** * Register hooks to prevent meta cloning for the templates. @@ -837,7 +805,6 @@ private function get_localization() { 'upsellNotifications' => $this->get_upsell_notifications(), 'isValidLicense' => $this->has_valid_addons(), 'licenseTIOB' => License::get_license_data(), - 'onboardingShowProNoticeText' => $this->should_show_business_agency_promo_text(), 'emailSubscribe' => array( 'ajaxURL' => esc_url( admin_url( 'admin-ajax.php' ) ), 'nonce' => wp_create_nonce( 'skip_subscribe_nonce' ), diff --git a/tests/tc-disabled-test.php b/tests/tc-disabled-test.php index 1f4601b3..58b8e956 100644 --- a/tests/tc-disabled-test.php +++ b/tests/tc-disabled-test.php @@ -15,20 +15,11 @@ class TC_Disabled_Test extends \WP_UnitTestCase { private $admin; private $license; - private $neve_pro_license_option; - - public static function set_up_before_class(): void { - parent::set_up_before_class(); - if ( ! defined( 'NEVE_PRO_BASEFILE' ) ) { - define( 'NEVE_PRO_BASEFILE', trailingslashit( sys_get_temp_dir() ) . 'neve-pro-addon/neve-pro-addon.php' ); - } - } public function set_up(): void { parent::set_up(); $this->admin = new Admin(); $this->license = License::get_instance(); - $this->neve_pro_license_option = 'neve_pro_addon_license_data'; } public function tear_down(): void { @@ -36,8 +27,6 @@ public function tear_down(): void { delete_option(Admin::TC_REMOVED_KEY); delete_option(License::LICENSE_DATA_OPTIONS_KEY); delete_option(License::LICENSE_KEY_OPTION_KEY); - delete_option( $this->neve_pro_license_option ); - remove_all_filters( 'product_neve_license_plan' ); } /** @@ -114,195 +103,4 @@ public function test_keeps_tc_with_license_and_templates() { $this->admin->maybe_remove_tc(); $this->assertEquals('no', get_option(Admin::TC_REMOVED_KEY)); } - - /** - * Test that free licenses never show the business/agency onboarding promo text. - * - * @return void - */ - public function test_free_license_excludes_business_agency_onboarding_promo_text() { - $this->set_active_license_data( - array( - 'key' => 'free', - 'tier' => 0, - ) - ); - $this->set_active_neve_pro_addon(); - - $this->assertFalse( $this->invoke_admin_private_method( 'should_show_business_agency_promo_text' ) ); - } - - /** - * Test that personal tiers use the default onboarding promo text. - * - * @return void - */ - public function test_personal_license_does_not_show_business_agency_onboarding_promo_text() { - $this->set_active_license_data( - array( - 'key' => 'personal-license', - 'tier' => 2, - ) - ); - $this->set_active_neve_pro_addon(); - - $this->assertFalse( $this->invoke_admin_private_method( 'should_show_business_agency_promo_text' ) ); - } - - /** - * Test that business tiers show the business/agency onboarding promo text. - * - * @return void - */ - public function test_business_license_shows_business_agency_onboarding_promo_text() { - $this->set_active_license_data( - array( - 'key' => 'business-license', - 'tier' => 4, - ) - ); - $this->set_active_neve_pro_addon(); - - $this->assertTrue( $this->invoke_admin_private_method( 'should_show_business_agency_promo_text' ) ); - } - - /** - * Test that agency tiers show the business/agency onboarding promo text. - * - * @return void - */ - public function test_agency_license_shows_business_agency_onboarding_promo_text() { - $this->set_active_license_data( - array( - 'key' => 'agency-license', - 'tier' => 5, - ) - ); - $this->set_active_neve_pro_addon(); - - $this->assertTrue( $this->invoke_admin_private_method( 'should_show_business_agency_promo_text' ) ); - } - - /** - * Test that Neve category mappings override the TPC tier when deciding the promo text. - * - * @return void - */ - public function test_neve_personal_category_does_not_show_business_agency_onboarding_promo_text() { - $this->set_active_license_data( - array( - 'key' => 'business-license', - 'tier' => 4, - ) - ); - $this->set_active_neve_pro_addon(); - add_filter( - 'product_neve_license_plan', - function () { - return 2; - } - ); - - $this->assertFalse( $this->invoke_admin_private_method( 'should_show_business_agency_promo_text' ) ); - } - - /** - * Test that mapped Neve business plans show the business/agency onboarding promo text. - * - * @return void - */ - public function test_neve_business_category_shows_business_agency_onboarding_promo_text() { - $this->set_active_license_data( - array( - 'key' => 'personal-license', - 'tier' => 1, - ) - ); - $this->set_active_neve_pro_addon(); - add_filter( - 'product_neve_license_plan', - function () { - return 3; - } - ); - - $this->assertTrue( $this->invoke_admin_private_method( 'should_show_business_agency_promo_text' ) ); - } - - /** - * Test that the default Neve plan falls back to the TPC tier. - * - * @return void - */ - public function test_default_neve_plan_falls_back_to_tpc_tier() { - $this->set_active_license_data( - array( - 'key' => 'business-license', - 'tier' => 4, - ) - ); - $this->set_active_neve_pro_addon(); - add_filter( - 'product_neve_license_plan', - function () { - return -1; - } - ); - - $this->assertTrue( $this->invoke_admin_private_method( 'should_show_business_agency_promo_text' ) ); - } - - /** - * Set active TPC license data for onboarding promo tests. - * - * @param array $overrides License data overrides. - * - * @return void - */ - private function set_active_license_data( $overrides = array() ) { - update_option( - License::LICENSE_DATA_OPTIONS_KEY, - (object) array_merge( - array( - 'license' => 'valid', - 'key' => 'test-key', - 'tier' => 0, - ), - $overrides - ) - ); - } - - /** - * Set an active Neve Pro addon license. - * - * @return void - */ - private function set_active_neve_pro_addon() { - update_option( - $this->neve_pro_license_option, - (object) array( - 'license' => 'valid', - ) - ); - } - - /** - * Invoke a private Admin method. - * - * @param string $method_name Method name. - * - * @return mixed - */ - private function invoke_admin_private_method( $method_name ) { - try { - $method = new ReflectionMethod( $this->admin, $method_name ); - } catch ( ReflectionException $exception ) { - $this->fail( sprintf( 'Expected private Admin method "%s" to exist.', $method_name ) ); - } - - $method->setAccessible( true ); - - return $method->invoke( $this->admin ); - } }