Added usage check to delete endpoints

This commit is contained in:
Constantin Graf
2024-04-18 21:42:29 +02:00
committed by Constantin Graf
parent 40f1159ea5
commit ad6146c483
18 changed files with 326 additions and 6 deletions

View File

@@ -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));
}
}