Add mailman Settings

This commit is contained in:
Philipp Lang 2022-10-18 15:04:47 +02:00
parent dd07a68762
commit 3976e8f502
10 changed files with 628 additions and 355 deletions

View File

@ -0,0 +1,35 @@
<?php
namespace App\Mailman\Actions;
use App\Mailman\MailmanSettings;
use Inertia\Inertia;
use Inertia\Response;
use Lorisleiva\Actions\Concerns\AsAction;
class SettingIndexAction
{
use AsAction;
/**
* @return array<string, string>
*/
public function handle(MailmanSettings $settings): array
{
return [
'base_url' => $settings->base_url,
'username' => $settings->username,
'password' => '',
];
}
public function asController(MailmanSettings $settings): Response
{
session()->put('menu', 'setting');
session()->put('title', 'Mailman-Einstellungen');
return Inertia::render('setting/Index', [
'data' => $this->handle($settings),
]);
}
}

View File

@ -0,0 +1,45 @@
<?php
namespace App\Mailman\Actions;
use App\Mailman\MailmanSettings;
use App\Mailman\Support\MailmanService;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Http\RedirectResponse;
use Lorisleiva\Actions\ActionRequest;
use Lorisleiva\Actions\Concerns\AsAction;
class SettingSaveAction
{
use AsAction;
/**
* @param array<string, string> $input
*/
public function handle(array $input): void
{
$settings = app(MailmanSettings::class);
$settings->fill([
'base_url' => $input['base_url'] ?? null,
'username' => $input['username'] ?? null,
'password' => $input['password'] ?? null,
]);
$settings->save();
}
public function afterValidator(Validator $validator, ActionRequest $request): void
{
if (!app(MailmanService::class)->setCredentials($request->input('base_url'), $request->input('username'), $request->input('password'))->check()) {
$validator->errors()->add('mailman', 'Verbindung fehlgeschlagen.');
}
}
public function asController(ActionRequest $request): RedirectResponse
{
$this->handle($request->all());
return redirect()->back()->success('Einstellungen gespeichert');
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Mailman;
use Spatie\LaravelSettings\Settings;
class MailmanSettings extends Settings
{
public ?string $base_url;
public ?string $username;
public ?string $password;
public static function group(): string
{
return 'mailman';
}
}

View File

@ -0,0 +1,14 @@
<?php
namespace App\Mailman\Support;
class MailmanService
{
public function setCredentials(string $baseUrl, string $username, string $password): self
{
}
public function check(): bool
{
}
}

View File

@ -25,6 +25,7 @@
"lorisleiva/laravel-actions": "^2.4",
"monicahq/laravel-sabre": "^1.6",
"nunomaduro/collision": "^6.1",
"phake/phake": "^4.2",
"spatie/laravel-data": "^1.4",
"spatie/laravel-ignition": "^1.0",
"spatie/laravel-medialibrary": "^10.0",

771
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "435651f6b234aa7eced95980e8ebaca7",
"content-hash": "595c09f60f56154860edae7e0d666e16",
"packages": [
{
"name": "beyondcode/laravel-dump-server",
@ -778,6 +778,76 @@
],
"time": "2022-09-07T09:01:28+00:00"
},
{
"name": "doctrine/instantiator",
"version": "1.4.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "10dcfce151b967d20fde1b34ae6640712c3891bc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc",
"reference": "10dcfce151b967d20fde1b34ae6640712c3891bc",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^9",
"ext-pdo": "*",
"ext-phar": "*",
"phpbench/phpbench": "^0.16 || ^1",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan-phpunit": "^1",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"vimeo/psalm": "^4.22"
},
"type": "library",
"autoload": {
"psr-4": {
"Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com",
"homepage": "https://ocramius.github.io/"
}
],
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
"homepage": "https://www.doctrine-project.org/projects/instantiator.html",
"keywords": [
"constructor",
"instantiate"
],
"support": {
"issues": "https://github.com/doctrine/instantiator/issues",
"source": "https://github.com/doctrine/instantiator/tree/1.4.1"
},
"funding": [
{
"url": "https://www.doctrine-project.org/sponsorship.html",
"type": "custom"
},
{
"url": "https://www.patreon.com/phpdoctrine",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator",
"type": "tidelift"
}
],
"time": "2022-03-03T08:28:38+00:00"
},
{
"name": "doctrine/lexer",
"version": "1.2.3",
@ -3515,6 +3585,75 @@
],
"time": "2022-08-01T11:03:24+00:00"
},
{
"name": "phake/phake",
"version": "v4.2.0",
"source": {
"type": "git",
"url": "https://github.com/phake/phake.git",
"reference": "5dbe829daa0a08b18bad60d4d482ca78abfcacad"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phake/phake/zipball/5dbe829daa0a08b18bad60d4d482ca78abfcacad",
"reference": "5dbe829daa0a08b18bad60d4d482ca78abfcacad",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.4",
"php": "^7.1|^8.0",
"sebastian/comparator": "^1.1|^2.0|^3.0|^4.0"
},
"require-dev": {
"doctrine/common": "^3.0",
"ext-soap": "*",
"hamcrest/hamcrest-php": "1.1.*",
"phpunit/phpunit": "^6.5|^7.0|^8.0|^9.0"
},
"suggest": {
"doctrine/common": "Allows mock annotations to use import statements for classes.",
"hamcrest/hamcrest-php": "Use Hamcrest matchers."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
}
},
"autoload": {
"files": [
"src/Phake.php"
],
"psr-4": {
"Phake\\": "src/Phake"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Mike Lively",
"email": "m@digitalsandwich.com"
}
],
"description": "The Phake mock testing library",
"homepage": "https://github.com/phake/phake",
"keywords": [
"mock",
"phake",
"spy",
"stub",
"test-doubles",
"testing"
],
"support": {
"issues": "https://github.com/phake/phake/issues",
"source": "https://github.com/phake/phake/tree/v4.2.0"
},
"time": "2021-11-30T20:18:47+00:00"
},
{
"name": "phpdocumentor/reflection-common",
"version": "2.2.0",
@ -4844,6 +4983,286 @@
},
"time": "2021-11-04T06:37:27+00:00"
},
{
"name": "sebastian/comparator",
"version": "4.0.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "fa0f136dd2334583309d32b62544682ee972b51a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a",
"reference": "fa0f136dd2334583309d32b62544682ee972b51a",
"shasum": ""
},
"require": {
"php": ">=7.3",
"sebastian/diff": "^4.0",
"sebastian/exporter": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Volker Dusch",
"email": "github@wallbash.com"
},
{
"name": "Bernhard Schussek",
"email": "bschussek@2bepublished.at"
}
],
"description": "Provides the functionality to compare PHP values for equality",
"homepage": "https://github.com/sebastianbergmann/comparator",
"keywords": [
"comparator",
"compare",
"equality"
],
"support": {
"issues": "https://github.com/sebastianbergmann/comparator/issues",
"source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2022-09-14T12:41:17+00:00"
},
{
"name": "sebastian/diff",
"version": "4.0.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
"reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d",
"reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3",
"symfony/process": "^4.2 || ^5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Kore Nordmann",
"email": "mail@kore-nordmann.de"
}
],
"description": "Diff implementation",
"homepage": "https://github.com/sebastianbergmann/diff",
"keywords": [
"diff",
"udiff",
"unidiff",
"unified diff"
],
"support": {
"issues": "https://github.com/sebastianbergmann/diff/issues",
"source": "https://github.com/sebastianbergmann/diff/tree/4.0.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-10-26T13:10:38+00:00"
},
{
"name": "sebastian/exporter",
"version": "4.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d",
"reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d",
"shasum": ""
},
"require": {
"php": ">=7.3",
"sebastian/recursion-context": "^4.0"
},
"require-dev": {
"ext-mbstring": "*",
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Volker Dusch",
"email": "github@wallbash.com"
},
{
"name": "Adam Harvey",
"email": "aharvey@php.net"
},
{
"name": "Bernhard Schussek",
"email": "bschussek@gmail.com"
}
],
"description": "Provides the functionality to export PHP variables for visualization",
"homepage": "https://www.github.com/sebastianbergmann/exporter",
"keywords": [
"export",
"exporter"
],
"support": {
"issues": "https://github.com/sebastianbergmann/exporter/issues",
"source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2022-09-14T06:03:37+00:00"
},
{
"name": "sebastian/recursion-context",
"version": "4.0.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/recursion-context.git",
"reference": "cd9d8cf3c5804de4341c283ed787f099f5506172"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172",
"reference": "cd9d8cf3c5804de4341c283ed787f099f5506172",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Adam Harvey",
"email": "aharvey@php.net"
}
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"support": {
"issues": "https://github.com/sebastianbergmann/recursion-context/issues",
"source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-10-26T13:17:30+00:00"
},
{
"name": "spatie/backtrace",
"version": "1.2.1",
@ -9056,76 +9475,6 @@
],
"time": "2022-02-25T21:32:43+00:00"
},
{
"name": "doctrine/instantiator",
"version": "1.4.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "10dcfce151b967d20fde1b34ae6640712c3891bc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc",
"reference": "10dcfce151b967d20fde1b34ae6640712c3891bc",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^9",
"ext-pdo": "*",
"ext-phar": "*",
"phpbench/phpbench": "^0.16 || ^1",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan-phpunit": "^1",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"vimeo/psalm": "^4.22"
},
"type": "library",
"autoload": {
"psr-4": {
"Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com",
"homepage": "https://ocramius.github.io/"
}
],
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
"homepage": "https://www.doctrine-project.org/projects/instantiator.html",
"keywords": [
"constructor",
"instantiate"
],
"support": {
"issues": "https://github.com/doctrine/instantiator/issues",
"source": "https://github.com/doctrine/instantiator/tree/1.4.1"
},
"funding": [
{
"url": "https://www.doctrine-project.org/sponsorship.html",
"type": "custom"
},
{
"url": "https://www.patreon.com/phpdoctrine",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator",
"type": "tidelift"
}
],
"time": "2022-03-03T08:28:38+00:00"
},
{
"name": "fakerphp/faker",
"version": "v1.20.0",
@ -10649,80 +10998,6 @@
],
"time": "2020-09-28T05:30:19+00:00"
},
{
"name": "sebastian/comparator",
"version": "4.0.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "fa0f136dd2334583309d32b62544682ee972b51a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a",
"reference": "fa0f136dd2334583309d32b62544682ee972b51a",
"shasum": ""
},
"require": {
"php": ">=7.3",
"sebastian/diff": "^4.0",
"sebastian/exporter": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Volker Dusch",
"email": "github@wallbash.com"
},
{
"name": "Bernhard Schussek",
"email": "bschussek@2bepublished.at"
}
],
"description": "Provides the functionality to compare PHP values for equality",
"homepage": "https://github.com/sebastianbergmann/comparator",
"keywords": [
"comparator",
"compare",
"equality"
],
"support": {
"issues": "https://github.com/sebastianbergmann/comparator/issues",
"source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2022-09-14T12:41:17+00:00"
},
{
"name": "sebastian/complexity",
"version": "2.0.2",
@ -10780,72 +11055,6 @@
],
"time": "2020-10-26T15:52:27+00:00"
},
{
"name": "sebastian/diff",
"version": "4.0.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
"reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d",
"reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3",
"symfony/process": "^4.2 || ^5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Kore Nordmann",
"email": "mail@kore-nordmann.de"
}
],
"description": "Diff implementation",
"homepage": "https://github.com/sebastianbergmann/diff",
"keywords": [
"diff",
"udiff",
"unidiff",
"unified diff"
],
"support": {
"issues": "https://github.com/sebastianbergmann/diff/issues",
"source": "https://github.com/sebastianbergmann/diff/tree/4.0.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-10-26T13:10:38+00:00"
},
{
"name": "sebastian/environment",
"version": "5.1.4",
@ -10909,83 +11118,6 @@
],
"time": "2022-04-03T09:37:03+00:00"
},
{
"name": "sebastian/exporter",
"version": "4.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d",
"reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d",
"shasum": ""
},
"require": {
"php": ">=7.3",
"sebastian/recursion-context": "^4.0"
},
"require-dev": {
"ext-mbstring": "*",
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Volker Dusch",
"email": "github@wallbash.com"
},
{
"name": "Adam Harvey",
"email": "aharvey@php.net"
},
{
"name": "Bernhard Schussek",
"email": "bschussek@gmail.com"
}
],
"description": "Provides the functionality to export PHP variables for visualization",
"homepage": "https://www.github.com/sebastianbergmann/exporter",
"keywords": [
"export",
"exporter"
],
"support": {
"issues": "https://github.com/sebastianbergmann/exporter/issues",
"source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2022-09-14T06:03:37+00:00"
},
{
"name": "sebastian/global-state",
"version": "5.0.5",
@ -11219,69 +11351,6 @@
],
"time": "2020-10-26T13:14:26+00:00"
},
{
"name": "sebastian/recursion-context",
"version": "4.0.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/recursion-context.git",
"reference": "cd9d8cf3c5804de4341c283ed787f099f5506172"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172",
"reference": "cd9d8cf3c5804de4341c283ed787f099f5506172",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Adam Harvey",
"email": "aharvey@php.net"
}
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"support": {
"issues": "https://github.com/sebastianbergmann/recursion-context/issues",
"source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-10-26T13:17:30+00:00"
},
{
"name": "sebastian/resource-operations",
"version": "3.0.3",

View File

@ -0,0 +1,13 @@
<?php
use Spatie\LaravelSettings\Migrations\SettingsMigration;
class MailmanSettings extends SettingsMigration
{
public function up(): void
{
$this->migrator->add('mailman.base_url', null);
$this->migrator->add('mailman.username', null);
$this->migrator->add('mailman.password', null);
}
}

View File

@ -7,6 +7,8 @@ use App\Course\Controllers\CourseController;
use App\Http\Controllers\HomeController;
use App\Initialize\Actions\InitializeAction;
use App\Initialize\Actions\InitializeFormAction;
use App\Mailman\Actions\SettingIndexAction as MailmanSettingIndexAction;
use App\Mailman\Actions\SettingSaveAction as MailmanSettingSaveAction;
use App\Member\Controllers\MemberResyncController;
use App\Member\MemberConfirmController;
use App\Member\MemberController;
@ -38,6 +40,8 @@ Route::group(['middleware' => 'auth:web'], function (): void {
Route::apiResource('member.membership', MembershipController::class);
Route::get('setting/bill', BillSettingIndexAction::class);
Route::post('setting/bill', BillSettingSaveAction::class);
Route::get('setting/mailman', MailmanSettingIndexAction::class);
Route::post('setting/mailman', MailmanSettingSaveAction::class);
Route::resource('member.course', CourseController::class);
Route::get('/member/{member}/efz', MemberEfzController::class)->name('efz');
Route::get('/member/{member}/resync', MemberResyncController::class)->name('member.resync');

View File

@ -0,0 +1,75 @@
<?php
namespace Tests\Feature\Mailman;
use App\Mailman\MailmanSettings;
use App\Mailman\Support\MailmanService;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Phake;
use Tests\TestCase;
class SettingTest extends TestCase
{
use DatabaseTransactions;
public function testItGetsMailSettings(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
MailmanSettings::fake([
'base_url' => 'http://mailman.test/api',
'username' => 'user',
'password' => 'secret',
]);
$response = $this->get('/setting/mailman');
$response->assertOk();
$this->assertInertiaHas([
'base_url' => 'http://mailman.test/api',
'username' => 'user',
'password' => '',
], $response, 'data');
}
public function testItSaesMailmanSettings(): void
{
$this->stubIo(MailmanService::class, function ($mock) {
Phake::when($mock)->setCredentials('http://mailman.test/api', 'user', 'secret')->thenReturn($mock);
Phake::when($mock)->check()->thenReturn(true);
});
$this->withoutExceptionHandling()->login()->loginNami();
$response = $this->from('/setting/mailman')->post('/setting/mailman', [
'base_url' => 'http://mailman.test/api',
'username' => 'user',
'password' => 'secret',
]);
$response->assertRedirect('/setting/mailman');
$settings = app(MailmanSettings::class);
$this->assertEquals('http://mailman.test/api', $settings->base_url);
$this->assertEquals('secret', $settings->password);
$this->assertEquals('user', $settings->username);
Phake::verify(app(MailmanService::class))->setCredentials('http://mailman.test/api', 'user', 'secret');
Phake::verify(app(MailmanService::class))->check();
}
public function testItThrowsErrorWhenLoginFailed(): void
{
$this->stubIo(MailmanService::class, function ($mock) {
Phake::when($mock)->setCredentials('http://mailman.test/api', 'user', 'secret')->thenReturn($mock);
Phake::when($mock)->check()->thenReturn(false);
});
$this->login()->loginNami();
$response = $this->from('/setting/mailman')->post('/setting/mailman', [
'base_url' => 'http://mailman.test/api',
'username' => 'user',
'password' => 'secret',
]);
$response->assertSessionHasErrors(['mailman' => 'Verbindung fehlgeschlagen.']);
Phake::verify(app(MailmanService::class))->setCredentials('http://mailman.test/api', 'user', 'secret');
Phake::verify(app(MailmanService::class))->check();
}
}

View File

@ -9,8 +9,7 @@ use App\User;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Http\RedirectResponse;
use Illuminate\Testing\TestResponse;
use Mockery as M;
use Mockery\MockInterface;
use Phake;
use Tests\Lib\TestsInertia;
use Zoomyboy\LaravelNami\Authentication\Auth;
@ -93,11 +92,10 @@ abstract class TestCase extends BaseTestCase
/**
* @param <class-string> $class
* @param callable(MockInterface $mock): void $mocker
*/
public function stubIo(string $class, callable $mocker): self
{
$mock = M::mock($class);
$mock = Phake::mock($class);
$mocker($mock);