mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-15 19:52:15 +01:00
Added tasks endpoints; Added more test
This commit is contained in:
@@ -18,11 +18,16 @@ class ApiEndpointTestAbstract extends TestCase
|
||||
* @param array<string> $permissions
|
||||
* @return object{user: User, organization: Organization}
|
||||
*/
|
||||
protected function createUserWithPermission(array $permissions): object
|
||||
protected function createUserWithPermission(array $permissions, bool $isOwner = false): object
|
||||
{
|
||||
Jetstream::role('custom-test', 'Custom Test', $permissions)->description('Role custom for testing');
|
||||
$organization = Organization::factory()->create();
|
||||
Jetstream::role('custom-test', 'Custom Test', $permissions)
|
||||
->description('Role custom for testing');
|
||||
$user = User::factory()->create();
|
||||
if ($isOwner) {
|
||||
$organization = Organization::factory()->withOwner($user)->create();
|
||||
} else {
|
||||
$organization = Organization::factory()->create();
|
||||
}
|
||||
$organization->users()->attach($user, [
|
||||
'role' => 'custom-test',
|
||||
]);
|
||||
|
||||
@@ -23,7 +23,7 @@ class ClientEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->getJson(route('api.v1.clients.index', [$data->organization->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_index_endpoint_returns_list_of_all_clients_of_organization_ordered_by_created_at_desc_per_default(): void
|
||||
@@ -66,7 +66,7 @@ class ClientEndpointTest extends ApiEndpointTestAbstract
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_store_endpoint_creates_new_client(): void
|
||||
@@ -106,7 +106,7 @@ class ClientEndpointTest extends ApiEndpointTestAbstract
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_update_endpoint_fails_if_user_is_not_part_of_client_organization(): void
|
||||
@@ -126,7 +126,7 @@ class ClientEndpointTest extends ApiEndpointTestAbstract
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
$this->assertDatabaseHas(Client::class, [
|
||||
'id' => $client->getKey(),
|
||||
'name' => $client->name,
|
||||
@@ -173,7 +173,7 @@ class ClientEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->deleteJson(route('api.v1.clients.destroy', [$data->organization->getKey(), $client->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_destroy_endpoint_fails_if_user_is_not_part_of_client_organization(): void
|
||||
@@ -190,7 +190,7 @@ class ClientEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->deleteJson(route('api.v1.clients.destroy', [$data->organization->getKey(), $client->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
$this->assertDatabaseHas(Client::class, [
|
||||
'id' => $client->getKey(),
|
||||
'name' => $client->name,
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Tests\Unit\Endpoint\Api\V1;
|
||||
|
||||
use App\Models\Organization;
|
||||
use App\Service\Import\Importers\ImportException;
|
||||
use App\Service\Import\Importers\ReportDto;
|
||||
use App\Service\Import\ImportService;
|
||||
use Laravel\Passport\Passport;
|
||||
@@ -28,7 +29,35 @@ class ImportEndpointTest extends ApiEndpointTestAbstract
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_import_return_error_message_if_import_fails(): void
|
||||
{
|
||||
$user = $this->createUserWithPermission([
|
||||
'import',
|
||||
]);
|
||||
$this->mock(ImportService::class, function (MockInterface $mock) use (&$user): void {
|
||||
$mock->shouldReceive('import')
|
||||
->withArgs(function (Organization $organization, string $importerType, string $data) use (&$user): bool {
|
||||
return $organization->is($user->organization) && $importerType === 'toggl_time_entries' && $data === 'some data';
|
||||
})
|
||||
->andThrow(new ImportException('This is a test error!'))
|
||||
->once();
|
||||
});
|
||||
Passport::actingAs($user->user);
|
||||
|
||||
// Act
|
||||
$response = $this->postJson(route('api.v1.import.import', ['organization' => $user->organization->id]), [
|
||||
'type' => 'toggl_time_entries',
|
||||
'data' => 'some data',
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(400);
|
||||
$response->assertExactJson([
|
||||
'message' => 'This is a test error!',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_import_calls_import_service_if_user_has_permission(): void
|
||||
|
||||
@@ -8,7 +8,7 @@ use App\Models\Organization;
|
||||
use App\Models\User;
|
||||
use Laravel\Passport\Passport;
|
||||
|
||||
class UserEndpointTest extends ApiEndpointTestAbstract
|
||||
class MemberEndpointTest extends ApiEndpointTestAbstract
|
||||
{
|
||||
public function test_index_returns_members_of_organization(): void
|
||||
{
|
||||
@@ -25,6 +25,29 @@ class UserEndpointTest extends ApiEndpointTestAbstract
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
public function test_invite_placeholder_succeeds_if_data_is_valid(): void
|
||||
{
|
||||
$data = $this->createUserWithPermission([
|
||||
'users:invite-placeholder',
|
||||
], true);
|
||||
$user = User::factory()->create([
|
||||
'is_placeholder' => true,
|
||||
]);
|
||||
$data->organization->users()->attach($user, [
|
||||
'role' => 'placeholder',
|
||||
]);
|
||||
Passport::actingAs($data->user);
|
||||
|
||||
// Act
|
||||
$response = $this->postJson(route('api.v1.users.invite-placeholder', [
|
||||
'organization' => $data->organization->id,
|
||||
'user' => $user->id,
|
||||
]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(204);
|
||||
}
|
||||
|
||||
public function test_invite_placeholder_fails_if_user_does_not_have_permission(): void
|
||||
{
|
||||
// Arrange
|
||||
@@ -40,7 +63,7 @@ class UserEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->postJson(route('api.v1.users.invite-placeholder', ['organization' => $data->organization->id, 'user' => $user->id]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_invite_placeholder_fails_if_user_is_not_part_of_organization(): void
|
||||
@@ -60,7 +83,7 @@ class UserEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->postJson(route('api.v1.users.invite-placeholder', ['organization' => $data->organization->id, 'user' => $user->id]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_invite_placeholder_returns_400_if_user_is_not_placeholder(): void
|
||||
@@ -20,7 +20,7 @@ class OrganizationEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->getJson(route('api.v1.organizations.show', [$data->organization->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_show_endpoint_returns_organization(): void
|
||||
@@ -53,7 +53,7 @@ class OrganizationEndpointTest extends ApiEndpointTestAbstract
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_update_endpoint_updates_project(): void
|
||||
|
||||
@@ -24,7 +24,7 @@ class ProjectEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->getJson(route('api.v1.projects.index', [$data->organization->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_index_endpoint_returns_list_of_all_projects_of_organization(): void
|
||||
@@ -58,7 +58,7 @@ class ProjectEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->getJson(route('api.v1.projects.show', [$data->organization->getKey(), $project->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_show_endpoint_fails_if_user_has_no_permission_to_view_projects(): void
|
||||
@@ -73,7 +73,7 @@ class ProjectEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->getJson(route('api.v1.projects.show', [$data->organization->getKey(), $project->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_show_endpoint_returns_project(): void
|
||||
@@ -108,7 +108,7 @@ class ProjectEndpointTest extends ApiEndpointTestAbstract
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_store_endpoint_creates_new_project(): void
|
||||
@@ -180,7 +180,7 @@ class ProjectEndpointTest extends ApiEndpointTestAbstract
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_update_endpoint_fails_if_user_has_no_permission_to_update_projects(): void
|
||||
@@ -199,7 +199,7 @@ class ProjectEndpointTest extends ApiEndpointTestAbstract
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_update_endpoint_updates_project(): void
|
||||
@@ -240,7 +240,7 @@ class ProjectEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->deleteJson(route('api.v1.projects.destroy', [$data->organization->getKey(), $project->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_destroy_endpoint_fails_if_user_has_no_permission_to_delete_projects(): void
|
||||
@@ -255,7 +255,7 @@ class ProjectEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->deleteJson(route('api.v1.projects.destroy', [$data->organization->getKey(), $project->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_destroy_endpoint_deletes_project(): void
|
||||
|
||||
@@ -23,7 +23,7 @@ class TagEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->getJson(route('api.v1.tags.index', [$data->organization->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_index_endpoint_returns_list_of_all_tags_of_organization_ordered_by_created_at_desc_per_default(): void
|
||||
@@ -66,7 +66,7 @@ class TagEndpointTest extends ApiEndpointTestAbstract
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_store_endpoint_creates_new_tag(): void
|
||||
@@ -106,7 +106,7 @@ class TagEndpointTest extends ApiEndpointTestAbstract
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_update_endpoint_fails_if_user_is_not_part_of_tag_organization(): void
|
||||
@@ -126,7 +126,7 @@ class TagEndpointTest extends ApiEndpointTestAbstract
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
$this->assertDatabaseHas(Tag::class, [
|
||||
'id' => $tag->getKey(),
|
||||
'name' => $tag->name,
|
||||
@@ -173,7 +173,7 @@ class TagEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->deleteJson(route('api.v1.tags.destroy', [$data->organization->getKey(), $tag->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_destroy_endpoint_fails_if_user_is_not_part_of_tag_organization(): void
|
||||
@@ -190,7 +190,7 @@ class TagEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->deleteJson(route('api.v1.tags.destroy', [$data->organization->getKey(), $tag->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
$this->assertDatabaseHas(Tag::class, [
|
||||
'id' => $tag->getKey(),
|
||||
'name' => $tag->name,
|
||||
|
||||
243
tests/Unit/Endpoint/Api/V1/TaskEndpointTest.php
Normal file
243
tests/Unit/Endpoint/Api/V1/TaskEndpointTest.php
Normal file
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Endpoint\Api\V1;
|
||||
|
||||
use App\Models\Project;
|
||||
use App\Models\Task;
|
||||
use Laravel\Passport\Passport;
|
||||
|
||||
class TaskEndpointTest extends ApiEndpointTestAbstract
|
||||
{
|
||||
public function test_index_endpoint_fails_if_user_has_no_permission_to_view_tasks(): void
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
]);
|
||||
Task::factory()->forOrganization($data->organization)->createMany(4);
|
||||
Passport::actingAs($data->user);
|
||||
|
||||
// Act
|
||||
$response = $this->getJson(route('api.v1.tasks.index', [$data->organization->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_index_endpoint_returns_list_of_all_tasks_of_organization(): void
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
'tasks:view',
|
||||
]);
|
||||
$tasks = Task::factory()->forOrganization($data->organization)->createMany(4);
|
||||
Passport::actingAs($data->user);
|
||||
|
||||
// Act
|
||||
$response = $this->getJson(route('api.v1.tasks.index', [$data->organization->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(200);
|
||||
$response->assertJsonCount(4, 'data');
|
||||
}
|
||||
|
||||
public function test_index_endpoint_returns_list_of_all_tasks_of_organization_filtered_by_project(): void
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
'tasks:view',
|
||||
]);
|
||||
$project = Project::factory()->forOrganization($data->organization)->create();
|
||||
Task::factory()->forOrganization($data->organization)->createMany(4);
|
||||
Task::factory()->forOrganization($data->organization)->forProject($project)->createMany(2);
|
||||
Passport::actingAs($data->user);
|
||||
|
||||
// Act
|
||||
$response = $this->getJson(route('api.v1.tasks.index', [
|
||||
$data->organization->getKey(),
|
||||
'project_id' => $project->getKey(),
|
||||
]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(200);
|
||||
$response->assertJsonCount(2, 'data');
|
||||
}
|
||||
|
||||
public function test_index_endpoint_validation_fails_if_project_id_does_not_belong_to_organization(): void
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
'tasks:view',
|
||||
]);
|
||||
$otherData = $this->createUserWithPermission([
|
||||
'tasks:view',
|
||||
]);
|
||||
$project = Project::factory()->forOrganization($otherData->organization)->create();
|
||||
Task::factory()->forOrganization($data->organization)->createMany(4);
|
||||
Passport::actingAs($data->user);
|
||||
|
||||
// Act
|
||||
$response = $this->getJson(route('api.v1.tasks.index', [
|
||||
$data->organization->getKey(),
|
||||
'project_id' => $project->getKey(),
|
||||
]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(422);
|
||||
$response->assertInvalid([
|
||||
'project_id',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_store_endpoint_fails_if_user_has_no_permission_to_create_tags()
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
]);
|
||||
$project = Project::factory()->forOrganization($data->organization)->create();
|
||||
Passport::actingAs($data->user);
|
||||
|
||||
// Act
|
||||
$response = $this->postJson(route('api.v1.tasks.store', [$data->organization->getKey()]), [
|
||||
'name' => 'Task 1',
|
||||
'project_id' => $project->getKey(),
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertForbidden();
|
||||
$this->assertDatabaseMissing(Task::class, [
|
||||
'name' => 'Task 1',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_store_endpoint_creates_new_task_if_user_has_permission_to_create_tasks()
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
'tasks:create',
|
||||
]);
|
||||
$project = Project::factory()->forOrganization($data->organization)->create();
|
||||
Passport::actingAs($data->user);
|
||||
|
||||
// Act
|
||||
$response = $this->postJson(route('api.v1.tasks.store', [$data->organization->getKey()]), [
|
||||
'name' => 'Task 1',
|
||||
'project_id' => $project->getKey(),
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(201);
|
||||
$this->assertDatabaseHas(Task::class, [
|
||||
'name' => 'Task 1',
|
||||
'project_id' => $project->getKey(),
|
||||
'organization_id' => $data->organization->id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_update_endpoint_fails_if_user_has_no_permission(): void
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
]);
|
||||
$task = Task::factory()->forOrganization($data->organization)->create();
|
||||
Passport::actingAs($data->user);
|
||||
|
||||
// Act
|
||||
$response = $this->putJson(route('api.v1.tasks.update', [$data->organization->getKey(), $task->getKey()]), [
|
||||
'name' => 'Updated Task',
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertForbidden();
|
||||
$this->assertDatabaseHas(Task::class, [
|
||||
'id' => $task->getKey(),
|
||||
'name' => $task->name,
|
||||
]);
|
||||
$this->assertDatabaseMissing(Task::class, [
|
||||
'id' => $task->getKey(),
|
||||
'name' => 'Updated Task',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_update_endpoint_updates_task_if_user_has_permission(): void
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
'tasks:update',
|
||||
]);
|
||||
$task = Task::factory()->forOrganization($data->organization)->create();
|
||||
Passport::actingAs($data->user);
|
||||
|
||||
// Act
|
||||
$response = $this->putJson(route('api.v1.tasks.update', [$data->organization->getKey(), $task->getKey()]), [
|
||||
'name' => 'Updated Task',
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(200);
|
||||
$this->assertDatabaseHas(Task::class, [
|
||||
'id' => $task->getKey(),
|
||||
'name' => 'Updated Task',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_delete_endpoint_deletes_tasks_if_user_has_permission(): void
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
'tasks:delete',
|
||||
]);
|
||||
$task = Task::factory()->forOrganization($data->organization)->create();
|
||||
Passport::actingAs($data->user);
|
||||
|
||||
// Act
|
||||
$response = $this->deleteJson(route('api.v1.tasks.destroy', [$data->organization->getKey(), $task->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(204);
|
||||
$this->assertDatabaseMissing(Task::class, [
|
||||
'id' => $task->getKey(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_delete_endpoint_fails_if_user_has_no_permission_to_delete_tasks(): void
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
]);
|
||||
$task = Task::factory()->forOrganization($data->organization)->create();
|
||||
Passport::actingAs($data->user);
|
||||
|
||||
// Act
|
||||
$response = $this->deleteJson(route('api.v1.tasks.destroy', [$data->organization->getKey(), $task->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertForbidden();
|
||||
$this->assertDatabaseHas(Task::class, [
|
||||
'id' => $task->getKey(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_delete_endpoint_fails_if_task_does_not_belong_to_organization(): void
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
'tasks:delete',
|
||||
]);
|
||||
$otherData = $this->createUserWithPermission([
|
||||
'tasks:delete',
|
||||
]);
|
||||
$task = Task::factory()->forOrganization($otherData->organization)->create();
|
||||
Passport::actingAs($data->user);
|
||||
|
||||
// Act
|
||||
$response = $this->deleteJson(route('api.v1.tasks.destroy', [$data->organization->getKey(), $task->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertForbidden();
|
||||
$this->assertDatabaseHas(Task::class, [
|
||||
'id' => $task->getKey(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->getJson(route('api.v1.time-entries.index', [$data->organization->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_index_endpoint_fails_if_user_has_no_permission_to_view_time_entries_for_others_but_wants_all_entries(): void
|
||||
@@ -41,7 +41,7 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->getJson(route('api.v1.time-entries.index', [$data->organization->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_index_endpoint_returns_time_entries_for_current_user(): void
|
||||
@@ -323,7 +323,7 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_store_endpoint_fails_if_user_already_has_active_time_entry_and_tries_to_start_new_one(): void
|
||||
@@ -463,7 +463,7 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_store_endpoint_creates_new_time_entry_for_other_user_in_organization(): void
|
||||
@@ -520,7 +520,7 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_update_endpoint_fails_if_user_is_not_part_of_time_entry_organization(): void
|
||||
@@ -547,7 +547,7 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_update_endpoint_fails_if_user_has_no_permission_to_update_time_entries_for_other_users_in_organization(): void
|
||||
@@ -575,7 +575,7 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_update_endpoint_updates_time_entry_for_current_user(): void
|
||||
@@ -656,7 +656,7 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->deleteJson(route('api.v1.time-entries.destroy', [$data->organization->getKey(), $timeEntry->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_destroy_endpoint_fails_if_user_tries_to_delete_non_existing_time_entry(): void
|
||||
@@ -686,7 +686,7 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->deleteJson(route('api.v1.time-entries.destroy', [$data->organization->getKey(), $timeEntry->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_destroy_endpoint_fails_if_user_has_no_permission_to_delete_time_entries_for_other_users_in_organization(): void
|
||||
@@ -706,7 +706,7 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
||||
$response = $this->deleteJson(route('api.v1.time-entries.destroy', [$data->organization->getKey(), $timeEntry->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_destroy_endpoint_deletes_own_time_entry(): void
|
||||
|
||||
Reference in New Issue
Block a user