$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, ]; } protected function enableQueryLog(): void { DB::flushQueryLog(); DB::enableQueryLog(); } protected function getQueryLog(): array { if (! DB::logging()) { throw new \LogicException('Query log is not enabled. Call enableQueryLog() before calling getQueryLog()'); } return DB::getQueryLog(); } protected function assertQueryCount(int $count, string $message = ''): void { $queryLog = $this->getQueryLog(); $this->assertCount($count, $queryLog, $message); } }