@@ -267,6 +267,65 @@ public function testPatchCampCollaborationInSharedCampIsDeniedForInvitedUser() {
267267 ]);
268268 }
269269
270+ public function testPatchCampCollaborationRoleWithoutUserIsAllowed () {
271+ /** @var CampCollaboration $campCollaboration */
272+ $ campCollaboration = static ::getFixture ('campCollaboration4invited ' );
273+
274+ static ::createClientWithCredentials ()->request ('PATCH ' , '/camp_collaborations/ ' .$ campCollaboration ->getId (), [
275+ 'json ' => [
276+ 'role ' => CampCollaboration::ROLE_GUEST ,
277+ ],
278+ 'headers ' => ['Content-Type ' => 'application/merge-patch+json ' ],
279+ ]);
280+
281+ $ this ->assertResponseStatusCodeSame (200 );
282+ $ this ->assertJsonContains ([
283+ 'role ' => CampCollaboration::ROLE_GUEST ,
284+ ]);
285+ }
286+
287+ public function testPatchCampCollaborationRoleFromGuestToManagerWithoutUserIsAllowed () {
288+ /** @var CampCollaboration $campCollaboration */
289+ $ campCollaboration = static ::getFixture ('campCollaboration4invited ' );
290+
291+ static ::createClientWithCredentials ()->request ('PATCH ' , '/camp_collaborations/ ' .$ campCollaboration ->getId (), [
292+ 'json ' => [
293+ 'role ' => CampCollaboration::ROLE_MANAGER ,
294+ ],
295+ 'headers ' => ['Content-Type ' => 'application/merge-patch+json ' ],
296+ ]);
297+
298+ static ::createClientWithCredentials ()->request ('PATCH ' , '/camp_collaborations/ ' .$ campCollaboration ->getId (), [
299+ 'json ' => [
300+ 'role ' => CampCollaboration::ROLE_MANAGER ,
301+ ],
302+ 'headers ' => ['Content-Type ' => 'application/merge-patch+json ' ],
303+ ]);
304+
305+ // This should succeed without errors
306+ $ this ->assertResponseStatusCodeSame (200 );
307+ $ this ->assertJsonContains ([
308+ 'role ' => 'manager ' ,
309+ ]);
310+ }
311+
312+ public function testPatchCampCollaborationDisallowsSettingUserToNull () {
313+ /** @var CampCollaboration $campCollaboration */
314+ $ campCollaboration = static ::getFixture ('campCollaboration4invited ' );
315+
316+ static ::createClientWithCredentials ()->request ('PATCH ' , '/camp_collaborations/ ' .$ campCollaboration ->getId (), [
317+ 'json ' => [
318+ 'user ' => null ,
319+ ],
320+ 'headers ' => ['Content-Type ' => 'application/merge-patch+json ' ],
321+ ]);
322+
323+ $ this ->assertResponseStatusCodeSame (400 );
324+ $ this ->assertJsonContains ([
325+ 'detail ' => 'Extra attributes are not allowed ("user" is unknown). ' ,
326+ ]);
327+ }
328+
270329 public function testPatchCampCollaborationDisallowsChangingInviteEmail () {
271330 $ campCollaboration = static ::getFixture ('campCollaboration1manager ' );
272331 static ::createClientWithCredentials ()->request ('PATCH ' , '/camp_collaborations/ ' .$ campCollaboration ->getId (), ['json ' => [
0 commit comments