mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-14 03:02:15 +01:00
Added usage check to delete endpoints
This commit is contained in:
committed by
Constantin Graf
parent
40f1159ea5
commit
ad6146c483
@@ -6,6 +6,7 @@ namespace Tests\Unit\Model;
|
||||
|
||||
use App\Models\Organization;
|
||||
use App\Models\Project;
|
||||
use App\Models\Tag;
|
||||
use App\Models\Task;
|
||||
use App\Models\TimeEntry;
|
||||
use App\Models\User;
|
||||
@@ -117,4 +118,30 @@ class TimeEntryModelTest extends ModelTestAbstract
|
||||
'start' => '2021-01-01 13:00:00',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_scope_has_tag_filter_by_tag(): void
|
||||
{
|
||||
// Arrange
|
||||
$tag1 = Tag::factory()->create();
|
||||
$tag2 = Tag::factory()->create();
|
||||
$timeEntry1 = TimeEntry::factory()->create([
|
||||
'tags' => [$tag1->getKey()],
|
||||
]);
|
||||
$timeEntry2 = TimeEntry::factory()->create([
|
||||
'tags' => [$tag2->getKey()],
|
||||
]);
|
||||
$timeEntry3 = TimeEntry::factory()->create([
|
||||
'tags' => ['something-else'],
|
||||
]);
|
||||
$timeEntry4 = TimeEntry::factory()->create([
|
||||
'tags' => null,
|
||||
]);
|
||||
|
||||
// Act
|
||||
$result = TimeEntry::hasTag($tag1)->get();
|
||||
|
||||
// Assert
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertTrue($result->first()->is($timeEntry1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Tests\Unit\Model;
|
||||
|
||||
use App\Models\Organization;
|
||||
use App\Models\ProjectMember;
|
||||
use App\Models\TimeEntry;
|
||||
use App\Models\User;
|
||||
use App\Providers\Filament\AdminPanelProvider;
|
||||
@@ -92,6 +93,27 @@ class UserModelTest extends ModelTestAbstract
|
||||
$this->assertTrue($timeEntriesRel->first()->is($timeEntries->first()));
|
||||
}
|
||||
|
||||
public function test_it_has_many_project_members(): void
|
||||
{
|
||||
// Arrange
|
||||
$user = User::factory()->create();
|
||||
$otherUser = User::factory()->create();
|
||||
$projectMembers = ProjectMember::factory()->forUser($user)->createMany(3);
|
||||
$otherProjectMembers = ProjectMember::factory()->forUser($otherUser)->createMany(3);
|
||||
|
||||
// Act
|
||||
$user->refresh();
|
||||
$projectMembersRel = $user->projectMembers;
|
||||
|
||||
// Assert
|
||||
$this->assertNotNull($projectMembersRel);
|
||||
$this->assertCount(3, $projectMembersRel);
|
||||
$this->assertEqualsCanonicalizing(
|
||||
$projectMembers->pluck('id')->toArray(),
|
||||
$projectMembersRel->pluck('id')->toArray()
|
||||
);
|
||||
}
|
||||
|
||||
public function test_scope_active_returns_only_non_placeholder_users(): void
|
||||
{
|
||||
// Arrange
|
||||
|
||||
Reference in New Issue
Block a user