Skip to content

Commit 99e5326

Browse files
committed
fix ci/cd
1 parent 8e8d694 commit 99e5326

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ jobs:
6565
DB_PORT: 3306
6666
run: bin/cake migrations migrate -c test
6767

68-
- name: Debug MySQL
69-
run: |
70-
mysql -h 127.0.0.1 -uroot -proot -e "SHOW DATABASES;"
71-
mysql -h 127.0.0.1 -uroot -proot -e "USE game_on_test; SHOW TABLES;"
72-
7368
- name: Run unit tests
7469
working-directory: app
7570
env:

app/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@
5151
],
5252
"cs-check": "phpcs --colors -p",
5353
"cs-fix": "phpcbf --colors -p",
54-
"unit-tests": "phpunit --colors=always --debug"
54+
"unit-tests": "phpunit --colors=always"
5555
}
5656
}

app/tests/TestCase/Controller/Api/EventsControllerTest.php

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

app/tests/bootstrap.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
Configure::write('App.fullBaseUrl', 'http://localhost');
3535
}
3636

37-
Configure::write('debug', true);
38-
3937
// Fixate now to avoid one-second-leap-issues
4038
Chronos::setTestNow(Chronos::now());
4139

0 commit comments

Comments
 (0)