Skip to content

Commit

Permalink
Add missing test for personal invitations
Browse files Browse the repository at this point in the history
  • Loading branch information
carlobeltrame committed Apr 13, 2024
1 parent e18b379 commit f79cbfb
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions api/tests/Api/PersonalInvitations/ListPersonalInvitationsTest.php
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' => [],
],
]);
}
}

0 comments on commit f79cbfb

Please sign in to comment.