@@ -31,7 +31,43 @@ public function testGetListOfSpecificIds()
31
31
32
32
public function testCreateGetAndDelete ()
33
33
{
34
- $ this ->standardTestCreateGetAndDelete ();
34
+ // Create category
35
+ $ response = $ this ->api ->create ($ this ->testPayload );
36
+ $ this ->assertErrors ($ response );
37
+ $ this ->assertPayload ($ response , $ this ->testPayload );
38
+ $ categoryId = $ response [$ this ->api ->itemName ()]['id ' ];
39
+
40
+ // GET category
41
+ $ response = $ this ->api ->get ($ categoryId );
42
+ $ this ->assertErrors ($ response );
43
+ $ this ->assertPayload ($ response , $ this ->testPayload );
44
+
45
+ // Add an asset to this category
46
+ $ assetApi = $ this ->getContext ('assets ' );
47
+ $ assetPayload = array (
48
+ 'title ' => 'Mautic Logo sent as a API request ' ,
49
+ 'storageLocation ' => 'remote ' ,
50
+ 'file ' => 'https://www.mautic.org/media/logos/logo/Mautic_Logo_DB.pdf ' ,
51
+ 'category ' => $ categoryId ,
52
+ );
53
+
54
+ // Create Asset
55
+ $ assetResponse = $ assetApi ->create ($ assetPayload );
56
+ $ assetCategory = $ assetResponse [$ assetApi ->itemName ()]['category ' ];
57
+ $ this ->assertEquals ($ categoryId , $ assetCategory ['id ' ]);
58
+ $ this ->assertErrors ($ assetPayload );
59
+
60
+ // Delete asset
61
+ $ response = $ assetApi ->delete ($ assetResponse [$ assetApi ->itemName ()]['id ' ]);
62
+ $ this ->assertErrors ($ response );
63
+
64
+ // Delete category
65
+ $ response = $ this ->api ->delete ($ categoryId );
66
+ $ this ->assertErrors ($ response );
67
+
68
+ // Expect an error when assigning a non existing category when creating a new asset
69
+ $ assetResponse = $ assetApi ->create ($ assetPayload );
70
+ $ this ->assertContains ("Category $ categoryId does not exist " , $ assetResponse ['errors ' ][0 ]['message ' ]);
35
71
}
36
72
37
73
public function testEditPatch ()
0 commit comments