@@ -1627,9 +1627,24 @@ public function testGetTagsPagination()
16271627 public function testCreateTag ()
16281628 {
16291629 $ tagName = 'Tag Test ' . mt_rand ();
1630+
1631+ // Add mock handler for this API request, as the API doesn't provide
1632+ // a method to delete tags to cleanup the test.
1633+ $ this ->api = $ this ->mockResponse (
1634+ api: $ this ->api ,
1635+ responseBody: [
1636+ 'tag ' => [
1637+ 'id ' => 12345 ,
1638+ 'name ' => $ tagName ,
1639+ 'created_at ' => date ('Y-m-d ' ) . 'T ' . date ('H:i:s ' ) . 'Z ' ,
1640+ ],
1641+ ]
1642+ );
1643+
1644+ // Send request.
16301645 $ result = $ this ->api ->create_tag ($ tagName );
16311646
1632- // Convert to array to check for keys, as assertObjectHasAttribute() will be deprecated in PHPUnit 10 .
1647+ // Assert response contains correct data .
16331648 $ tag = get_object_vars ($ result ->tag );
16341649 $ this ->assertArrayHasKey ('id ' , $ tag );
16351650 $ this ->assertArrayHasKey ('name ' , $ tag );
@@ -1678,6 +1693,28 @@ public function testCreateTags()
16781693 'Tag Test ' . mt_rand (),
16791694 'Tag Test ' . mt_rand (),
16801695 ];
1696+
1697+ // Add mock handler for this API request, as the API doesn't provide
1698+ // a method to delete tags to cleanup the test.
1699+ $ this ->api = $ this ->mockResponse (
1700+ api: $ this ->api ,
1701+ responseBody: [
1702+ 'tags ' => [
1703+ [
1704+ 'id ' => 12345 ,
1705+ 'name ' => $ tagNames [0 ],
1706+ 'created_at ' => date ('Y-m-d ' ) . 'T ' . date ('H:i:s ' ) . 'Z ' ,
1707+ ],
1708+ [
1709+ 'id ' => 23456 ,
1710+ 'name ' => $ tagNames [1 ],
1711+ 'created_at ' => date ('Y-m-d ' ) . 'T ' . date ('H:i:s ' ) . 'Z ' ,
1712+ ],
1713+ ],
1714+ 'failures ' => [],
1715+ ]
1716+ );
1717+
16811718 $ result = $ this ->api ->create_tags ($ tagNames );
16821719
16831720 // Assert no failures.
0 commit comments