code style fix

add command tests
This commit is contained in:
Saeed Vaziry
2023-09-02 16:41:42 +02:00
parent 71f9dabc24
commit e1eb42059f
135 changed files with 1859 additions and 135 deletions

View File

@ -59,7 +59,7 @@ private function validate($type, Server $server, array $input): void
'0 0 * * *',
'0 0 * * 0',
'0 0 1 * *',
'custom'
'custom',
]),
],
];

View File

@ -6,7 +6,6 @@
use App\Models\FirewallRule;
use App\Models\Server;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
use Illuminate\Validation\ValidationException;
class CreateRule

View File

@ -15,7 +15,7 @@ public function connect(array $input): void
$sourceControl = new SourceControl([
'provider' => $input['provider'],
'profile' => $input['name'],
'access_token' => $input['token']
'access_token' => $input['token'],
]);
if (! $sourceControl->provider()->connect()) {
@ -24,7 +24,7 @@ public function connect(array $input): void
),
]);
}
$sourceControl->save();
}
@ -36,14 +36,14 @@ private function validate(array $input): void
$rules = [
'provider' => [
'required',
Rule::in(\App\Enums\SourceControl::getValues())
Rule::in(\App\Enums\SourceControl::getValues()),
],
'name' => [
'required',
],
'token' => [
'required'
]
'required',
],
];
Validator::make($input, $rules)->validate();
}

View File

@ -22,15 +22,15 @@ public function create(User $user, array $input): void
'provider' => $input['provider'],
'profile' => $input['name'],
'credentials' => [
'token' => $input['token']
]
'token' => $input['token'],
],
]);
if (! $storageProvider->provider()->connect()) {
throw ValidationException::withMessages([
'token' => __("Couldn't connect to the provider")
'token' => __("Couldn't connect to the provider"),
]);
}
$storageProvider->save();;
$storageProvider->save();
}
private function validate(User $user, array $input): void
@ -45,8 +45,8 @@ private function validate(User $user, array $input): void
Rule::unique('storage_providers', 'profile')->where('user_id', $user->id),
],
'token' => [
'required'
]
'required',
],
])->validate();
}
}