@@ -1722,6 +1722,49 @@ public function testCreateTagsThatExist()
17221722 $ this ->assertEquals ($ result ->tags [0 ]->name , $ _ENV ['CONVERTKIT_API_TAG_NAME_2 ' ]);
17231723 }
17241724
1725+ /**
1726+ * Test that get_subscriber_stats() returns the expected data
1727+ * when using a valid subscriber ID.
1728+ *
1729+ * @since 2.2.1
1730+ *
1731+ * @return void
1732+ */
1733+ public function testGetSubscriberStats ()
1734+ {
1735+ $ result = $ this ->api ->get_subscriber_stats (
1736+ id: (int ) $ _ENV ['CONVERTKIT_API_SUBSCRIBER_ID ' ]
1737+ );
1738+ $ this ->assertArrayHasKey ('subscriber ' , get_object_vars ($ result ));
1739+ $ this ->assertArrayHasKey ('id ' , get_object_vars ($ result ->subscriber ));
1740+ $ this ->assertArrayHasKey ('stats ' , get_object_vars ($ result ->subscriber ));
1741+ $ this ->assertArrayHasKey ('sent ' , get_object_vars ($ result ->subscriber ->stats ));
1742+ $ this ->assertArrayHasKey ('opened ' , get_object_vars ($ result ->subscriber ->stats ));
1743+ $ this ->assertArrayHasKey ('clicked ' , get_object_vars ($ result ->subscriber ->stats ));
1744+ $ this ->assertArrayHasKey ('bounced ' , get_object_vars ($ result ->subscriber ->stats ));
1745+ $ this ->assertArrayHasKey ('open_rate ' , get_object_vars ($ result ->subscriber ->stats ));
1746+ $ this ->assertArrayHasKey ('click_rate ' , get_object_vars ($ result ->subscriber ->stats ));
1747+ $ this ->assertArrayHasKey ('last_sent ' , get_object_vars ($ result ->subscriber ->stats ));
1748+ $ this ->assertArrayHasKey ('last_opened ' , get_object_vars ($ result ->subscriber ->stats ));
1749+ $ this ->assertArrayHasKey ('last_clicked ' , get_object_vars ($ result ->subscriber ->stats ));
1750+ $ this ->assertArrayHasKey ('sends_since_last_open ' , get_object_vars ($ result ->subscriber ->stats ));
1751+ $ this ->assertArrayHasKey ('sends_since_last_click ' , get_object_vars ($ result ->subscriber ->stats ));
1752+ }
1753+
1754+ /**
1755+ * Test that get_subscriber_stats() throws a ClientException when an invalid
1756+ * subscriber ID is specified.
1757+ *
1758+ * @since 2.2.1
1759+ *
1760+ * @return void
1761+ */
1762+ public function testGetSubscriberStatsWithInvalidSubscriberID ()
1763+ {
1764+ $ this ->expectException (ClientException::class);
1765+ $ result = $ this ->api ->get_subscriber_stats (12345 );
1766+ }
1767+
17251768 /**
17261769 * Test that tag_subscriber_by_email() returns the expected data.
17271770 *
0 commit comments