@@ -125,27 +125,37 @@ public function testGetEvents(): void
125125 }
126126
127127 /**
128- * Test deleting an event (DELETE request)
128+ * Test deleting events (DELETE request)
129129 */
130130 public function testDeleteEvent (): void
131131 {
132- $ event = $ this -> Events -> newEntity ( [
132+ $ createData = [
133133 'name ' => 'Test Event ' ,
134134 'sport ' => 'Running ' ,
135135 'sponsor ' => 'Test Sponsor ' ,
136136 'max_attendees ' => 10 ,
137137 'date_of_event ' => '2026-05-01 ' ,
138138 'location_country_iso ' => 'US ' ,
139+ ];
140+
141+ $ this ->configRequest ([
142+ 'headers ' => [
143+ 'Authorization ' => self ::HOMERS_FIXTURE_TOKEN ,
144+ 'Content-Type ' => 'application/json ' ,
145+ ],
139146 ]);
140- $ this ->Events ->save ($ event );
147+ $ this ->post ('/api/events/create ' , json_encode ($ createData ));
148+ $ response = json_decode ((string )$ this ->_response ->getBody (), true );
149+ $ eventId = $ response ['event ' ]['id ' ];
150+
141151 $ this ->configRequest ([
142152 'headers ' => [
143153 'Authorization ' => self ::HOMERS_FIXTURE_TOKEN ,
144154 'Accept ' => 'application/json ' ,
145155 ],
146156 ]);
147157
148- $ this ->delete ('/api/events/delete/ ' . $ event -> id );
158+ $ this ->delete ('/api/events/delete/ ' . $ eventId );
149159 $ this ->assertResponseCode (200 );
150160 $ this ->assertContentType ('application/json ' );
151161 $ response = json_decode ((string )$ this ->_response ->getBody (), true );
@@ -154,21 +164,35 @@ public function testDeleteEvent(): void
154164 }
155165
156166 /**
157- * Test updating an existing event (PUT request)
167+ * Test updating an existing event (PUT request) via API endpoints
158168 */
159169 public function testUpdateEvent (): void
160170 {
161- $ event = $ this -> Events -> newEntity ( [
171+ $ createData = [
162172 'name ' => 'Old Event Name ' ,
163173 'sport ' => 'Running ' ,
164174 'sponsor ' => 'Old Sponsor ' ,
165175 'max_attendees ' => 10 ,
166176 'date_of_event ' => '2026-05-01 ' ,
167177 'location_country_iso ' => 'US ' ,
178+ ];
179+
180+ $ this ->configRequest ([
181+ 'headers ' => [
182+ 'Authorization ' => self ::HOMERS_FIXTURE_TOKEN ,
183+ 'Content-Type ' => 'application/json ' ,
184+ ],
168185 ]);
169- $ this ->Events ->save ($ event );
186+
187+ $ this ->post ('/api/events/create ' , json_encode ($ createData ));
188+
189+ $ this ->assertResponseCode (201 );
190+ $ response = json_decode ((string )$ this ->_response ->getBody (), true );
191+ $ this ->assertTrue ($ response ['success ' ]);
192+ $ eventId = $ response ['event ' ]['id ' ];
193+
170194 $ updateData = [
171- 'id ' => $ event -> id ,
195+ 'id ' => $ eventId ,
172196 'name ' => 'Updated Event Name ' ,
173197 'sport ' => 'Cycling ' ,
174198 'sponsor ' => 'New Sponsor ' ,
@@ -179,11 +203,11 @@ public function testUpdateEvent(): void
179203 'headers ' => [
180204 'Authorization ' => self ::HOMERS_FIXTURE_TOKEN ,
181205 'Content-Type ' => 'application/json ' ,
182- 'Accept ' => 'application/json ' ,
183206 ],
184207 ]);
185208
186209 $ this ->put ('/api/events/update ' , json_encode ($ updateData ));
210+
187211 $ this ->assertResponseCode (200 );
188212 $ this ->assertContentType ('application/json ' );
189213 $ response = json_decode ((string )$ this ->_response ->getBody (), true );
0 commit comments