Skip to content

Commit 812daae

Browse files
committed
chore(unit-tests): add missing endpoint coverage and fix skipped test
chore(ci): add OAuth2SummitTrackChairsRankingApiTest to GA pipeline
1 parent 1d46bfd commit 812daae

File tree

7 files changed

+410
-17
lines changed

7 files changed

+410
-17
lines changed

.github/workflows/push.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ jobs:
9696
- { name: "OAuth2SummitTicketTypesApiTest", filter: "--filter tests/OAuth2SummitTicketTypesApiTest" }
9797
- { name: "OAuth2SummitTicketsApiTest", filter: "--filter tests/OAuth2SummitTicketsApiTest" }
9898
- { name: "OAuth2SummitTrackChairsApiTest", filter: "--filter tests/OAuth2SummitTrackChairsApiTest" }
99+
- { name: "OAuth2SummitTrackChairsRankingApiTest", filter: "--filter tests/OAuth2SummitTrackChairsRankingApiTest" }
99100
- { name: "OAuth2TrackGroupsApiTest", filter: "--filter tests/OAuth2TrackGroupsApiTest" }
100101
- { name: "OAuth2TrackQuestionsTemplateTest", filter: "--filter tests/OAuth2TrackQuestionsTemplateTest" }
101102
- { name: "OAuth2SummitBadgeTypeApiTest", filter: "--filter tests/OAuth2SummitBadgeTypeApiTest" }

app/Services/Model/Imp/SummitTicketTypeService.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -319,17 +319,6 @@ public function seedSummitTicketTypesFromEventBrite(Summit $summit)
319319
$res[] = $new_ticket_type;
320320
}
321321

322-
foreach ($res as $ticket_type) {
323-
Event::dispatch
324-
(
325-
new SummitTicketTypeInserted
326-
(
327-
$ticket_type->getId(),
328-
$ticket_type->getSummitId()
329-
)
330-
);
331-
}
332-
333322
++$page;
334323
} while ($has_more_items);
335324

@@ -410,4 +399,4 @@ public function updateCurrencySymbol(Summit $summit, string $currency_symbol): v
410399
}
411400
});
412401
}
413-
}
402+
}

tests/OAuth2SummitTicketTypesApiTest.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,28 @@ public function testUpdateTicketType(){
363363
return $ticket_type;
364364
}
365365

366-
/**
367-
* Skipped: SummitTicketTypeService references non-existent class
368-
* App\Services\Model\SummitTicketTypeInserted at line 325.
369-
*/
370366
public function testSeedDefaultTicketTypes(){
371-
$this->markTestSkipped('Service references missing class App\Services\Model\SummitTicketTypeInserted');
367+
$params = [
368+
'id' => self::$summit->getId(),
369+
];
370+
371+
$headers = [
372+
"HTTP_Authorization" => " Bearer " . $this->access_token,
373+
"CONTENT_TYPE" => "application/json"
374+
];
375+
376+
$response = $this->action(
377+
"POST",
378+
"OAuth2SummitsTicketTypesApiController@seedDefaultTicketTypesBySummit",
379+
$params,
380+
[],
381+
[],
382+
[],
383+
$headers
384+
);
385+
386+
// 412 expected: test summit has external_summit_id but no external_registration_feed_api_key
387+
$this->assertResponseStatus(412);
372388
}
373389

374390
public function testUpdateTicketTypesCurrencySymbol(){

tests/OAuth2SummitTrackChairsApiTest.php

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,149 @@ public function testAddTrackChairAndAddCategory(){
278278
$this->assertTrue(count($track_chair->categories) == 2);
279279
}
280280

281+
public function testGetAllTrackChairsCSV(){
282+
$params = [
283+
'id' => self::$summit->getId(),
284+
];
285+
286+
$headers = [
287+
"HTTP_Authorization" => " Bearer " . $this->access_token,
288+
"CONTENT_TYPE" => "application/json"
289+
];
290+
291+
$response = $this->action(
292+
"GET",
293+
"OAuth2SummitTrackChairsApiController@getAllBySummitCSV",
294+
$params,
295+
[],
296+
[],
297+
[],
298+
$headers
299+
);
300+
301+
$this->assertResponseStatus(200);
302+
$content = $response->getContent();
303+
$this->assertNotEmpty($content);
304+
}
305+
306+
public function testGetTrackChairById(){
307+
308+
$params = [
309+
'id' => self::$summit->getId(),
310+
'expand' => 'member,categories'
311+
];
312+
313+
$data = [
314+
'member_id' => self::$member2->getId(),
315+
'categories' => [self::$defaultTrack->getId()]
316+
];
317+
318+
$headers = [
319+
"HTTP_Authorization" => " Bearer " . $this->access_token,
320+
"CONTENT_TYPE" => "application/json"
321+
];
322+
323+
$response = $this->action(
324+
"POST",
325+
"OAuth2SummitTrackChairsApiController@add",
326+
$params,
327+
[],
328+
[],
329+
[],
330+
$headers,
331+
json_encode($data)
332+
);
333+
334+
$content = $response->getContent();
335+
$this->assertResponseStatus(201);
336+
$track_chair = json_decode($content);
337+
$this->assertTrue(!is_null($track_chair));
338+
339+
// now get by id
340+
$params = [
341+
'id' => self::$summit->getId(),
342+
'track_chair_id' => $track_chair->id,
343+
'expand' => 'member,categories'
344+
];
345+
346+
$headers = [
347+
"HTTP_Authorization" => " Bearer " . $this->access_token,
348+
"CONTENT_TYPE" => "application/json"
349+
];
350+
351+
$response = $this->action(
352+
"GET",
353+
"OAuth2SummitTrackChairsApiController@get",
354+
$params,
355+
[],
356+
[],
357+
[],
358+
$headers
359+
);
360+
361+
$content = $response->getContent();
362+
$this->assertResponseStatus(200);
363+
$track_chair_fetched = json_decode($content);
364+
$this->assertTrue(!is_null($track_chair_fetched));
365+
$this->assertEquals($track_chair->id, $track_chair_fetched->id);
366+
}
367+
368+
public function testDeleteTrackChair(){
369+
370+
$params = [
371+
'id' => self::$summit->getId(),
372+
];
373+
374+
$data = [
375+
'member_id' => self::$member2->getId(),
376+
'categories' => [self::$defaultTrack->getId()]
377+
];
378+
379+
$headers = [
380+
"HTTP_Authorization" => " Bearer " . $this->access_token,
381+
"CONTENT_TYPE" => "application/json"
382+
];
383+
384+
$response = $this->action(
385+
"POST",
386+
"OAuth2SummitTrackChairsApiController@add",
387+
$params,
388+
[],
389+
[],
390+
[],
391+
$headers,
392+
json_encode($data)
393+
);
394+
395+
$content = $response->getContent();
396+
$this->assertResponseStatus(201);
397+
$track_chair = json_decode($content);
398+
$this->assertTrue(!is_null($track_chair));
399+
400+
// now delete
401+
$params = [
402+
'id' => self::$summit->getId(),
403+
'track_chair_id' => $track_chair->id,
404+
];
405+
406+
$headers = [
407+
"HTTP_Authorization" => " Bearer " . $this->access_token,
408+
"CONTENT_TYPE" => "application/json"
409+
];
410+
411+
$response = $this->action(
412+
"DELETE",
413+
"OAuth2SummitTrackChairsApiController@delete",
414+
$params,
415+
[],
416+
[],
417+
[],
418+
$headers
419+
);
420+
421+
$this->assertResponseStatus(204);
422+
}
423+
281424
public function testAddTrackChairAndDeleteCategory(){
282425

283426
$params = [

tests/OAuth2SummitTracksApiTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,4 +435,32 @@ public function testRemoveSubTrack(){
435435

436436
$this->assertResponseStatus(204);
437437
}
438+
439+
public function testCopyTracksToSummit(){
440+
441+
$params = [
442+
'id' => self::$summit->getId(),
443+
'to_summit_id' => self::$summit2->getId()
444+
];
445+
446+
$headers = [
447+
"HTTP_Authorization" => " Bearer " . $this->access_token,
448+
"CONTENT_TYPE" => "application/json"
449+
];
450+
451+
$response = $this->action(
452+
"POST",
453+
"OAuth2SummitTracksApiController@copyTracksToSummit",
454+
$params,
455+
[],
456+
[],
457+
[],
458+
$headers
459+
);
460+
461+
$this->assertResponseStatus(201);
462+
$content = $response->getContent();
463+
$tracks = json_decode($content);
464+
$this->assertNotNull($tracks);
465+
}
438466
}

0 commit comments

Comments
 (0)