Add initialize action
This commit is contained in:
parent
a1205a8173
commit
03b7f0ba64
app/Initialize/Actions
packages
resources
tests/Feature/Initialize
|
@ -5,18 +5,23 @@ namespace App\Initialize\Actions;
|
||||||
use App\Initialize\InitializeJob;
|
use App\Initialize\InitializeJob;
|
||||||
use App\Setting\NamiSettings;
|
use App\Setting\NamiSettings;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
use Zoomyboy\LaravelNami\Nami;
|
||||||
|
|
||||||
class InitializeAction
|
class InitializeAction
|
||||||
{
|
{
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
|
||||||
public function handle(int $mglnr, string $password, int $groupId)
|
public function handle(int $mglnr, string $password, int $groupId): void
|
||||||
{
|
{
|
||||||
InitializeJob::dispatch();
|
InitializeJob::dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -26,8 +31,24 @@ class InitializeAction
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function getValidationAttributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'group_id' => 'Gruppierungsnr',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function asController(ActionRequest $request, NamiSettings $settings): RedirectResponse
|
public function asController(ActionRequest $request, NamiSettings $settings): RedirectResponse
|
||||||
{
|
{
|
||||||
|
$api = Nami::login($request->input('mglnr'), $request->input('password'));
|
||||||
|
|
||||||
|
if (!$api->hasGroup($request->input('group_id'))) {
|
||||||
|
throw ValidationException::withMessages(['nami' => 'Gruppierung nicht gefunden.']);
|
||||||
|
}
|
||||||
|
|
||||||
$settings->mglnr = $request->input('mglnr');
|
$settings->mglnr = $request->input('mglnr');
|
||||||
$settings->password = $request->input('password');
|
$settings->password = $request->input('password');
|
||||||
$settings->default_group_id = $request->input('group_id');
|
$settings->default_group_id = $request->input('group_id');
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2c285801947dcbb2f262d4239662229d7f7c7e89
|
Subproject commit 6676b91cda3c0f426612768e5ae22396241cc488
|
|
@ -1,7 +1,42 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="p-6">
|
<div class="p-6 grid h-full items-center justify-center">
|
||||||
<div class="text-lg">Deine App wurde noch nicht initialisiert. Nami-Daten jetzt übernehmen?</div>
|
<div class="rounded border-primary-700 border border-solid p-6">
|
||||||
<a class="btn btn-primary mt-6 inline-block" href="#" @click.prevent="$inertia.post('/initialize', { preserveState: true, replace: false })">Jetzt initialisieren</a>
|
<div class="text-lg text-gray-200 text-sm">
|
||||||
|
Willkommen bei ScoutRobot.<br />
|
||||||
|
Bitte gib deine Zugangsdaten ein,<br />
|
||||||
|
um eine erste Synchronisation durchzuführen.
|
||||||
|
</div>
|
||||||
|
<form @submit.prevent="submit" class="grid gap-3 mt-5">
|
||||||
|
<f-text v-model="values.mglnr" label="Mitgliedsnummer" name="mglnr" id="mglnr"></f-text>
|
||||||
|
<f-text
|
||||||
|
v-model="values.password"
|
||||||
|
type="password"
|
||||||
|
label="Passwort"
|
||||||
|
name="password"
|
||||||
|
id="password"
|
||||||
|
></f-text>
|
||||||
|
<f-text v-model="values.group_id" label="Gruppierungsnummer" name="group_id" id="group_id"></f-text>
|
||||||
|
<button type="submit" class="btn w-full btn-primary mt-6 inline-block">Jetzt initialisieren</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data: function () {
|
||||||
|
return {
|
||||||
|
values: {
|
||||||
|
mglnr: '',
|
||||||
|
password: '',
|
||||||
|
group_id: '',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
submit() {
|
||||||
|
this.$inertia.post('/initialize', this.values);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
|
@ -12,110 +12,110 @@ return [
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'accepted' => ':attribute muss akzeptiert werden.',
|
'accepted' => ':attribute muss akzeptiert werden.',
|
||||||
'active_url' => ':attribute ist keine gültige Internet-Adresse.',
|
'active_url' => ':attribute ist keine gültige Internet-Adresse.',
|
||||||
'after' => ':attribute muss ein Datum nach dem :date sein.',
|
'after' => ':attribute muss ein Datum nach dem :date sein.',
|
||||||
'after_or_equal' => ':attribute muss ein Datum nach dem :date oder gleich dem :date sein.',
|
'after_or_equal' => ':attribute muss ein Datum nach dem :date oder gleich dem :date sein.',
|
||||||
'alpha' => ':attribute darf nur aus Buchstaben bestehen.',
|
'alpha' => ':attribute darf nur aus Buchstaben bestehen.',
|
||||||
'alpha_dash' => ':attribute darf nur aus Buchstaben, Zahlen, Binde- und Unterstrichen bestehen.',
|
'alpha_dash' => ':attribute darf nur aus Buchstaben, Zahlen, Binde- und Unterstrichen bestehen.',
|
||||||
'alpha_num' => ':attribute darf nur aus Buchstaben und Zahlen bestehen.',
|
'alpha_num' => ':attribute darf nur aus Buchstaben und Zahlen bestehen.',
|
||||||
'array' => ':attribute muss ein Array sein.',
|
'array' => ':attribute muss ein Array sein.',
|
||||||
'before' => ':attribute muss ein Datum vor dem :date sein.',
|
'before' => ':attribute muss ein Datum vor dem :date sein.',
|
||||||
'before_or_equal' => ':attribute muss ein Datum vor dem :date oder gleich dem :date sein.',
|
'before_or_equal' => ':attribute muss ein Datum vor dem :date oder gleich dem :date sein.',
|
||||||
'between' => [
|
'between' => [
|
||||||
'numeric' => ':attribute muss zwischen :min & :max liegen.',
|
'numeric' => ':attribute muss zwischen :min & :max liegen.',
|
||||||
'file' => ':attribute muss zwischen :min & :max Kilobytes groß sein.',
|
'file' => ':attribute muss zwischen :min & :max Kilobytes groß sein.',
|
||||||
'string' => ':attribute muss zwischen :min & :max Zeichen lang sein.',
|
'string' => ':attribute muss zwischen :min & :max Zeichen lang sein.',
|
||||||
'array' => ':attribute muss zwischen :min & :max Elemente haben.',
|
'array' => ':attribute muss zwischen :min & :max Elemente haben.',
|
||||||
],
|
],
|
||||||
'boolean' => ":attribute muss entweder 'true' oder 'false' sein.",
|
'boolean' => ":attribute muss entweder 'true' oder 'false' sein.",
|
||||||
'confirmed' => ':attribute stimmt nicht mit der Bestätigung überein.',
|
'confirmed' => ':attribute stimmt nicht mit der Bestätigung überein.',
|
||||||
'date' => ':attribute muss ein gültiges Datum sein.',
|
'date' => ':attribute muss ein gültiges Datum sein.',
|
||||||
'date_equals' => ':attribute muss ein Datum gleich :date sein.',
|
'date_equals' => ':attribute muss ein Datum gleich :date sein.',
|
||||||
'date_format' => ':attribute entspricht nicht dem gültigen Format für :format.',
|
'date_format' => ':attribute entspricht nicht dem gültigen Format für :format.',
|
||||||
'different' => ':attribute und :other müssen sich unterscheiden.',
|
'different' => ':attribute und :other müssen sich unterscheiden.',
|
||||||
'digits' => ':attribute muss :digits Stellen haben.',
|
'digits' => ':attribute muss :digits Stellen haben.',
|
||||||
'digits_between' => ':attribute muss zwischen :min und :max Stellen haben.',
|
'digits_between' => ':attribute muss zwischen :min und :max Stellen haben.',
|
||||||
'dimensions' => ':attribute hat ungültige Bildabmessungen.',
|
'dimensions' => ':attribute hat ungültige Bildabmessungen.',
|
||||||
'distinct' => ':attribute beinhaltet einen bereits vorhandenen Wert.',
|
'distinct' => ':attribute beinhaltet einen bereits vorhandenen Wert.',
|
||||||
'email' => ':attribute muss eine gültige E-Mail-Adresse sein.',
|
'email' => ':attribute muss eine gültige E-Mail-Adresse sein.',
|
||||||
'ends_with' => ':attribute muss eine der folgenden Endungen aufweisen: :values',
|
'ends_with' => ':attribute muss eine der folgenden Endungen aufweisen: :values',
|
||||||
'exists' => ':attribute ist nicht vorhanden.',
|
'exists' => ':attribute ist nicht vorhanden.',
|
||||||
'file' => ':attribute muss eine Datei sein.',
|
'file' => ':attribute muss eine Datei sein.',
|
||||||
'filled' => ':attribute muss ausgefüllt sein.',
|
'filled' => ':attribute muss ausgefüllt sein.',
|
||||||
'gt' => [
|
'gt' => [
|
||||||
'numeric' => ':attribute muss größer als :value sein.',
|
'numeric' => ':attribute muss größer als :value sein.',
|
||||||
'file' => ':attribute muss größer als :value Kilobytes sein.',
|
'file' => ':attribute muss größer als :value Kilobytes sein.',
|
||||||
'string' => ':attribute muss länger als :value Zeichen sein.',
|
'string' => ':attribute muss länger als :value Zeichen sein.',
|
||||||
'array' => ':attribute muss mehr als :value Elemente haben.',
|
'array' => ':attribute muss mehr als :value Elemente haben.',
|
||||||
],
|
],
|
||||||
'gte' => [
|
'gte' => [
|
||||||
'numeric' => ':attribute muss größer oder gleich :value sein.',
|
'numeric' => ':attribute muss größer oder gleich :value sein.',
|
||||||
'file' => ':attribute muss größer oder gleich :value Kilobytes sein.',
|
'file' => ':attribute muss größer oder gleich :value Kilobytes sein.',
|
||||||
'string' => ':attribute muss mindestens :value Zeichen lang sein.',
|
'string' => ':attribute muss mindestens :value Zeichen lang sein.',
|
||||||
'array' => ':attribute muss mindestens :value Elemente haben.',
|
'array' => ':attribute muss mindestens :value Elemente haben.',
|
||||||
],
|
],
|
||||||
'image' => ':attribute muss ein Bild sein.',
|
'image' => ':attribute muss ein Bild sein.',
|
||||||
'in' => 'Der gewählte Wert für :attribute ist ungültig.',
|
'in' => 'Der gewählte Wert für :attribute ist ungültig.',
|
||||||
'in_array' => 'Der gewählte Wert für :attribute kommt nicht in :other vor.',
|
'in_array' => 'Der gewählte Wert für :attribute kommt nicht in :other vor.',
|
||||||
'integer' => ':attribute muss eine ganze Zahl sein.',
|
'integer' => ':attribute muss eine ganze Zahl sein.',
|
||||||
'ip' => ':attribute muss eine gültige IP-Adresse sein.',
|
'ip' => ':attribute muss eine gültige IP-Adresse sein.',
|
||||||
'ipv4' => ':attribute muss eine gültige IPv4-Adresse sein.',
|
'ipv4' => ':attribute muss eine gültige IPv4-Adresse sein.',
|
||||||
'ipv6' => ':attribute muss eine gültige IPv6-Adresse sein.',
|
'ipv6' => ':attribute muss eine gültige IPv6-Adresse sein.',
|
||||||
'json' => ':attribute muss ein gültiger JSON-String sein.',
|
'json' => ':attribute muss ein gültiger JSON-String sein.',
|
||||||
'lt' => [
|
'lt' => [
|
||||||
'numeric' => ':attribute muss kleiner als :value sein.',
|
'numeric' => ':attribute muss kleiner als :value sein.',
|
||||||
'file' => ':attribute muss kleiner als :value Kilobytes sein.',
|
'file' => ':attribute muss kleiner als :value Kilobytes sein.',
|
||||||
'string' => ':attribute muss kürzer als :value Zeichen sein.',
|
'string' => ':attribute muss kürzer als :value Zeichen sein.',
|
||||||
'array' => ':attribute muss weniger als :value Elemente haben.',
|
'array' => ':attribute muss weniger als :value Elemente haben.',
|
||||||
],
|
],
|
||||||
'lte' => [
|
'lte' => [
|
||||||
'numeric' => ':attribute muss kleiner oder gleich :value sein.',
|
'numeric' => ':attribute muss kleiner oder gleich :value sein.',
|
||||||
'file' => ':attribute muss kleiner oder gleich :value Kilobytes sein.',
|
'file' => ':attribute muss kleiner oder gleich :value Kilobytes sein.',
|
||||||
'string' => ':attribute darf maximal :value Zeichen lang sein.',
|
'string' => ':attribute darf maximal :value Zeichen lang sein.',
|
||||||
'array' => ':attribute darf maximal :value Elemente haben.',
|
'array' => ':attribute darf maximal :value Elemente haben.',
|
||||||
],
|
],
|
||||||
'max' => [
|
'max' => [
|
||||||
'numeric' => ':attribute darf maximal :max sein.',
|
'numeric' => ':attribute darf maximal :max sein.',
|
||||||
'file' => ':attribute darf maximal :max Kilobytes groß sein.',
|
'file' => ':attribute darf maximal :max Kilobytes groß sein.',
|
||||||
'string' => ':attribute darf maximal :max Zeichen haben.',
|
'string' => ':attribute darf maximal :max Zeichen haben.',
|
||||||
'array' => ':attribute darf maximal :max Elemente haben.',
|
'array' => ':attribute darf maximal :max Elemente haben.',
|
||||||
],
|
],
|
||||||
'mimes' => ':attribute muss den Dateityp :values haben.',
|
'mimes' => ':attribute muss den Dateityp :values haben.',
|
||||||
'mimetypes' => ':attribute muss den Dateityp :values haben.',
|
'mimetypes' => ':attribute muss den Dateityp :values haben.',
|
||||||
'min' => [
|
'min' => [
|
||||||
'numeric' => ':attribute muss mindestens :min sein.',
|
'numeric' => ':attribute muss mindestens :min sein.',
|
||||||
'file' => ':attribute muss mindestens :min Kilobytes groß sein.',
|
'file' => ':attribute muss mindestens :min Kilobytes groß sein.',
|
||||||
'string' => ':attribute muss mindestens :min Zeichen lang sein.',
|
'string' => ':attribute muss mindestens :min Zeichen lang sein.',
|
||||||
'array' => ':attribute muss mindestens :min Elemente haben.',
|
'array' => ':attribute muss mindestens :min Elemente haben.',
|
||||||
],
|
],
|
||||||
'not_in' => 'Der gewählte Wert für :attribute ist ungültig.',
|
'not_in' => 'Der gewählte Wert für :attribute ist ungültig.',
|
||||||
'not_regex' => ':attribute hat ein ungültiges Format.',
|
'not_regex' => ':attribute hat ein ungültiges Format.',
|
||||||
'numeric' => ':attribute muss eine Zahl sein.',
|
'numeric' => ':attribute muss eine Zahl sein.',
|
||||||
'password' => 'Das Passwort ist falsch.',
|
'password' => 'Das Passwort ist falsch.',
|
||||||
'present' => ':attribute muss vorhanden sein.',
|
'present' => ':attribute muss vorhanden sein.',
|
||||||
'regex' => ':attribute Format ist ungültig.',
|
'regex' => ':attribute Format ist ungültig.',
|
||||||
'required' => ':attribute ist erforderlich.',
|
'required' => ':attribute ist erforderlich.',
|
||||||
'required_if' => ':attribute muss ausgefüllt werden, wenn :other den Wert :value hat.',
|
'required_if' => ':attribute muss ausgefüllt werden, wenn :other den Wert :value hat.',
|
||||||
'required_unless' => ':attribute muss ausgefüllt werden, wenn :other nicht den Wert :values hat.',
|
'required_unless' => ':attribute muss ausgefüllt werden, wenn :other nicht den Wert :values hat.',
|
||||||
'required_with' => ':attribute muss ausgefüllt werden, wenn :values ausgefüllt wurde.',
|
'required_with' => ':attribute muss ausgefüllt werden, wenn :values ausgefüllt wurde.',
|
||||||
'required_with_all' => ':attribute muss ausgefüllt werden, wenn :values ausgefüllt wurde.',
|
'required_with_all' => ':attribute muss ausgefüllt werden, wenn :values ausgefüllt wurde.',
|
||||||
'required_without' => ':attribute muss ausgefüllt werden, wenn :values nicht ausgefüllt wurde.',
|
'required_without' => ':attribute muss ausgefüllt werden, wenn :values nicht ausgefüllt wurde.',
|
||||||
'required_without_all' => ':attribute muss ausgefüllt werden, wenn keines der Felder :values ausgefüllt wurde.',
|
'required_without_all' => ':attribute muss ausgefüllt werden, wenn keines der Felder :values ausgefüllt wurde.',
|
||||||
'same' => ':attribute und :other müssen übereinstimmen.',
|
'same' => ':attribute und :other müssen übereinstimmen.',
|
||||||
'size' => [
|
'size' => [
|
||||||
'numeric' => ':attribute muss gleich :size sein.',
|
'numeric' => ':attribute muss gleich :size sein.',
|
||||||
'file' => ':attribute muss :size Kilobyte groß sein.',
|
'file' => ':attribute muss :size Kilobyte groß sein.',
|
||||||
'string' => ':attribute muss :size Zeichen lang sein.',
|
'string' => ':attribute muss :size Zeichen lang sein.',
|
||||||
'array' => ':attribute muss genau :size Elemente haben.',
|
'array' => ':attribute muss genau :size Elemente haben.',
|
||||||
],
|
],
|
||||||
'starts_with' => ':attribute muss mit einem der folgenden Anfänge aufweisen: :values',
|
'starts_with' => ':attribute muss mit einem der folgenden Anfänge aufweisen: :values',
|
||||||
'string' => ':attribute muss ein String sein.',
|
'string' => ':attribute muss ein String sein.',
|
||||||
'timezone' => ':attribute muss eine gültige Zeitzone sein.',
|
'timezone' => ':attribute muss eine gültige Zeitzone sein.',
|
||||||
'unique' => ':attribute ist bereits vergeben.',
|
'unique' => ':attribute ist bereits vergeben.',
|
||||||
'uploaded' => ':attribute konnte nicht hochgeladen werden.',
|
'uploaded' => ':attribute konnte nicht hochgeladen werden.',
|
||||||
'url' => ':attribute muss eine URL sein.',
|
'url' => ':attribute muss eine URL sein.',
|
||||||
'uuid' => ':attribute muss ein UUID sein.',
|
'uuid' => ':attribute muss ein UUID sein.',
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@ -146,37 +146,37 @@ return [
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'name' => 'Name',
|
'name' => 'Name',
|
||||||
'username' => 'Benutzername',
|
'username' => 'Benutzername',
|
||||||
'email' => 'E-Mail Adresse',
|
'email' => 'E-Mail Adresse',
|
||||||
'first_name' => 'Vorname',
|
'first_name' => 'Vorname',
|
||||||
'last_name' => 'Nachname',
|
'last_name' => 'Nachname',
|
||||||
'password' => 'Passwort',
|
'password' => 'Passwort',
|
||||||
'password_confirmation' => 'Passwort Bestätigung',
|
'password_confirmation' => 'Passwort Bestätigung',
|
||||||
'city' => 'Stadt',
|
'city' => 'Stadt',
|
||||||
'country' => 'Land',
|
'country' => 'Land',
|
||||||
'address' => 'Adresse',
|
'address' => 'Adresse',
|
||||||
'phone' => 'Telefonnummer',
|
'phone' => 'Telefonnummer',
|
||||||
'mobile' => 'Handynummer',
|
'mobile' => 'Handynummer',
|
||||||
'age' => 'Alter',
|
'age' => 'Alter',
|
||||||
'sex' => 'Geschlecht',
|
'sex' => 'Geschlecht',
|
||||||
'gender' => 'Geschlecht',
|
'gender' => 'Geschlecht',
|
||||||
'day' => 'Tag',
|
'day' => 'Tag',
|
||||||
'month' => 'Monat',
|
'month' => 'Monat',
|
||||||
'year' => 'Jahr',
|
'year' => 'Jahr',
|
||||||
'hour' => 'Stunde',
|
'hour' => 'Stunde',
|
||||||
'minute' => 'Minute',
|
'minute' => 'Minute',
|
||||||
'second' => 'Sekunde',
|
'second' => 'Sekunde',
|
||||||
'title' => 'Titel',
|
'title' => 'Titel',
|
||||||
'content' => 'Inhalt',
|
'content' => 'Inhalt',
|
||||||
'description' => 'Beschreibung',
|
'description' => 'Beschreibung',
|
||||||
'excerpt' => 'Auszug',
|
'excerpt' => 'Auszug',
|
||||||
'date' => 'Datum',
|
'date' => 'Datum',
|
||||||
'time' => 'Uhrzeit',
|
'time' => 'Uhrzeit',
|
||||||
'available' => 'verfügbar',
|
'available' => 'verfügbar',
|
||||||
'size' => 'Größe',
|
'size' => 'Größe',
|
||||||
'mglnr' => 'Mitgliesnummer',
|
'mglnr' => 'Mitgliedsnummer',
|
||||||
'groupid' => 'Gruppierungsnummer',
|
'groupid' => 'Gruppierungsnummer',
|
||||||
'firstname' => 'Vorname',
|
'firstname' => 'Vorname',
|
||||||
'lastname' => 'Nachname',
|
'lastname' => 'Nachname',
|
||||||
'birthday' => 'Geburtsdatum',
|
'birthday' => 'Geburtsdatum',
|
||||||
|
|
|
@ -20,6 +20,7 @@ use Illuminate\Support\Facades\Artisan;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Queue;
|
use Illuminate\Support\Facades\Queue;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
use Zoomyboy\LaravelNami\Authentication\Auth;
|
||||||
use Zoomyboy\LaravelNami\Backend\FakeBackend;
|
use Zoomyboy\LaravelNami\Backend\FakeBackend;
|
||||||
use Zoomyboy\LaravelNami\Fakes\GroupFake;
|
use Zoomyboy\LaravelNami\Fakes\GroupFake;
|
||||||
use Zoomyboy\LaravelNami\Fakes\SearchFake;
|
use Zoomyboy\LaravelNami\Fakes\SearchFake;
|
||||||
|
@ -76,6 +77,8 @@ class InitializeTest extends TestCase
|
||||||
{
|
{
|
||||||
$this->withoutExceptionHandling()->login();
|
$this->withoutExceptionHandling()->login();
|
||||||
InitializeAction::partialMock()->shouldReceive('handle')->with(12345, 'secret', 185)->once()->andReturn(true);
|
InitializeAction::partialMock()->shouldReceive('handle')->with(12345, 'secret', 185)->once()->andReturn(true);
|
||||||
|
Auth::success(12345, 'secret');
|
||||||
|
app(GroupFake::class)->fetches(null, [185 => ['name' => 'testgroup']]);
|
||||||
|
|
||||||
$response = $this->post('/initialize', [
|
$response = $this->post('/initialize', [
|
||||||
'group_id' => 185,
|
'group_id' => 185,
|
||||||
|
@ -102,6 +105,39 @@ class InitializeTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertErrors(['password' => 'Passwort ist erforderlich.'], $response);
|
$this->assertErrors(['password' => 'Passwort ist erforderlich.'], $response);
|
||||||
|
$this->assertErrors(['mglnr' => 'Mitgliedsnummer ist erforderlich.'], $response);
|
||||||
|
$this->assertErrors(['group_id' => 'Gruppierungsnr ist erforderlich.'], $response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testItValidatesLogin(): void
|
||||||
|
{
|
||||||
|
$this->login();
|
||||||
|
Auth::fails(12345, 'secret');
|
||||||
|
InitializeAction::partialMock()->shouldReceive('handle')->never();
|
||||||
|
|
||||||
|
$response = $this->post('/initialize', [
|
||||||
|
'group_id' => 12345,
|
||||||
|
'password' => 'secret',
|
||||||
|
'mglnr' => 100102,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertErrors(['nami' => 'NaMi Login fehlgeschlagen.'], $response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testItValidatesGroupExistance(): void
|
||||||
|
{
|
||||||
|
$this->login();
|
||||||
|
InitializeAction::partialMock()->shouldReceive('handle')->never();
|
||||||
|
Auth::success(12345, 'secret');
|
||||||
|
app(GroupFake::class)->fetches(null, []);
|
||||||
|
|
||||||
|
$response = $this->post('/initialize', [
|
||||||
|
'group_id' => 185,
|
||||||
|
'password' => 'secret',
|
||||||
|
'mglnr' => 12345,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertErrors(['nami' => 'Gruppierung nicht gefunden.'], $response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItFiresJobWhenRunningInitializer(): void
|
public function testItFiresJobWhenRunningInitializer(): void
|
||||||
|
|
Loading…
Reference in New Issue