@@ -1627,9 +1627,24 @@ public function testGetTagsPagination()
1627
1627
public function testCreateTag ()
1628
1628
{
1629
1629
$ 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.
1630
1645
$ result = $ this ->api ->create_tag ($ tagName );
1631
1646
1632
- // Convert to array to check for keys, as assertObjectHasAttribute() will be deprecated in PHPUnit 10 .
1647
+ // Assert response contains correct data .
1633
1648
$ tag = get_object_vars ($ result ->tag );
1634
1649
$ this ->assertArrayHasKey ('id ' , $ tag );
1635
1650
$ this ->assertArrayHasKey ('name ' , $ tag );
@@ -1678,6 +1693,28 @@ public function testCreateTags()
1678
1693
'Tag Test ' . mt_rand (),
1679
1694
'Tag Test ' . mt_rand (),
1680
1695
];
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
+
1681
1718
$ result = $ this ->api ->create_tags ($ tagNames );
1682
1719
1683
1720
// Assert no failures.
0 commit comments