mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 00:02:15 +01:00
Added filled gaps to time entry aggregation; Moved aggregation to service
This commit is contained in:
43
tests/TestCaseWithDatabase.php
Normal file
43
tests/TestCaseWithDatabase.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use App\Models\Member;
|
||||
use App\Models\Organization;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Jetstream\Jetstream;
|
||||
|
||||
abstract class TestCaseWithDatabase extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* @param array<string> $permissions
|
||||
* @return object{user: User, organization: Organization, member: Member}
|
||||
*/
|
||||
protected function createUserWithPermission(array $permissions = [], bool $isOwner = false): object
|
||||
{
|
||||
$roleName = 'custom-test-'.Str::uuid();
|
||||
Jetstream::role($roleName, '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();
|
||||
}
|
||||
$member = Member::factory()->forUser($user)->forOrganization($organization)->create([
|
||||
'role' => $roleName,
|
||||
]);
|
||||
|
||||
return (object) [
|
||||
'user' => $user,
|
||||
'organization' => $organization,
|
||||
'member' => $member,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user