Skip to content

Commit

Permalink
fix root route + fix remaining tests
Browse files Browse the repository at this point in the history
  • Loading branch information
usu committed Dec 11, 2022
1 parent e489ad8 commit 2a3d2ff
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 22 deletions.
3 changes: 2 additions & 1 deletion api/src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
new Patch(
processor: UserActivateProcessor::class,
uriTemplate: 'users/{id}/activate{._format}',
denormalizationContext: ['groups' => ['activate']]
denormalizationContext: ['groups' => ['activate']],
output: User::class
),
new Get(
security: 'is_authenticated()'
Expand Down
2 changes: 1 addition & 1 deletion api/src/Serializer/Normalizer/UriTemplateNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function normalize($object, $format = null, array $context = []): array|s
$result['_links']['oauthGoogle'] = ['href' => $this->urlGenerator->generate('connect_google_start').'{?callback}', 'templated' => true];
$result['_links']['oauthPbsmidata'] = ['href' => $this->urlGenerator->generate('connect_pbsmidata_start').'{?callback}', 'templated' => true];
$result['_links']['oauthCevidb'] = ['href' => $this->urlGenerator->generate('connect_cevidb_start').'{?callback}', 'templated' => true];
$result['_links']['resetPassword'] = ['href' => $this->urlGenerator->generate('_api_/reset_password{._format}_post').'{/id}', 'templated' => true];
$result['_links']['resetPassword'] = ['href' => $this->urlGenerator->generate('_api_/auth/reset_password{._format}_post').'{/id}', 'templated' => true];

return $result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class CreateContentNodeTest extends ECampApiTestCase {
public function testCreateContentNodeIsNotAllowed() {
static::createClientWithCredentials()->request('POST', '/content_node/content_nodes', ['json' => []]);
static::createClientWithCredentials()->request('POST', '/content_nodes', ['json' => []]);
$this->assertResponseStatusCodeSame(405);
}
}
7 changes: 1 addition & 6 deletions api/tests/Api/Invitations/AcceptInvitationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,8 @@ public function testAcceptInvitationSuccess() {
'headers' => ['Content-Type' => 'application/merge-patch+json'],
]
);
$this->assertResponseStatusCodeSame(200); // TO DISCUSS: Wouldn't it be better to get a 204 here? The invitation doesn't really exist anymore after successful acceptance
$this->assertResponseStatusCodeSame(200);
$this->assertJsonContains([
/*
'campId' => $campCollaboration->camp->getId(),
'campTitle' => $campCollaboration->camp->title,
'userDisplayName' => 'Bi-Pi',
'userAlreadyInCamp' => false, */
'_links' => [
'self' => ['href' => "/invitations/{$campCollaboration->inviteKey}/find"],
],
Expand Down
7 changes: 1 addition & 6 deletions api/tests/Api/Invitations/RejectInvitationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,8 @@ public function testRejectInvitationSucceedsWhenNotLoggedIn() {
'headers' => ['Content-Type' => 'application/merge-patch+json'],
]
);
$this->assertResponseStatusCodeSame(200); // // TO DISCUSS: Wouldn't it be better to get a 204 here? The invitation doesn't really exist anymore after successful acceptance
$this->assertResponseStatusCodeSame(200);
$this->assertJsonContains([
/*
'campId' => $campCollaboration->camp->getId(),
'campTitle' => $campCollaboration->camp->title,
'userDisplayName' => null,
'userAlreadyInCamp' => null,*/
'_links' => [
'self' => ['href' => "/invitations/{$campCollaboration->inviteKey}/find"],
],
Expand Down
8 changes: 1 addition & 7 deletions api/tests/Api/Profiles/CreateProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,15 @@

namespace App\Tests\Api\Profiles;

use ApiPlatform\Metadata\Post;
use App\Entity\Profile;
use App\Tests\Api\ECampApiTestCase;

/**
* @internal
*/
class CreateProfileTest extends ECampApiTestCase {
public function testCreateProfileIsNotAllowed() {
static::createClientWithCredentials()->request('POST', '/profiles', ['json' => $this->getExampleWritePayload()]);
static::createClientWithCredentials()->request('POST', '/profiles', ['json' => []]);

$this->assertResponseStatusCodeSame(405);
}

public function getExampleWritePayload($attributes = [], $except = []) {
return $this->getExamplePayload(Profile::class, Post::class, $attributes, [], $except);
}
}

0 comments on commit 2a3d2ff

Please sign in to comment.