@@ -113,38 +113,23 @@ public function test_get_bf_notices_returns_empty_when_not_black_friday() {
113113 $ this ->assertEmpty ( $ result );
114114 }
115115
116- /**
117- * Test get_bf_notices returns empty array for yearly plans.
118- */
119- public function test_get_bf_notices_returns_empty_for_yearly_plans () {
120- // Mock Black Friday status as true
121- add_filter ( 'themeisle_sdk_is_black_friday_sale ' , '__return_true ' );
122-
123- // Test various yearly plans
124- $ yearly_plans = [ 'starter-yearly ' , 'growth-yearly ' , 'business-yearly ' , 'agency-yearly ' ];
125-
126- foreach ( $ yearly_plans as $ plan ) {
127- $ result = $ this ->admin ->get_bf_notices ( $ plan );
128- $ this ->assertIsArray ( $ result , "Failed for plan: $ plan " );
129- $ this ->assertEmpty ( $ result , "Expected empty array for yearly plan: $ plan " );
130- }
131- }
116+
132117
133118 /**
134- * Test get_bf_notices returns empty array for empty or invalid plans.
119+ * Test get_bf_notices returns empty array for non-free plans.
135120 */
136- public function test_get_bf_notices_returns_empty_for_invalid_plans () {
121+ public function test_get_bf_notices_returns_empty_for_non_free_plans () {
137122 $ this ->setup_black_friday_sale_period ();
138123 $ this ->mock_date_to ( clone $ this ->black_friday );
139124
140- // Test invalid plan (yearly suffix makes it invalid for BF notices)
141- $ result = $ this ->admin ->get_bf_notices ( 'invalid-plan-yearly ' );
142- $ this ->assertIsArray ( $ result );
143- $ this ->assertEmpty ( $ result );
125+ // Test various non-free plans - all should return empty
126+ $ non_free_plans = [ 'starter ' , 'growth ' , 'business ' , 'agency ' , 'starter-yearly ' , 'invalid-plan ' ];
144127
145- // Verify the plan is actually being evaluated, not just returning empty by default
146- $ result_valid = $ this ->admin ->get_bf_notices ( 'starter ' );
147- $ this ->assertNotEmpty ( $ result_valid , 'Valid plan should return notices ' );
128+ foreach ( $ non_free_plans as $ plan ) {
129+ $ result = $ this ->admin ->get_bf_notices ( $ plan );
130+ $ this ->assertIsArray ( $ result , "Failed for plan: $ plan " );
131+ $ this ->assertEmpty ( $ result , "Expected empty array for non-free plan: $ plan " );
132+ }
148133 }
149134
150135 /**
@@ -188,69 +173,28 @@ public function test_get_bf_notices_structure_for_free_plan() {
188173 $ this ->assertNotEmpty ( $ banner ['cta_text ' ] );
189174 $ this ->assertStringContainsString ( 'Use coupon code ' , $ banner ['subtitle ' ] );
190175 $ this ->assertStringContainsString ( 'BFCM2525 ' , $ banner ['subtitle ' ] );
176+ $ this ->assertStringContainsString ( '25 ' , $ banner ['subtitle ' ] );
191177 }
192178
193- /**
194- * Test get_bf_notices returns correct structure for monthly plan during Black Friday.
195- */
196- public function test_get_bf_notices_structure_for_monthly_plan () {
197- $ this ->setup_black_friday_sale_period ();
198- $ this ->mock_date_to ( clone $ this ->black_friday );
199-
200- // Test various monthly plans
201- $ monthly_plans = [ 'starter ' , 'growth ' , 'business ' , 'agency ' ];
202-
203- foreach ( $ monthly_plans as $ plan ) {
204- $ result = $ this ->admin ->get_bf_notices ( $ plan );
205-
206- $ this ->assertIsArray ( $ result , "Failed for plan: $ plan " );
207- // Monthly plans should NOT have sidebar, only banner
208- $ this ->assertArrayNotHasKey ( 'sidebar ' , $ result , "Unexpected sidebar for monthly plan: $ plan " );
209- $ this ->assertArrayHasKey ( 'banner ' , $ result , "Missing banner for plan: $ plan " );
210-
211- $ banner = $ result ['banner ' ];
212-
213- // Check banner subtitle contains discount information for monthly users
214- $ this ->assertStringContainsString ( '15 ' , $ banner ['subtitle ' ], "Missing 15% discount for plan: $ plan " );
215- $ this ->assertStringContainsString ( 'yearly plan ' , $ banner ['subtitle ' ], "Missing yearly mention for plan: $ plan " );
216-
217- // Check CTA for monthly users
218- $ this ->assertStringContainsString ( 'Contact us ' , $ banner ['cta_text ' ], "Wrong CTA for plan: $ plan " );
219- $ this ->assertNotEmpty ( $ banner ['cta_link ' ], "Empty link for plan: $ plan " );
220- }
221- }
179+
222180
223181 /**
224- * Test get_bf_notices banner is hidden when dismissed .
182+ * Test get_bf_notices banner visibility based on dismissal status .
225183 */
226- public function test_get_bf_notices_banner_hidden_when_dismissed () {
184+ public function test_get_bf_notices_banner_dismissal () {
227185 $ this ->setup_black_friday_sale_period ();
228186 $ this ->mock_date_to ( clone $ this ->black_friday );
229187
230- // Set dismissal option
188+ // Test banner is hidden when dismissed
231189 update_option ( Optml_Admin::BF_PROMO_DISMISS_KEY , 'yes ' );
232-
233190 $ result = $ this ->admin ->get_bf_notices ( 'free ' );
234-
235- // Should only have sidebar, not banner
236191 $ this ->assertIsArray ( $ result );
237192 $ this ->assertArrayHasKey ( 'sidebar ' , $ result );
238193 $ this ->assertArrayNotHasKey ( 'banner ' , $ result );
239- }
240-
241- /**
242- * Test get_bf_notices banner appears when not dismissed.
243- */
244- public function test_get_bf_notices_banner_appears_when_not_dismissed () {
245- $ this ->setup_black_friday_sale_period ();
246- $ this ->mock_date_to ( clone $ this ->black_friday );
247194
248- // Ensure option is not set
195+ // Test banner appears when not dismissed
249196 delete_option ( Optml_Admin::BF_PROMO_DISMISS_KEY );
250-
251197 $ result = $ this ->admin ->get_bf_notices ( 'free ' );
252-
253- // Should have both sidebar and banner
254198 $ this ->assertIsArray ( $ result );
255199 $ this ->assertArrayHasKey ( 'sidebar ' , $ result );
256200 $ this ->assertArrayHasKey ( 'banner ' , $ result );
@@ -315,23 +259,7 @@ public function test_get_bf_notices_banner_has_correct_title() {
315259 $ this ->assertStringContainsString ( 'private sale ' , $ result ['banner ' ]['title ' ] );
316260 }
317261
318- /**
319- * Test get_bf_notices with different date scenarios.
320- */
321- public function test_get_bf_notices_monthly_plan_contact_link () {
322- $ this ->setup_black_friday_sale_period ();
323- $ this ->mock_date_to ( clone $ this ->black_friday );
324-
325- $ result = $ this ->admin ->get_bf_notices ( 'starter ' );
326-
327- $ this ->assertArrayHasKey ( 'banner ' , $ result );
328- $ banner = $ result ['banner ' ];
329-
330- // Verify monthly plan contact link includes query parameters
331- $ this ->assertStringContainsString ( 'contact_subject ' , $ banner ['cta_link ' ] );
332- $ this ->assertStringContainsString ( 'contact_website ' , $ banner ['cta_link ' ] );
333- $ this ->assertStringContainsString ( 'Upgrade ' , $ banner ['cta_link ' ] );
334- }
262+
335263
336264 /**
337265 * Test get_bf_notices with different date scenarios.
@@ -367,26 +295,20 @@ public function test_get_bf_notices_date_scenarios() {
367295 }
368296
369297 /**
370- * Test get_bf_notices with non-'yes' dismissal values.
298+ * Test get_bf_notices banner appears with non-'yes' dismissal values.
371299 */
372- public function test_get_bf_notices_banner_appears_with_non_yes_dismissal () {
300+ public function test_get_bf_notices_banner_dismissal_values () {
373301 $ this ->setup_black_friday_sale_period ();
374302 $ this ->mock_date_to ( clone $ this ->black_friday );
375303
376- // Test with 'no' value
377- update_option ( Optml_Admin::BF_PROMO_DISMISS_KEY , 'no ' );
378- $ result = $ this ->admin ->get_bf_notices ( 'free ' );
379- $ this ->assertArrayHasKey ( 'banner ' , $ result , "Banner should appear when dismiss key is 'no' " );
380-
381- // Test with '0' value
382- update_option ( Optml_Admin::BF_PROMO_DISMISS_KEY , '0 ' );
383- $ result = $ this ->admin ->get_bf_notices ( 'free ' );
384- $ this ->assertArrayHasKey ( 'banner ' , $ result , "Banner should appear when dismiss key is '0' " );
304+ // Banner only hides when dismissal key is exactly 'yes'
305+ $ test_values = [ 'no ' , '0 ' , '' , 'dismissed ' ];
385306
386- // Test with empty string
387- update_option ( Optml_Admin::BF_PROMO_DISMISS_KEY , '' );
388- $ result = $ this ->admin ->get_bf_notices ( 'free ' );
389- $ this ->assertArrayHasKey ( 'banner ' , $ result , "Banner should appear when dismiss key is empty string " );
307+ foreach ( $ test_values as $ value ) {
308+ update_option ( Optml_Admin::BF_PROMO_DISMISS_KEY , $ value );
309+ $ result = $ this ->admin ->get_bf_notices ( 'free ' );
310+ $ this ->assertArrayHasKey ( 'banner ' , $ result , "Banner should appear when dismiss key is ' $ value' " );
311+ }
390312 }
391313
392314 /**
0 commit comments