@@ -1775,6 +1775,49 @@ public function testUpdateTagNameWithBlankName()
17751775 );
17761776 }
17771777
1778+ /**
1779+ * Test that get_subscriber_stats() returns the expected data
1780+ * when using a valid subscriber ID.
1781+ *
1782+ * @since 2.2.1
1783+ *
1784+ * @return void
1785+ */
1786+ public function testGetSubscriberStats ()
1787+ {
1788+ $ result = $ this ->api ->get_subscriber_stats (
1789+ id: (int ) $ _ENV ['CONVERTKIT_API_SUBSCRIBER_ID ' ]
1790+ );
1791+ $ this ->assertArrayHasKey ('subscriber ' , get_object_vars ($ result ));
1792+ $ this ->assertArrayHasKey ('id ' , get_object_vars ($ result ->subscriber ));
1793+ $ this ->assertArrayHasKey ('stats ' , get_object_vars ($ result ->subscriber ));
1794+ $ this ->assertArrayHasKey ('sent ' , get_object_vars ($ result ->subscriber ->stats ));
1795+ $ this ->assertArrayHasKey ('opened ' , get_object_vars ($ result ->subscriber ->stats ));
1796+ $ this ->assertArrayHasKey ('clicked ' , get_object_vars ($ result ->subscriber ->stats ));
1797+ $ this ->assertArrayHasKey ('bounced ' , get_object_vars ($ result ->subscriber ->stats ));
1798+ $ this ->assertArrayHasKey ('open_rate ' , get_object_vars ($ result ->subscriber ->stats ));
1799+ $ this ->assertArrayHasKey ('click_rate ' , get_object_vars ($ result ->subscriber ->stats ));
1800+ $ this ->assertArrayHasKey ('last_sent ' , get_object_vars ($ result ->subscriber ->stats ));
1801+ $ this ->assertArrayHasKey ('last_opened ' , get_object_vars ($ result ->subscriber ->stats ));
1802+ $ this ->assertArrayHasKey ('last_clicked ' , get_object_vars ($ result ->subscriber ->stats ));
1803+ $ this ->assertArrayHasKey ('sends_since_last_open ' , get_object_vars ($ result ->subscriber ->stats ));
1804+ $ this ->assertArrayHasKey ('sends_since_last_click ' , get_object_vars ($ result ->subscriber ->stats ));
1805+ }
1806+
1807+ /**
1808+ * Test that get_subscriber_stats() throws a ClientException when an invalid
1809+ * subscriber ID is specified.
1810+ *
1811+ * @since 2.2.1
1812+ *
1813+ * @return void
1814+ */
1815+ public function testGetSubscriberStatsWithInvalidSubscriberID ()
1816+ {
1817+ $ this ->expectException (ClientException::class);
1818+ $ result = $ this ->api ->get_subscriber_stats (12345 );
1819+ }
1820+
17781821 /**
17791822 * Test that tag_subscriber_by_email() returns the expected data.
17801823 *
0 commit comments