@@ -98,7 +98,42 @@ public function test_no_notification_within_2_weeks() {
9898 );
9999
100100 $ subscription ->add_phase ( $ phase );
101- $ subscription ->set_meta ( 'notification_date_renewal ' , \gmdate ( DATE_ATOM , \strtotime ( '-10 days ' ) ) );
101+ $ subscription ->set_meta (
102+ 'notification_date_renewal ' ,
103+ ( new \DateTime ( '-10 days ' , new \DateTimeZone ( 'GMT ' ) ) )->format ( DATE_ATOM )
104+ );
105+ $ subscription ->save ();
106+
107+ $ notifications_controller ->send_subscription_renewal_notification ( $ subscription );
108+
109+ $ this ->assertSame ( 0 , \did_action ( 'pronamic_subscription_renewal_notice_ ' . $ source ) );
110+ }
111+
112+ /**
113+ * Test no notification within 2 weeks for legacy meta key.
114+ */
115+ public function test_no_notification_within_2_weeks_legacy_meta_key () {
116+ $ notifications_controller = new SubscriptionsNotificationsController ();
117+
118+ $ source = 'test-within-2-weeks-legacy ' ;
119+
120+ $ subscription = new Subscription ();
121+
122+ $ subscription ->set_source ( $ source );
123+ $ subscription ->set_mode ( 'test ' );
124+
125+ $ phase = new SubscriptionPhase (
126+ $ subscription ,
127+ new \DateTime ( '-3 weeks midnight ' , new \DateTimeZone ( 'GMT ' ) ),
128+ new SubscriptionInterval ( 'P1M ' ),
129+ new Money ( '10 ' , 'EUR ' )
130+ );
131+
132+ $ subscription ->add_phase ( $ phase );
133+ $ subscription ->set_meta (
134+ 'notification_date_1_week ' ,
135+ ( new \DateTime ( '-10 days ' , new \DateTimeZone ( 'GMT ' ) ) )->format ( DATE_ATOM )
136+ );
102137 $ subscription ->save ();
103138
104139 $ notifications_controller ->send_subscription_renewal_notification ( $ subscription );
0 commit comments