Skip to content

Commit 1219099

Browse files
committed
chore(unit-tests): fix OAuth2SummitOrders, MediaUpload, Notifications, OrderExtraQuestion, PresentationAction, PresentationActionType tests
chore(ci): add OAuth2SummitMediaFileTypeApiControllerTest, OAuth2SummitMediaUploadTypeApiControllerTest, OAuth2SummitMetricsApiControllerTest, OAuth2SummitNotificationsApiControllerTest, OAuth2SummitOrderExtraQuestionTypeApiTest, OAuth2SummitOrdersApiTest, OAuth2SummitPresentationActionApiTest, OAuth2SummitPresentationActionTypeApiTest
1 parent 340215a commit 1219099

8 files changed

Lines changed: 198 additions & 173 deletions

.github/workflows/push.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ jobs:
115115
- { name: "OAuth2SummitAttendeeBadgePrintApiControllerTest", filter: "--filter tests/OAuth2SummitAttendeeBadgePrintApiControllerTest" }
116116
- { name: "OAuth2SummitAttendeeNotesApiTest", filter: "--filter tests/OAuth2SummitAttendeeNotesApiTest" }
117117
- { name: "OAuth2SummitBadgeFeatureTypeApiTest", filter: "--filter tests/OAuth2SummitBadgeFeatureTypeApiTest" }
118+
- { name: "OAuth2SummitMediaFileTypeApiControllerTest", filter: "--filter tests/OAuth2SummitMediaFileTypeApiControllerTest" }
119+
- { name: "OAuth2SummitMediaUploadTypeApiControllerTest", filter: "--filter tests/OAuth2SummitMediaUploadTypeApiControllerTest" }
120+
- { name: "OAuth2SummitMetricsApiControllerTest", filter: "--filter tests/OAuth2SummitMetricsApiControllerTest" }
121+
- { name: "OAuth2SummitNotificationsApiControllerTest", filter: "--filter tests/OAuth2SummitNotificationsApiControllerTest" }
122+
- { name: "OAuth2SummitOrderExtraQuestionTypeApiTest", filter: "--filter tests/OAuth2SummitOrderExtraQuestionTypeApiTest" }
123+
- { name: "OAuth2SummitOrdersApiTest", filter: "--filter tests/OAuth2SummitOrdersApiTest" }
124+
- { name: "OAuth2SummitPresentationActionApiTest", filter: "--filter tests/OAuth2SummitPresentationActionApiTest" }
125+
- { name: "OAuth2SummitPresentationActionTypeApiTest", filter: "--filter tests/OAuth2SummitPresentationActionTypeApiTest" }
118126
env:
119127
OTEL_SERVICE_ENABLED: false
120128
APP_ENV: testing

tests/InsertSummitTestData.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,9 @@ protected static function clearSummitTestData(){
10081008
self::$em->remove(self::$summit);
10091009
self::$em->remove(self::$summit2);
10101010
self::$em->remove(self::$summit_permission_group);
1011-
self::$em->remove(self::$default_media_file_type);
1011+
if (!is_null(self::$default_media_file_type)) {
1012+
self::$em->remove(self::$default_media_file_type);
1013+
}
10121014
self::$em->flush();
10131015

10141016
// reset static vars

tests/OAuth2SummitMediaUploadTypeApiControllerTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public function testAddGet(){
6060
'description' => 'this is a description',
6161
'max_size' => 2048,
6262
'is_mandatory' => false,
63+
'is_editable' => true,
6364
'private_storage_type' => \App\Models\Utils\IStorageTypesConstants::DropBox,
6465
'public_storage_type' => \App\Models\Utils\IStorageTypesConstants::Swift,
6566
'presentation_types' => [$event_types[0]->getId()],
@@ -124,6 +125,7 @@ public function testAddAndDeleteCascade(){
124125
'description' => 'this is a description',
125126
'max_size' => 2048,
126127
'is_mandatory' => false,
128+
'is_editable' => true,
127129
'private_storage_type' => \App\Models\Utils\IStorageTypesConstants::DropBox,
128130
'public_storage_type' => \App\Models\Utils\IStorageTypesConstants::Swift,
129131
'presentation_types' => [$event_types[0]->getId()]
@@ -171,6 +173,7 @@ public function testAddDelete(){
171173
'description' => 'this is a description',
172174
'max_size' => 2048,
173175
'is_mandatory' => false,
176+
'is_editable' => true,
174177
'private_storage_type' => \App\Models\Utils\IStorageTypesConstants::DropBox,
175178
'public_storage_type' => \App\Models\Utils\IStorageTypesConstants::Swift,
176179
'presentation_types' => [ $event_types[0]->getId() ]
@@ -203,7 +206,7 @@ public function testAddDelete(){
203206
"OAuth2SummitMediaUploadTypeApiController@delete",
204207
[
205208
'id' => self::$summit->getId(),
206-
'type_id' => intval($response['id'])
209+
'media_upload_type_id' => intval($response['id'])
207210
],
208211
[],
209212
[],
@@ -230,6 +233,7 @@ public function testAddAddPresentationType(){
230233
'description' => 'this is a description',
231234
'max_size' => 2048,
232235
'is_mandatory' => false,
236+
'is_editable' => true,
233237
'private_storage_type' => \App\Models\Utils\IStorageTypesConstants::DropBox,
234238
'public_storage_type' => \App\Models\Utils\IStorageTypesConstants::Swift,
235239
];
@@ -260,8 +264,8 @@ public function testAddAddPresentationType(){
260264
"OAuth2SummitMediaUploadTypeApiController@addToPresentationType",
261265
[
262266
'id' => self::$summit->getId(),
263-
'type_id' => intval($response['id']),
264-
'presentation_type_id' => $event_types[0]->getId()
267+
'media_upload_type_id' => intval($response['id']),
268+
'event_type_id' => $event_types[0]->getId()
265269
],
266270
[],
267271
[],

tests/OAuth2SummitNotificationsApiControllerTest.php

Lines changed: 54 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,24 @@
1717
*/
1818
final class OAuth2SummitNotificationsApiControllerTest extends ProtectedApiTestCase
1919
{
20-
/**
21-
* @param int $summit_id
22-
* @return mixed
23-
*/
24-
public function testGetApprovedSummitNotifications($summit_id = 27)
20+
use InsertSummitTestData;
21+
22+
protected function setUp(): void
23+
{
24+
parent::setUp();
25+
self::insertSummitTestData();
26+
}
27+
28+
protected function tearDown(): void
29+
{
30+
self::clearSummitTestData();
31+
parent::tearDown();
32+
}
33+
34+
public function testGetApprovedSummitNotifications()
2535
{
2636
$params = [
27-
'id' => $summit_id,
37+
'id' => self::$summit->getId(),
2838
'page' => 1,
2939
'per_page' => 15,
3040
'order' => '+sent_date',
@@ -35,13 +45,11 @@ public function testGetApprovedSummitNotifications($summit_id = 27)
3545
];
3646

3747
$headers = [
38-
3948
"HTTP_Authorization" => " Bearer " . $this->access_token,
4049
"CONTENT_TYPE" => "application/json"
4150
];
4251

43-
$response = $this->action
44-
(
52+
$response = $this->action(
4553
"GET",
4654
"OAuth2SummitNotificationsApiController@getAll",
4755
$params,
@@ -60,29 +68,21 @@ public function testGetApprovedSummitNotifications($summit_id = 27)
6068
return $notifications;
6169
}
6270

63-
/**
64-
* @param int $summit_id
65-
* @return mixed
66-
*/
67-
public function testGetSentSummitNotifications($summit_id = 27)
71+
public function testGetSentSummitNotifications()
6872
{
6973
$params = [
70-
'id' => $summit_id,
74+
'id' => self::$summit->getId(),
7175
'page' => 1,
7276
'per_page' => 15,
7377
'order' => '+sent_date',
74-
// 'filter' => 'message=@Shanghai',
75-
//'expand' => 'owner,approved_by',
7678
];
7779

7880
$headers = [
79-
8081
"HTTP_Authorization" => " Bearer " . $this->access_token,
8182
"CONTENT_TYPE" => "application/json"
8283
];
8384

84-
$response = $this->action
85-
(
85+
$response = $this->action(
8686
"GET",
8787
"OAuth2SummitNotificationsApiController@getAllApprovedByUser",
8888
$params,
@@ -101,93 +101,79 @@ public function testGetSentSummitNotifications($summit_id = 27)
101101
return $notifications;
102102
}
103103

104-
/**
105-
* @param int $summit_id
106-
* @return mixed
107-
*/
108-
public function testGetPushNotificationById($summit_id = 24){
109-
$notifications_response = $this->testGetApprovedSummitNotifications($summit_id);
104+
public function testAddPushNotificationEveryone(){
110105

111106
$params = [
112-
'id' => $summit_id,
113-
'notification_id' => $notifications_response->data[0]->id
107+
'id' => self::$summit->getId(),
114108
];
115109

116-
$headers = [
110+
$message = str_random(16).'_message';
111+
112+
$data = [
113+
'message' => $message,
114+
'channel' => \models\summit\SummitPushNotificationChannel::Everyone,
115+
'platform' => \models\summit\SummitPushNotification::PlatformMobile,
116+
];
117117

118+
$headers = [
118119
"HTTP_Authorization" => " Bearer " . $this->access_token,
119-
"CONTENT_TYPE" => "application/json"
120+
"CONTENT_TYPE" => "application/json"
120121
];
121122

122-
$response = $this->action
123-
(
124-
"GET",
125-
"OAuth2SummitNotificationsApiController@getById",
123+
$response = $this->action(
124+
"POST",
125+
"OAuth2SummitNotificationsApiController@addPushNotification",
126126
$params,
127127
[],
128128
[],
129129
[],
130-
$headers
130+
$headers,
131+
json_encode($data)
131132
);
132133

133134
$content = $response->getContent();
134-
$this->assertResponseStatus(200);
135-
135+
$this->assertResponseStatus(201);
136136
$notification = json_decode($content);
137137
$this->assertTrue(!is_null($notification));
138-
139138
return $notification;
140139
}
141140

142-
/**
143-
* @param int $summit_id
144-
* @return mixed
145-
*/
146-
public function testAddPushNotificationEveryone($summit_id = 24){
141+
public function testGetPushNotificationById(){
142+
$notification = $this->testAddPushNotificationEveryone();
147143

148144
$params = [
149-
'id' => $summit_id,
150-
];
151-
152-
$message = str_random(16).'_message';
153-
154-
$data = [
155-
'message' => $message,
156-
'channel' => \models\summit\SummitPushNotificationChannel::Everyone,
157-
'platform' => \models\summit\SummitPushNotification::PlatformMobile,
145+
'id' => self::$summit->getId(),
146+
'notification_id' => $notification->id
158147
];
159148

160149
$headers = [
161150
"HTTP_Authorization" => " Bearer " . $this->access_token,
162-
"CONTENT_TYPE" => "application/json"
151+
"CONTENT_TYPE" => "application/json"
163152
];
164153

165154
$response = $this->action(
166-
"POST",
167-
"OAuth2SummitNotificationsApiController@addPushNotification",
155+
"GET",
156+
"OAuth2SummitNotificationsApiController@getById",
168157
$params,
169158
[],
170159
[],
171160
[],
172-
$headers,
173-
json_encode($data)
161+
$headers
174162
);
175163

176164
$content = $response->getContent();
177-
$this->assertResponseStatus(201);
165+
$this->assertResponseStatus(200);
166+
178167
$notification = json_decode($content);
179168
$this->assertTrue(!is_null($notification));
169+
180170
return $notification;
181171
}
182172

183-
/**
184-
* @param int $summit_id
185-
* @return mixed
186-
*/
187-
public function testAddPushNotificationMembersFail($summit_id = 24){
173+
public function testAddPushNotificationMembersFail(){
188174

189175
$params = [
190-
'id' => $summit_id,
176+
'id' => self::$summit->getId(),
191177
];
192178

193179
$message = str_random(16).'_message';
@@ -218,14 +204,10 @@ public function testAddPushNotificationMembersFail($summit_id = 24){
218204
$this->assertResponseStatus(412);
219205
}
220206

221-
/**
222-
* @param int $summit_id
223-
* @return mixed
224-
*/
225-
public function testAddPushNotificationMembers($summit_id = 24){
207+
public function testAddPushNotificationMembers(){
226208

227209
$params = [
228-
'id' => $summit_id,
210+
'id' => self::$summit->getId(),
229211
];
230212

231213
$message = str_random(16).'_message';
@@ -234,7 +216,7 @@ public function testAddPushNotificationMembers($summit_id = 24){
234216
'message' => $message,
235217
'channel' => \models\summit\SummitPushNotificationChannel::Members,
236218
'platform' => \models\summit\SummitPushNotification::PlatformMobile,
237-
'recipient_ids' => [13867]
219+
'recipient_ids' => [self::$member->getId()]
238220
];
239221

240222
$headers = [
@@ -259,4 +241,4 @@ public function testAddPushNotificationMembers($summit_id = 24){
259241
$this->assertTrue(!is_null($notification));
260242
return $notification;
261243
}
262-
}
244+
}

tests/OAuth2SummitOrderExtraQuestionTypeApiTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,11 @@ final class OAuth2SummitOrderExtraQuestionTypeApiTest extends ProtectedApiTestCa
3131

3232
use InsertSummitTestData;
3333

34-
use InsertMemberTestData;
35-
3634
protected function setUp():void
3735
{
3836
parent::setUp();
3937
self::$defaultMember = self::$member;
4038
self::insertSummitTestData();
41-
self::insertMemberTestData(IGroup::TrackChairs);
4239
self::$summit_permission_group->addMember(self::$member);
4340
self::$em->persist(self::$summit);
4441
self::$em->persist(self::$summit_permission_group);
@@ -47,7 +44,6 @@ protected function setUp():void
4744

4845
protected function tearDown():void
4946
{
50-
self::clearMemberTestData();
5147
self::clearSummitTestData();
5248
parent::tearDown();
5349
}
@@ -96,9 +92,11 @@ public function testAddExtraOrderQuestion(){
9692

9793
public function testUpdateExtraOrderQuestion(){
9894

95+
$question = $this->testAddExtraOrderQuestion();
96+
9997
$params = [
10098
'id' => self::$summit->getId(),
101-
'question_id' => self::$summit->getOrderExtraQuestions()->first()
99+
'question_id' => $question->id
102100
];
103101

104102
$name = str_random(16).'_question';

0 commit comments

Comments
 (0)