@@ -765,8 +765,10 @@ public function testGetGrowthStatsWithStartDate()
765
765
$ this ->assertArrayHasKey ('ending ' , $ stats );
766
766
767
767
// Assert start and end dates were honored.
768
- $ this ->assertEquals ($ stats ['starting ' ], $ starting ->format ('Y-m-d ' ) . 'T00:00:00-05:00 ' );
769
- $ this ->assertEquals ($ stats ['ending ' ], $ ending ->format ('Y-m-d ' ) . 'T23:59:59-05:00 ' );
768
+ // Gets timezone offset for New York (-04:00 during DST, -05:00 otherwise).
769
+ $ timezone = ( new DateTime () )->setTimezone (new DateTimeZone ('America/New_York ' ))->format ('P ' );
770
+ $ this ->assertEquals ($ stats ['starting ' ], $ starting ->format ('Y-m-d ' ) . 'T00:00:00 ' . $ timezone );
771
+ $ this ->assertEquals ($ stats ['ending ' ], $ ending ->format ('Y-m-d ' ) . 'T23:59:59 ' . $ timezone );
770
772
}
771
773
772
774
/**
@@ -802,8 +804,10 @@ public function testGetGrowthStatsWithEndDate()
802
804
$ this ->assertArrayHasKey ('ending ' , $ stats );
803
805
804
806
// Assert start and end dates were honored.
805
- $ this ->assertEquals ($ stats ['starting ' ], $ starting ->format ('Y-m-d ' ) . 'T00:00:00-05:00 ' );
806
- $ this ->assertEquals ($ stats ['ending ' ], $ ending ->format ('Y-m-d ' ) . 'T23:59:59-05:00 ' );
807
+ // Gets timezone offset for New York (-04:00 during DST, -05:00 otherwise).
808
+ $ timezone = ( new DateTime () )->setTimezone (new DateTimeZone ('America/New_York ' ))->format ('P ' );
809
+ $ this ->assertEquals ($ stats ['starting ' ], $ starting ->format ('Y-m-d ' ) . 'T00:00:00 ' . $ timezone );
810
+ $ this ->assertEquals ($ stats ['ending ' ], $ ending ->format ('Y-m-d ' ) . 'T23:59:59 ' . $ timezone );
807
811
}
808
812
809
813
/**
@@ -1186,7 +1190,7 @@ public function testGetFormSubscriptionsWithBouncedSubscriberState()
1186
1190
*/
1187
1191
public function testGetFormSubscriptionsWithAddedAfterParam ()
1188
1192
{
1189
- $ date = new \DateTime ('2024 -01-01 ' );
1193
+ $ date = new \DateTime ('2022 -01-01 ' );
1190
1194
$ result = $ this ->api ->get_form_subscriptions (
1191
1195
form_id: (int ) $ _ENV ['CONVERTKIT_API_FORM_ID ' ],
1192
1196
added_after: $ date
@@ -1242,7 +1246,7 @@ public function testGetFormSubscriptionsWithAddedBeforeParam()
1242
1246
*/
1243
1247
public function testGetFormSubscriptionsWithCreatedAfterParam ()
1244
1248
{
1245
- $ date = new \DateTime ('2024 -01-01 ' );
1249
+ $ date = new \DateTime ('2022 -01-01 ' );
1246
1250
$ result = $ this ->api ->get_form_subscriptions (
1247
1251
form_id: (int ) $ _ENV ['CONVERTKIT_API_FORM_ID ' ],
1248
1252
created_after: $ date
@@ -1702,7 +1706,7 @@ public function testGetSequenceSubscriptionsWithBouncedSubscriberState()
1702
1706
*/
1703
1707
public function testGetSequenceSubscriptionsWithAddedAfterParam ()
1704
1708
{
1705
- $ date = new \DateTime ('2024 -01-01 ' );
1709
+ $ date = new \DateTime ('2022 -01-01 ' );
1706
1710
$ result = $ this ->api ->get_sequence_subscriptions (
1707
1711
sequence_id: (int ) $ _ENV ['CONVERTKIT_API_SEQUENCE_ID ' ],
1708
1712
added_after: $ date
@@ -1758,7 +1762,7 @@ public function testGetSequenceSubscriptionsWithAddedBeforeParam()
1758
1762
*/
1759
1763
public function testGetSequenceSubscriptionsWithCreatedAfterParam ()
1760
1764
{
1761
- $ date = new \DateTime ('2024 -01-01 ' );
1765
+ $ date = new \DateTime ('2022 -01-01 ' );
1762
1766
$ result = $ this ->api ->get_sequence_subscriptions (
1763
1767
sequence_id: (int ) $ _ENV ['CONVERTKIT_API_SEQUENCE_ID ' ],
1764
1768
created_after: $ date
@@ -1846,7 +1850,7 @@ public function testGetSequenceSubscriptionsPagination()
1846
1850
1847
1851
// Assert has_previous_page and has_next_page are correct.
1848
1852
$ this ->assertTrue ($ result ->pagination ->has_previous_page );
1849
- $ this ->assertTrue ($ result ->pagination ->has_next_page );
1853
+ $ this ->assertFalse ($ result ->pagination ->has_next_page );
1850
1854
1851
1855
// Use pagination to fetch previous page.
1852
1856
$ result = $ this ->api ->get_sequence_subscriptions (
@@ -2058,7 +2062,7 @@ public function testCreateTagBlank()
2058
2062
}
2059
2063
2060
2064
/**
2061
- * Test that create_tag() throws a ClientException when creating
2065
+ * Test that create_tag() returns the expected data when creating
2062
2066
* a tag that already exists.
2063
2067
*
2064
2068
* @since 1.0.0
@@ -2067,8 +2071,14 @@ public function testCreateTagBlank()
2067
2071
*/
2068
2072
public function testCreateTagThatExists ()
2069
2073
{
2070
- $ this ->expectException (ClientException::class);
2071
2074
$ result = $ this ->api ->create_tag ($ _ENV ['CONVERTKIT_API_TAG_NAME ' ]);
2075
+
2076
+ // Assert response contains correct data.
2077
+ $ tag = get_object_vars ($ result ->tag );
2078
+ $ this ->assertArrayHasKey ('id ' , $ tag );
2079
+ $ this ->assertArrayHasKey ('name ' , $ tag );
2080
+ $ this ->assertArrayHasKey ('created_at ' , $ tag );
2081
+ $ this ->assertEquals ($ tag ['name ' ], $ _ENV ['CONVERTKIT_API_TAG_NAME ' ]);
2072
2082
}
2073
2083
2074
2084
/**
@@ -2141,13 +2151,17 @@ public function testCreateTagsBlank()
2141
2151
*/
2142
2152
public function testCreateTagsThatExist ()
2143
2153
{
2144
- $ result = $ this ->api ->create_tags ([
2145
- $ _ENV ['CONVERTKIT_API_TAG_NAME ' ],
2146
- $ _ENV ['CONVERTKIT_API_TAG_NAME_2 ' ],
2147
- ]);
2154
+ $ result = $ this ->api ->create_tags (
2155
+ [
2156
+ $ _ENV ['CONVERTKIT_API_TAG_NAME ' ],
2157
+ $ _ENV ['CONVERTKIT_API_TAG_NAME_2 ' ],
2158
+ ]
2159
+ );
2148
2160
2149
- // Assert failures.
2150
- $ this ->assertCount (2 , $ result ->failures );
2161
+ // Assert existing tags are returned.
2162
+ $ this ->assertCount (2 , $ result ->tags );
2163
+ $ this ->assertEquals ($ result ->tags [1 ]->name , $ _ENV ['CONVERTKIT_API_TAG_NAME ' ]);
2164
+ $ this ->assertEquals ($ result ->tags [0 ]->name , $ _ENV ['CONVERTKIT_API_TAG_NAME_2 ' ]);
2151
2165
}
2152
2166
2153
2167
/**
@@ -2530,7 +2544,7 @@ public function testGetTagSubscriptionsWithBouncedSubscriberState()
2530
2544
*/
2531
2545
public function testGetTagSubscriptionsWithTaggedAfterParam ()
2532
2546
{
2533
- $ date = new \DateTime ('2024 -01-01 ' );
2547
+ $ date = new \DateTime ('2022 -01-01 ' );
2534
2548
$ result = $ this ->api ->get_tag_subscriptions (
2535
2549
tag_id: (int ) $ _ENV ['CONVERTKIT_API_TAG_ID ' ],
2536
2550
tagged_after: $ date
@@ -2586,7 +2600,7 @@ public function testGetTagSubscriptionsWithTaggedBeforeParam()
2586
2600
*/
2587
2601
public function testGetTagSubscriptionsWithCreatedAfterParam ()
2588
2602
{
2589
- $ date = new \DateTime ('2024 -01-01 ' );
2603
+ $ date = new \DateTime ('2022 -01-01 ' );
2590
2604
$ result = $ this ->api ->get_tag_subscriptions (
2591
2605
tag_id: (int ) $ _ENV ['CONVERTKIT_API_TAG_ID ' ],
2592
2606
created_after: $ date
@@ -3396,7 +3410,7 @@ public function testGetSubscribersWithBouncedSubscriberState()
3396
3410
*/
3397
3411
public function testGetSubscribersWithCreatedAfterParam ()
3398
3412
{
3399
- $ date = new \DateTime ('2024 -01-01 ' );
3413
+ $ date = new \DateTime ('2022 -01-01 ' );
3400
3414
$ result = $ this ->api ->get_subscribers (
3401
3415
created_after: $ date
3402
3416
);
@@ -3448,7 +3462,7 @@ public function testGetSubscribersWithCreatedBeforeParam()
3448
3462
*/
3449
3463
public function testGetSubscribersWithUpdatedAfterParam ()
3450
3464
{
3451
- $ date = new \DateTime ('2024 -01-01 ' );
3465
+ $ date = new \DateTime ('2022 -01-01 ' );
3452
3466
$ result = $ this ->api ->get_subscribers (
3453
3467
updated_after: $ date
3454
3468
);
0 commit comments