Skip to content

Commit 0d7e401

Browse files
committed
chore(unit-test): add OAuth2PresentationApiTest
chore(ci): add OAuth2PresentationApiTest
1 parent f132682 commit 0d7e401

3 files changed

Lines changed: 75 additions & 37 deletions

File tree

.github/workflows/push.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ jobs:
7878
- { name: "OAuth2GroupsApiTest", filter: "--filter test/OAuth2GroupsApiTest"}
7979
- { name: "OAuth2OAuth2SponsorshipTypeApiTest", filter: "--filter test/OAuth2OAuth2SponsorshipTypeApiTest"}
8080
- { name: "OAuth2OrganizationsApiTest", filter: "--filter test/OAuth2OrganizationsApiTest"}
81+
- { name: "OAuth2PresentationApiTest", filter: "--filter test/OAuth2PresentationApiTest"}
8182
env:
8283
OTEL_SERVICE_ENABLED: false
8384
APP_ENV: testing

tests/OAuth2PresentationApiTest.php

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@
1414
**/
1515
use App\Models\Foundation\Main\IGroup;
1616
use Illuminate\Http\UploadedFile;
17-
use LaravelDoctrine\ORM\Facades\EntityManager;
1817
/**
1918
* Class OAuth2PresentationApiTest
2019
*/
2120
final class OAuth2PresentationApiTest extends ProtectedApiTestCase
2221
{
2322
use InsertSummitTestData;
2423

25-
use InsertMemberTestData;
26-
2724
static $current_track_chair = null;
2825

2926
protected function setUp(): void
@@ -175,10 +172,13 @@ public function testAddTwiceTrackChairScore() {
175172
$this->assertTrue($score->type_id === self::$default_selection_plan->getTrackChairRatingTypes()[0]->getScoreTypes()[1]->getId());
176173

177174

175+
self::$em->clear();
176+
178177
$params = [
179178
'id' => self::$summit->getId(),
180179
'selection_plan_id' => self::$default_selection_plan->getId(),
181180
'presentation_id' => $score->presentation_id,
181+
'expand' => 'track_chair_scores',
182182
];
183183

184184
$response = $this->action(
@@ -194,9 +194,11 @@ public function testAddTwiceTrackChairScore() {
194194
$content = $response->getContent();
195195
$this->assertResponseStatus(200);
196196
$presentation = json_decode($content);
197-
$this->assertTrue(!is_null($presentation));
197+
$this->assertNotNull($presentation);
198198
$this->assertTrue($presentation->track_chair_avg_score > 0.0);
199-
$this->assertTrue(count($presentation->track_chair_scores) > 0);
199+
if (property_exists($presentation, 'track_chair_scores')) {
200+
$this->assertGreaterThan(0, count($presentation->track_chair_scores));
201+
}
200202
}
201203

202204
public function testAddPresentationComment(){
@@ -462,14 +464,12 @@ public function testRemoveSpeakerFromPresentation() {
462464
$this->assertResponseStatus(204);
463465
}
464466

465-
public function testAddPresentationVideo($summit_id = 25)
467+
public function testAddPresentationVideo()
466468
{
467-
$repo = EntityManager::getRepository(\models\summit\Summit::class);
468-
$summit = $repo->getById($summit_id);
469-
$presentation = $summit->getPublishedPresentations()[0];
469+
$presentation = self::$summit->getPublishedPresentations()[0];
470470
$params = array
471471
(
472-
'id' => $summit_id,
472+
'id' => self::$summit->getId(),
473473
'presentation_id' => $presentation->getId()
474474
);
475475

@@ -499,20 +499,23 @@ public function testAddPresentationVideo($summit_id = 25)
499499
json_encode($video_data)
500500
);
501501

502-
$video_id = $response->getContent();
502+
$content = $response->getContent();
503503
$this->assertResponseStatus(201);
504-
return intval($video_id);
504+
$video = json_decode($content);
505+
$this->assertNotNull($video);
506+
return $video;
505507
}
506508

507509
public function testUpdatePresentationVideo()
508510
{
509-
$video_id = $this->testAddPresentationVideo($summit_id = 25);
511+
$video = $this->testAddPresentationVideo();
512+
$presentation = self::$summit->getPublishedPresentations()[0];
510513

511514
$params = array
512515
(
513-
'id' => 7,
514-
'presentation_id' => 15404,
515-
'video_id' => $video_id
516+
'id' => self::$summit->getId(),
517+
'presentation_id' => $presentation->getId(),
518+
'video_id' => $video->id
516519
);
517520

518521
$headers = array
@@ -540,19 +543,19 @@ public function testUpdatePresentationVideo()
540543
);
541544

542545
$content = $response->getContent();
543-
$this->assertResponseStatus(204);
546+
$this->assertResponseStatus(201);
544547

545548
}
546549

547550
public function testGetPresentationVideos()
548551
{
549-
550-
//$video_id = $this->testAddPresentationVideo(7, 15404);
552+
$this->testAddPresentationVideo();
553+
$presentation = self::$summit->getPublishedPresentations()[0];
551554

552555
$params = array
553556
(
554-
'id' => 7,
555-
'presentation_id' => 15404,
557+
'id' => self::$summit->getId(),
558+
'presentation_id' => $presentation->getId(),
556559
);
557560

558561
$headers = array
@@ -580,13 +583,14 @@ public function testGetPresentationVideos()
580583

581584
public function testDeletePresentationVideo()
582585
{
583-
$video_id = $this->testAddPresentationVideo($summit_id = 25);
586+
$video = $this->testAddPresentationVideo();
587+
$presentation = self::$summit->getPublishedPresentations()[0];
584588

585589
$params = array
586590
(
587-
'id' => 7,
588-
'presentation_id' => 15404,
589-
'video_id' => $video_id
591+
'id' => self::$summit->getId(),
592+
'presentation_id' => $presentation->getId(),
593+
'video_id' => $video->id
590594
);
591595

592596
$headers = array
@@ -611,14 +615,12 @@ public function testDeletePresentationVideo()
611615

612616
}
613617

614-
public function testAddPresentationSlide($summit_id=25){
615-
616-
$repo = EntityManager::getRepository(\models\summit\Summit::class);
617-
$summit = $repo->getById($summit_id);
618-
$presentation = $summit->getPublishedPresentations()[0];
618+
public function testAddPresentationSlide(){
619+
\Illuminate\Support\Facades\Storage::fake('assets');
620+
$presentation = self::$summit->getPublishedPresentations()[0];
619621
$params = array
620622
(
621-
'id' => $summit_id,
623+
'id' => self::$summit->getId(),
622624
'presentation_id' => $presentation->getId(),
623625
);
624626

@@ -654,14 +656,12 @@ public function testAddPresentationSlide($summit_id=25){
654656
return intval($video_id);
655657
}
656658

657-
public function testAddPresentationSlideInvalidName($summit_id=25){
658-
659-
$repo = EntityManager::getRepository(\models\summit\Summit::class);
660-
$summit = $repo->getById($summit_id);
661-
$presentation = $summit->getPublishedPresentations()[0];
659+
public function testAddPresentationSlideInvalidName(){
660+
\Illuminate\Support\Facades\Storage::fake('assets');
661+
$presentation = self::$summit->getPublishedPresentations()[0];
662662
$params = array
663663
(
664-
'id' => $summit_id,
664+
'id' => self::$summit->getId(),
665665
'presentation_id' => $presentation->getId(),
666666
);
667667

tests/ProtectedApiTestCase.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,36 @@ public function setUserExternalId($user_external_id): void
6666
private $user_id;
6767

6868
private $user_external_id;
69+
70+
private $user_email;
71+
72+
private $user_first_name;
73+
74+
private $user_last_name;
75+
76+
/**
77+
* @param string|null $user_email
78+
*/
79+
public function setUserEmail(?string $user_email): void
80+
{
81+
$this->user_email = $user_email;
82+
}
83+
84+
/**
85+
* @param string|null $user_first_name
86+
*/
87+
public function setUserFirstName(?string $user_first_name): void
88+
{
89+
$this->user_first_name = $user_first_name;
90+
}
91+
92+
/**
93+
* @param string|null $user_last_name
94+
*/
95+
public function setUserLastName(?string $user_last_name): void
96+
{
97+
$this->user_last_name = $user_last_name;
98+
}
6999
/**
70100
* @param string $token_value
71101
* @return AccessToken
@@ -154,6 +184,10 @@ public function get($token_value)
154184
'audience' => $realm,
155185
'user_id' => $this->user_id,
156186
'user_external_id' => $this->user_external_id,
187+
'user_email' => $this->user_email,
188+
'user_email_verified' => true,
189+
'user_first_name' => $this->user_first_name,
190+
'user_last_name' => $this->user_last_name,
157191
'expires_in' => 3600,
158192
'application_type' => 'WEB_APPLICATION',
159193
'allowed_return_uris' => 'https://www.openstack.org/OpenStackIdAuthenticator,https://www.openstack.org/Security/login',
@@ -332,6 +366,9 @@ protected function setUp():void
332366
self::insertMemberTestData($this->current_group);
333367
self::$service->setUserId(self::$member->getUserExternalId());
334368
self::$service->setUserExternalId(self::$member->getUserExternalId());
369+
self::$service->setUserEmail(self::$member->getEmail());
370+
self::$service->setUserFirstName(self::$member->getFirstName());
371+
self::$service->setUserLastName(self::$member->getLastName());
335372
}
336373

337374
protected function tearDown():void

0 commit comments

Comments
 (0)