@@ -756,8 +756,9 @@ public function testGetGrowthStatsWithStartDate()
756
756
$ this ->assertArrayHasKey ('ending ' , $ result ['stats ' ]);
757
757
758
758
// Assert start and end dates were honored.
759
- $ this ->assertEquals ($ result ['stats ' ]['starting ' ], $ starting ->format ('Y-m-d ' ) . 'T00:00:00-04:00 ' );
760
- $ this ->assertEquals ($ result ['stats ' ]['ending ' ], $ ending ->format ('Y-m-d ' ) . 'T23:59:59-04:00 ' );
759
+ $ timezone = ( new DateTime () )->setTimezone (new DateTimeZone ('America/New_York ' ))->format ('P ' ); // Gets timezone offset for New York (-04:00 during DST, -05:00 otherwise).
760
+ $ this ->assertEquals ($ result ['stats ' ]['starting ' ], $ starting ->format ('Y-m-d ' ) . 'T00:00:00 ' . $ timezone );
761
+ $ this ->assertEquals ($ result ['stats ' ]['ending ' ], $ ending ->format ('Y-m-d ' ) . 'T23:59:59 ' . $ timezone );
761
762
}
762
763
763
764
/**
@@ -790,8 +791,9 @@ public function testGetGrowthStatsWithEndDate()
790
791
$ this ->assertArrayHasKey ('ending ' , $ result ['stats ' ]);
791
792
792
793
// Assert start and end dates were honored.
793
- $ this ->assertEquals ($ result ['stats ' ]['starting ' ], $ starting ->format ('Y-m-d ' ) . 'T00:00:00-04:00 ' );
794
- $ this ->assertEquals ($ result ['stats ' ]['ending ' ], $ ending ->format ('Y-m-d ' ) . 'T23:59:59-04:00 ' );
794
+ $ timezone = ( new DateTime () )->setTimezone (new DateTimeZone ('America/New_York ' ))->format ('P ' ); // Gets timezone offset for New York (-04:00 during DST, -05:00 otherwise).
795
+ $ this ->assertEquals ($ result ['stats ' ]['starting ' ], $ starting ->format ('Y-m-d ' ) . 'T00:00:00 ' . $ timezone );
796
+ $ this ->assertEquals ($ result ['stats ' ]['ending ' ], $ ending ->format ('Y-m-d ' ) . 'T23:59:59 ' . $ timezone );
795
797
}
796
798
797
799
/**
@@ -1249,7 +1251,7 @@ public function testGetFormSubscriptionsWithBouncedSubscriberState()
1249
1251
*/
1250
1252
public function testGetFormSubscriptionsWithAddedAfterParam ()
1251
1253
{
1252
- $ date = new \DateTime ('2024 -01-01 ' );
1254
+ $ date = new \DateTime ('2022 -01-01 ' );
1253
1255
$ result = $ this ->api ->get_form_subscriptions (
1254
1256
(int ) $ _ENV ['CONVERTKIT_API_FORM_ID ' ], // Form ID.
1255
1257
'active ' , // Subscriber state.
@@ -1312,7 +1314,7 @@ public function testGetFormSubscriptionsWithAddedBeforeParam()
1312
1314
*/
1313
1315
public function testGetFormSubscriptionsWithCreatedAfterParam ()
1314
1316
{
1315
- $ date = new \DateTime ('2024 -01-01 ' );
1317
+ $ date = new \DateTime ('2022 -01-01 ' );
1316
1318
$ result = $ this ->api ->get_form_subscriptions (
1317
1319
(int ) $ _ENV ['CONVERTKIT_API_FORM_ID ' ], // Form ID.
1318
1320
'active ' , // Subscriber state.
@@ -2272,7 +2274,7 @@ public function testGetSequenceSubscriptionsWithBouncedSubscriberState()
2272
2274
*/
2273
2275
public function testGetSequenceSubscriptionsWithAddedAfterParam ()
2274
2276
{
2275
- $ date = new \DateTime ('2024 -01-01 ' );
2277
+ $ date = new \DateTime ('2022 -01-01 ' );
2276
2278
$ result = $ this ->api ->get_sequence_subscriptions (
2277
2279
$ _ENV ['CONVERTKIT_API_SEQUENCE_ID ' ], // Sequence ID.
2278
2280
'active ' , // Subscriber state.
@@ -2335,7 +2337,7 @@ public function testGetSequenceSubscriptionsWithAddedBeforeParam()
2335
2337
*/
2336
2338
public function testGetSequenceSubscriptionsWithCreatedAfterParam ()
2337
2339
{
2338
- $ date = new \DateTime ('2024 -01-01 ' );
2340
+ $ date = new \DateTime ('2022 -01-01 ' );
2339
2341
$ result = $ this ->api ->get_sequence_subscriptions (
2340
2342
$ _ENV ['CONVERTKIT_API_SEQUENCE_ID ' ], // Sequence ID.
2341
2343
'active ' , // Subscriber state.
@@ -2441,7 +2443,7 @@ public function testGetSequenceSubscriptionsPagination()
2441
2443
2442
2444
// Assert has_previous_page and has_next_page are correct.
2443
2445
$ this ->assertTrue ($ result ['pagination ' ]['has_previous_page ' ]);
2444
- $ this ->assertTrue ($ result ['pagination ' ]['has_next_page ' ]);
2446
+ $ this ->assertFalse ($ result ['pagination ' ]['has_next_page ' ]);
2445
2447
2446
2448
// Use pagination to fetch previous page.
2447
2449
$ result = $ this ->api ->get_sequence_subscriptions (
@@ -2654,7 +2656,7 @@ public function testCreateTagBlank()
2654
2656
}
2655
2657
2656
2658
/**
2657
- * Test that create_tag() returns a WP_Error when creating
2659
+ * Test that create_tag() returns the expected data when creating
2658
2660
* a tag that already exists.
2659
2661
*
2660
2662
* @since 1.0.0
@@ -2664,8 +2666,12 @@ public function testCreateTagBlank()
2664
2666
public function testCreateTagThatExists ()
2665
2667
{
2666
2668
$ result = $ this ->api ->create_tag ($ _ENV ['CONVERTKIT_API_TAG_NAME ' ]);
2667
- $ this ->assertInstanceOf (WP_Error::class, $ result );
2668
- $ this ->assertEquals ($ result ->get_error_code (), $ this ->errorCode );
2669
+
2670
+ // Assert response contains correct data.
2671
+ $ this ->assertArrayHasKey ('id ' , $ result ['tag ' ]);
2672
+ $ this ->assertArrayHasKey ('name ' , $ result ['tag ' ]);
2673
+ $ this ->assertArrayHasKey ('created_at ' , $ result ['tag ' ]);
2674
+ $ this ->assertEquals ($ result ['tag ' ]['name ' ], $ _ENV ['CONVERTKIT_API_TAG_NAME ' ]);
2669
2675
}
2670
2676
2671
2677
/**
@@ -2728,14 +2734,13 @@ public function testCreateTagsBlank()
2728
2734
'' ,
2729
2735
]
2730
2736
);
2731
-
2732
- // Assert failures.
2733
- $ this ->assertCount (2 , $ result ['failures ' ]);
2737
+ $ this ->assertInstanceOf (WP_Error::class, $ result );
2738
+ $ this ->assertEquals ($ result ->get_error_code (), $ this ->errorCode );
2734
2739
}
2735
2740
2736
2741
/**
2737
- * Test that create_tags() returns a WP_Error when creating
2738
- * tags that already exists .
2742
+ * Test that create_tags() returns the expected data when creating
2743
+ * tags that already exist .
2739
2744
*
2740
2745
* @since 2.0.0
2741
2746
*
@@ -2750,8 +2755,10 @@ public function testCreateTagsThatExist()
2750
2755
]
2751
2756
);
2752
2757
2753
- // Assert failures.
2754
- $ this ->assertCount (2 , $ result ['failures ' ]);
2758
+ // Assert existing tags are returned.
2759
+ $ this ->assertCount (2 , $ result ['tags ' ]);
2760
+ $ this ->assertEquals ($ result ['tags ' ][1 ]['name ' ], $ _ENV ['CONVERTKIT_API_TAG_NAME ' ]);
2761
+ $ this ->assertEquals ($ result ['tags ' ][0 ]['name ' ], $ _ENV ['CONVERTKIT_API_TAG_NAME_2 ' ]);
2755
2762
}
2756
2763
2757
2764
/**
@@ -3127,7 +3134,7 @@ public function testGetTagSubscriptionsWithBouncedSubscriberState()
3127
3134
*/
3128
3135
public function testGetTagSubscriptionsWithTaggedAfterParam ()
3129
3136
{
3130
- $ date = new \DateTime ('2024 -01-01 ' );
3137
+ $ date = new \DateTime ('2022 -01-01 ' );
3131
3138
$ result = $ this ->api ->get_tag_subscriptions (
3132
3139
(int ) $ _ENV ['CONVERTKIT_API_TAG_ID ' ], // Tag ID.
3133
3140
'active ' , // Subscriber state.
@@ -3190,7 +3197,7 @@ public function testGetTagSubscriptionsWithTaggedBeforeParam()
3190
3197
*/
3191
3198
public function testGetTagSubscriptionsWithCreatedAfterParam ()
3192
3199
{
3193
- $ date = new \DateTime ('2024 -01-01 ' );
3200
+ $ date = new \DateTime ('2022 -01-01 ' );
3194
3201
$ result = $ this ->api ->get_tag_subscriptions (
3195
3202
(int ) $ _ENV ['CONVERTKIT_API_TAG_ID ' ], // Tag ID.
3196
3203
'active ' , // Subscriber state.
@@ -3450,7 +3457,7 @@ public function testGetSubscribersWithBouncedSubscriberState()
3450
3457
*/
3451
3458
public function testGetSubscribersWithCreatedAfterParam ()
3452
3459
{
3453
- $ date = new \DateTime ('2024 -01-01 ' );
3460
+ $ date = new \DateTime ('2022 -01-01 ' );
3454
3461
$ result = $ this ->api ->get_subscribers (
3455
3462
'active ' , // Subscriber state.
3456
3463
'' , // Email address.
@@ -3507,7 +3514,7 @@ public function testGetSubscribersWithCreatedBeforeParam()
3507
3514
*/
3508
3515
public function testGetSubscribersWithUpdatedAfterParam ()
3509
3516
{
3510
- $ date = new \DateTime ('2024 -01-01 ' );
3517
+ $ date = new \DateTime ('2022 -01-01 ' );
3511
3518
$ result = $ this ->api ->get_subscribers (
3512
3519
'active ' , // Subscriber state.
3513
3520
'' , // Email address.
0 commit comments