Skip to content

Commit 7b5fcef

Browse files
committed
Started tests
1 parent 0df40a7 commit 7b5fcef

File tree

1 file changed

+165
-0
lines changed

1 file changed

+165
-0
lines changed

tests/ConvertKitAPITest.php

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,30 @@ public function testGetFormSubscriptions()
755755
$this->assertPaginationExists($result);
756756
}
757757

758+
/**
759+
* Test that get_form_subscriptions() returns the expected data
760+
* when the total count is included.
761+
*
762+
* @since 2.0.0
763+
*
764+
* @return void
765+
*/
766+
public function testGetFormSubscriptionsWithTotalCount()
767+
{
768+
$result = $this->api->get_form_subscriptions(
769+
form_id: (int) $_ENV['CONVERTKIT_API_FORM_ID'],
770+
include_total_count: true
771+
);
772+
773+
// Assert subscribers and pagination exist.
774+
$this->assertDataExists($result, 'subscribers');
775+
$this->assertPaginationExists($result);
776+
777+
// Assert total count is included.
778+
$this->assertArrayHasKey('total_count', get_object_vars($result->pagination));
779+
$this->assertGreaterThan(0, $result->pagination->total_count);
780+
}
781+
758782
/**
759783
* Test that get_form_subscriptions() returns the expected data
760784
* when a valid Form ID is specified and the subscription status
@@ -1022,6 +1046,29 @@ public function testGetSequences()
10221046
$this->assertArrayHasKey('created_at', $sequence);
10231047
}
10241048

1049+
/**
1050+
* Test that get_sequences() returns the expected data
1051+
* when the total count is included.
1052+
*
1053+
* @since 2.0.0
1054+
*
1055+
* @return void
1056+
*/
1057+
public function testGetSequencesWithTotalCount()
1058+
{
1059+
$result = $this->api->get_sequences(
1060+
include_total_count: true
1061+
);
1062+
1063+
// Assert sequences and pagination exist.
1064+
$this->assertDataExists($result, 'sequences');
1065+
$this->assertPaginationExists($result);
1066+
1067+
// Assert total count is included.
1068+
$this->assertArrayHasKey('total_count', get_object_vars($result->pagination));
1069+
$this->assertGreaterThan(0, $result->pagination->total_count);
1070+
}
1071+
10251072
/**
10261073
* Test that get_sequences() returns the expected data when
10271074
* pagination parameters and per_page limits are specified.
@@ -1205,6 +1252,30 @@ public function testGetSequenceSubscriptions()
12051252
$this->assertPaginationExists($result);
12061253
}
12071254

1255+
/**
1256+
* Test that get_sequence_subscriptions() returns the expected data
1257+
* when the total count is included.
1258+
*
1259+
* @since 2.0.0
1260+
*
1261+
* @return void
1262+
*/
1263+
public function testGetSequencesWithTotalCount()
1264+
{
1265+
$result = $this->api->get_sequence_subscriptions(
1266+
sequence_id: $_ENV['CONVERTKIT_API_SEQUENCE_ID'],
1267+
include_total_count: true
1268+
);
1269+
1270+
// Assert subscribers and pagination exist.
1271+
$this->assertDataExists($result, 'subscribers');
1272+
$this->assertPaginationExists($result);
1273+
1274+
// Assert total count is included.
1275+
$this->assertArrayHasKey('total_count', get_object_vars($result->pagination));
1276+
$this->assertGreaterThan(0, $result->pagination->total_count);
1277+
}
1278+
12081279
/**
12091280
* Test that get_sequence_subscriptions() returns the expected data
12101281
* when a valid Sequence ID is specified and the subscription status
@@ -1470,6 +1541,29 @@ public function testGetTags()
14701541
$this->assertArrayHasKey('created_at', $tag);
14711542
}
14721543

1544+
/**
1545+
* Test that get_tags() returns the expected data
1546+
* when the total count is included.
1547+
*
1548+
* @since 2.0.0
1549+
*
1550+
* @return void
1551+
*/
1552+
public function testGetTagsWithTotalCount()
1553+
{
1554+
$result = $this->api->get_tags(
1555+
include_total_count: true
1556+
);
1557+
1558+
// Assert tags and pagination exist.
1559+
$this->assertDataExists($result, 'tags');
1560+
$this->assertPaginationExists($result);
1561+
1562+
// Assert total count is included.
1563+
$this->assertArrayHasKey('total_count', get_object_vars($result->pagination));
1564+
$this->assertGreaterThan(0, $result->pagination->total_count);
1565+
}
1566+
14731567
/**
14741568
* Test that get_tags() returns the expected data
14751569
* when pagination parameters and per_page limits are specified.
@@ -1948,6 +2042,30 @@ public function testGetTagSubscriptions()
19482042
$this->assertPaginationExists($result);
19492043
}
19502044

2045+
/**
2046+
* Test that get_tag_subscriptions() returns the expected data
2047+
* when the total count is included.
2048+
*
2049+
* @since 2.0.0
2050+
*
2051+
* @return void
2052+
*/
2053+
public function testGetTagSubscriptionsWithTotalCount()
2054+
{
2055+
$result = $this->api->get_tag_subscriptions(
2056+
tag_id: (int) $_ENV['CONVERTKIT_API_TAG_ID'],
2057+
include_total_count: true
2058+
);
2059+
2060+
// Assert tags and pagination exist.
2061+
$this->assertDataExists($result, 'tags');
2062+
$this->assertPaginationExists($result);
2063+
2064+
// Assert total count is included.
2065+
$this->assertArrayHasKey('total_count', get_object_vars($result->pagination));
2066+
$this->assertGreaterThan(0, $result->pagination->total_count);
2067+
}
2068+
19512069
/**
19522070
* Test that get_tag_subscriptions() returns the expected data
19532071
* when a valid Tag ID is specified and the subscription status
@@ -2346,6 +2464,29 @@ public function testGetSubscribers()
23462464
$this->assertPaginationExists($result);
23472465
}
23482466

2467+
/**
2468+
* Test that get_subscribers() returns the expected data
2469+
* when the total count is included.
2470+
*
2471+
* @since 2.0.0
2472+
*
2473+
* @return void
2474+
*/
2475+
public function testGetSubscribersWithTotalCount()
2476+
{
2477+
$result = $this->api->get_subscribers(
2478+
include_total_count: true
2479+
);
2480+
2481+
// Assert subscribers and pagination exist.
2482+
$this->assertDataExists($result, 'subscribers');
2483+
$this->assertPaginationExists($result);
2484+
2485+
// Assert total count is included.
2486+
$this->assertArrayHasKey('total_count', get_object_vars($result->pagination));
2487+
$this->assertGreaterThan(0, $result->pagination->total_count);
2488+
}
2489+
23492490
/**
23502491
* Test that get_subscribers() returns the expected data when
23512492
* searching by an email address.
@@ -3207,6 +3348,30 @@ public function testGetSubscriberTags()
32073348
$this->assertPaginationExists($result);
32083349
}
32093350

3351+
/**
3352+
* Test that get_subscriber_tags() returns the expected data
3353+
* when the total count is included.
3354+
*
3355+
* @since 2.0.0
3356+
*
3357+
* @return void
3358+
*/
3359+
public function testGetSubscriberTagsWithTotalCount()
3360+
{
3361+
$result = $this->api->get_subscriber_tags(
3362+
subscriber_id: (int) $_ENV['CONVERTKIT_API_SUBSCRIBER_ID'],
3363+
include_total_count: true
3364+
);
3365+
3366+
// Assert tags and pagination exist.
3367+
$this->assertDataExists($result, 'tags');
3368+
$this->assertPaginationExists($result);
3369+
3370+
// Assert total count is included.
3371+
$this->assertArrayHasKey('total_count', get_object_vars($result->pagination));
3372+
$this->assertGreaterThan(0, $result->pagination->total_count);
3373+
}
3374+
32103375
/**
32113376
* Test that get_subscriber_tags() throws a ClientException when an invalid
32123377
* subscriber ID is specified.

0 commit comments

Comments
 (0)