forked from ecamp/ecamp3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing test for personal invitations
- Loading branch information
1 parent
e18b379
commit f79cbfb
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
api/tests/Api/PersonalInvitations/ListPersonalInvitationsTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace App\Tests\Api\PersonalInvitations; | ||
|
||
use App\Entity\User; | ||
use App\Tests\Api\ECampApiTestCase; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
class ListPersonalInvitationsTest extends ECampApiTestCase { | ||
public function testListPersonalInvitationsIsDeniedForAnonymousUser() { | ||
static::createBasicClient()->request('GET', '/personal_invitations'); | ||
$this->assertResponseStatusCodeSame(401); | ||
$this->assertJsonContains([ | ||
'code' => 401, | ||
'message' => 'JWT Token not found', | ||
]); | ||
} | ||
|
||
public function testListPersonalInvitationsIsAllowedForLoggedInUserButFiltered() { | ||
/** @var User $user */ | ||
$user = static::getFixture('user6invited'); | ||
$client = static::createClientWithCredentials(['email' => $user->getProfile()->email]); | ||
$client->request('GET', '/personal_invitations'); | ||
$this->assertResponseStatusCodeSame(200); | ||
$invitation = static::getFixture('campCollaboration6invitedWithUser'); | ||
$this->assertJsonContains([ | ||
'totalItems' => 1, | ||
'_links' => [ | ||
'items' => [ | ||
['href' => "/personal_invitations/{$invitation->getId()}"] | ||
], | ||
], | ||
'_embedded' => [ | ||
'items' => [], | ||
], | ||
]); | ||
} | ||
} |