@@ -1162,16 +1162,26 @@ public function testGetSequencesPagination()
1162
1162
*/
1163
1163
public function testAddSubscriberToSequenceByEmail ()
1164
1164
{
1165
+ // Create subscriber.
1166
+ $ emailAddress = $ this ->generateEmailAddress ();
1167
+ $ subscriber = $ this ->api ->create_subscriber (
1168
+ email_address: $ emailAddress
1169
+ );
1170
+
1171
+ // Set subscriber_id to ensure subscriber is unsubscribed after test.
1172
+ $ this ->subscriber_ids [] = $ subscriber ->subscriber ->id ;
1173
+
1174
+ // Add subscriber to sequence.
1165
1175
$ result = $ this ->api ->add_subscriber_to_sequence_by_email (
1166
1176
sequence_id: $ _ENV ['CONVERTKIT_API_SEQUENCE_ID ' ],
1167
- email_address: $ _ENV [ ' CONVERTKIT_API_SUBSCRIBER_EMAIL ' ]
1177
+ email_address: $ emailAddress
1168
1178
);
1169
1179
$ this ->assertInstanceOf ('stdClass ' , $ result );
1170
1180
$ this ->assertArrayHasKey ('subscriber ' , get_object_vars ($ result ));
1171
1181
$ this ->assertArrayHasKey ('id ' , get_object_vars ($ result ->subscriber ));
1172
1182
$ this ->assertEquals (
1173
1183
get_object_vars ($ result ->subscriber )['email_address ' ],
1174
- $ _ENV [ ' CONVERTKIT_API_SUBSCRIBER_EMAIL ' ]
1184
+ $ emailAddress
1175
1185
);
1176
1186
}
1177
1187
@@ -1218,14 +1228,23 @@ public function testAddSubscriberToSequenceByEmailWithInvalidEmailAddress()
1218
1228
*/
1219
1229
public function testAddSubscriberToSequence ()
1220
1230
{
1231
+ // Create subscriber.
1232
+ $ subscriber = $ this ->api ->create_subscriber (
1233
+ email_address: $ this ->generateEmailAddress ()
1234
+ );
1235
+
1236
+ // Set subscriber_id to ensure subscriber is unsubscribed after test.
1237
+ $ this ->subscriber_ids [] = $ subscriber ->subscriber ->id ;
1238
+
1239
+ // Add subscriber to sequence.
1221
1240
$ result = $ this ->api ->add_subscriber_to_sequence (
1222
1241
sequence_id: (int ) $ _ENV ['CONVERTKIT_API_SEQUENCE_ID ' ],
1223
- subscriber_id: $ _ENV [ ' CONVERTKIT_API_SUBSCRIBER_ID ' ]
1242
+ subscriber_id: $ subscriber -> subscriber -> id
1224
1243
);
1225
1244
$ this ->assertInstanceOf ('stdClass ' , $ result );
1226
1245
$ this ->assertArrayHasKey ('subscriber ' , get_object_vars ($ result ));
1227
1246
$ this ->assertArrayHasKey ('id ' , get_object_vars ($ result ->subscriber ));
1228
- $ this ->assertEquals (get_object_vars ($ result ->subscriber )['id ' ], $ _ENV [ ' CONVERTKIT_API_SUBSCRIBER_ID ' ] );
1247
+ $ this ->assertEquals (get_object_vars ($ result ->subscriber )['id ' ], $ subscriber -> subscriber -> id );
1229
1248
}
1230
1249
1231
1250
/**
@@ -2416,14 +2435,27 @@ public function testGetResourcesInvalidResourceType()
2416
2435
*/
2417
2436
public function testAddSubscriberToFormByEmail ()
2418
2437
{
2438
+ // Create subscriber.
2439
+ $ emailAddress = $ this ->generateEmailAddress ();
2440
+ $ subscriber = $ this ->api ->create_subscriber (
2441
+ email_address: $ emailAddress
2442
+ );
2443
+
2444
+ // Set subscriber_id to ensure subscriber is unsubscribed after test.
2445
+ $ this ->subscriber_ids [] = $ subscriber ->subscriber ->id ;
2446
+
2447
+ // Add subscriber to form.
2419
2448
$ result = $ this ->api ->add_subscriber_to_form_by_email (
2420
2449
form_id: (int ) $ _ENV ['CONVERTKIT_API_FORM_ID ' ],
2421
- email_address: $ _ENV [ ' CONVERTKIT_API_SUBSCRIBER_EMAIL ' ]
2450
+ email_address: $ emailAddress
2422
2451
);
2423
2452
$ this ->assertInstanceOf ('stdClass ' , $ result );
2424
2453
$ this ->assertArrayHasKey ('subscriber ' , get_object_vars ($ result ));
2425
2454
$ this ->assertArrayHasKey ('id ' , get_object_vars ($ result ->subscriber ));
2426
- $ this ->assertEquals (get_object_vars ($ result ->subscriber )['id ' ], $ _ENV ['CONVERTKIT_API_SUBSCRIBER_ID ' ]);
2455
+ $ this ->assertEquals (
2456
+ get_object_vars ($ result ->subscriber )['email_address ' ],
2457
+ $ emailAddress
2458
+ );
2427
2459
}
2428
2460
2429
2461
/**
@@ -2469,14 +2501,22 @@ public function testAddSubscriberToFormByEmailWithInvalidEmailAddress()
2469
2501
*/
2470
2502
public function testAddSubscriberToForm ()
2471
2503
{
2504
+ // Create subscriber.
2505
+ $ subscriber = $ this ->api ->create_subscriber (
2506
+ email_address: $ this ->generateEmailAddress ()
2507
+ );
2508
+
2509
+ // Set subscriber_id to ensure subscriber is unsubscribed after test.
2510
+ $ this ->subscriber_ids [] = $ subscriber ->subscriber ->id ;
2511
+
2472
2512
$ result = $ this ->api ->add_subscriber_to_form (
2473
2513
form_id: (int ) $ _ENV ['CONVERTKIT_API_FORM_ID ' ],
2474
- subscriber_id: $ _ENV [ ' CONVERTKIT_API_SUBSCRIBER_ID ' ]
2514
+ subscriber_id: $ subscriber -> subscriber -> id
2475
2515
);
2476
2516
$ this ->assertInstanceOf ('stdClass ' , $ result );
2477
2517
$ this ->assertArrayHasKey ('subscriber ' , get_object_vars ($ result ));
2478
2518
$ this ->assertArrayHasKey ('id ' , get_object_vars ($ result ->subscriber ));
2479
- $ this ->assertEquals (get_object_vars ($ result ->subscriber )['id ' ], $ _ENV [ ' CONVERTKIT_API_SUBSCRIBER_ID ' ] );
2519
+ $ this ->assertEquals (get_object_vars ($ result ->subscriber )['id ' ], $ subscriber -> subscriber -> id );
2480
2520
}
2481
2521
2482
2522
/**
0 commit comments