Skip to content

Commit dc70eb7

Browse files
committed
Add more tests
1 parent c2a8eac commit dc70eb7

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

tests/Unit/Endpoint/Api/V1/UserEndpointTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,22 @@ public function test_update_fails_if_name_is_not_a_string(): void
240240
$response->assertJsonValidationErrors(['name']);
241241
}
242242

243+
public function test_update_fails_if_given_user_is_not_the_authenticated_user(): void
244+
{
245+
// Arrange
246+
$data = $this->createUserWithPermission();
247+
$otherData = $this->createUserWithPermission();
248+
Passport::actingAs($otherData->user);
249+
250+
// Act
251+
$response = $this->putJson(route('api.v1.users.update', $data->user->getKey()), [
252+
'name' => 'Updated Name',
253+
]);
254+
255+
// Assert
256+
$response->assertForbidden();
257+
}
258+
243259
public function test_update_fails_if_name_is_too_long(): void
244260
{
245261
// Arrange

tests/Unit/Endpoint/Web/OrganizationInvitationEndpointTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,27 @@ public function test_fails_with_invalid_signature(): void
251251
// Assert
252252
$response->assertForbidden();
253253
}
254+
255+
public function test_fails_if_invitation_has_owner_role(): void
256+
{
257+
// Arrange
258+
$user = $this->createUserWithPermission();
259+
$invitation = OrganizationInvitation::factory()
260+
->forOrganization($user->organization)
261+
->create([
262+
'role' => Role::Owner->value,
263+
]);
264+
265+
// Act
266+
$acceptUrl = URL::to(URL::temporarySignedRoute(
267+
'organization-invitations.accept',
268+
now()->addMinutes(60),
269+
[$invitation->getKey()],
270+
false
271+
));
272+
$response = $this->get($acceptUrl);
273+
274+
// Assert
275+
$response->assertStatus(500);
276+
}
254277
}

0 commit comments

Comments
 (0)