Compare commits
17 Commits
eaa6482b83
...
45e8d8e1a5
Author | SHA1 | Date |
---|---|---|
|
45e8d8e1a5 | |
|
700c352b8e | |
|
9d73facf9e | |
|
322b392061 | |
|
5a83a01e89 | |
|
ad47b76d25 | |
|
86a9596e84 | |
|
40590a76b1 | |
|
23e70a73f1 | |
|
13d0252e6f | |
|
59aaae0971 | |
|
ca66751e4d | |
|
6e5c98dfad | |
|
2298bf2d18 | |
|
0eff9e20ae | |
|
58354ce340 | |
|
4996c0a4b1 |
|
@ -65,4 +65,4 @@ class ContributionFactory
|
||||||
public function validateType(HasContributionData $request): void {
|
public function validateType(HasContributionData $request): void {
|
||||||
Validator::make(['type' => $request->type()], $this->typeRule())->validate();
|
Validator::make(['type' => $request->type()], $this->typeRule())->validate();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ class InitializeAction
|
||||||
|
|
||||||
public function asController(ActionRequest $request, NamiSettings $settings): RedirectResponse
|
public function asController(ActionRequest $request, NamiSettings $settings): RedirectResponse
|
||||||
{
|
{
|
||||||
$settings->mglnr = $request->input('mglnr');
|
$settings->mglnr = (int) $request->input('mglnr');
|
||||||
$settings->password = $request->input('password');
|
$settings->password = $request->input('password');
|
||||||
$settings->default_group_id = (int) $request->input('group_id');
|
$settings->default_group_id = (int) $request->input('group_id');
|
||||||
$settings->search_params = $request->input('params');
|
$settings->search_params = $request->input('params');
|
||||||
|
|
|
@ -21,7 +21,7 @@ class NamiGetSearchLayerAction
|
||||||
*/
|
*/
|
||||||
public function handle(array $input): Collection
|
public function handle(array $input): Collection
|
||||||
{
|
{
|
||||||
return Nami::login($input['mglnr'], $input['password'])->searchLayerOptions(
|
return Nami::login((int) $input['mglnr'], $input['password'])->searchLayerOptions(
|
||||||
SearchLayer::from($input['layer'] ?: 0),
|
SearchLayer::from($input['layer'] ?: 0),
|
||||||
$input['parent'] ?: null
|
$input['parent'] ?: null
|
||||||
);
|
);
|
||||||
|
|
|
@ -16,7 +16,7 @@ class NamiLoginCheckAction
|
||||||
*/
|
*/
|
||||||
public function handle(array $input): void
|
public function handle(array $input): void
|
||||||
{
|
{
|
||||||
Nami::freshLogin($input['mglnr'], $input['password']);
|
Nami::freshLogin((int) $input['mglnr'], $input['password']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Setting;
|
||||||
|
|
||||||
use App\Group;
|
use App\Group;
|
||||||
use App\Initialize\Actions\NamiLoginCheckAction;
|
use App\Initialize\Actions\NamiLoginCheckAction;
|
||||||
|
use App\Nami\Actions\SettingSaveAction;
|
||||||
use App\Setting\Contracts\Storeable;
|
use App\Setting\Contracts\Storeable;
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
use Zoomyboy\LaravelNami\Api;
|
use Zoomyboy\LaravelNami\Api;
|
||||||
|
@ -11,7 +12,7 @@ use Zoomyboy\LaravelNami\Nami;
|
||||||
|
|
||||||
class NamiSettings extends LocalSettings implements Storeable
|
class NamiSettings extends LocalSettings implements Storeable
|
||||||
{
|
{
|
||||||
public string $mglnr;
|
public int $mglnr;
|
||||||
|
|
||||||
public string $password;
|
public string $password;
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 47f01b3c3c98821603f3612511d713cf51a6a14c
|
Subproject commit 35bed01848492471d6e4141f303f74ab19d1fc09
|
|
@ -15,7 +15,7 @@ class PsPendingBlockTest extends TestCase
|
||||||
|
|
||||||
public function testItRendersContent(): void
|
public function testItRendersContent(): void
|
||||||
{
|
{
|
||||||
$this->withoutExceptionHandling()->withNamiSettings('12345', 'password', 101);
|
$this->withoutExceptionHandling()->withNamiSettings(12345, 'password', 101);
|
||||||
$group = Group::factory()->inNami(101)->create();
|
$group = Group::factory()->inNami(101)->create();
|
||||||
|
|
||||||
$noPsAtAll = Member::factory()
|
$noPsAtAll = Member::factory()
|
||||||
|
@ -72,7 +72,7 @@ class PsPendingBlockTest extends TestCase
|
||||||
|
|
||||||
public function testItExcludesForeignGroups(): void
|
public function testItExcludesForeignGroups(): void
|
||||||
{
|
{
|
||||||
$this->withoutExceptionHandling()->withNamiSettings('12345', 'password', 101);
|
$this->withoutExceptionHandling()->withNamiSettings(12345, 'password', 101);
|
||||||
Group::factory()->inNami(101)->create();
|
Group::factory()->inNami(101)->create();
|
||||||
$otherGroup = Group::factory()->inNami(55)->create();
|
$otherGroup = Group::factory()->inNami(55)->create();
|
||||||
|
|
||||||
|
|
|
@ -1,84 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Feature\Nami;
|
|
||||||
|
|
||||||
use App\Invoice\InvoiceSettings;
|
|
||||||
use App\Setting\NamiSettings;
|
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
||||||
use Tests\TestCase;
|
|
||||||
use Zoomyboy\LaravelNami\Authentication\Auth;
|
|
||||||
use Zoomyboy\LaravelNami\Nami;
|
|
||||||
|
|
||||||
uses(DatabaseTransactions::class);
|
|
||||||
|
|
||||||
it('testItDisplaysView', function () {
|
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
|
||||||
|
|
||||||
$this->get(route('setting.view', ['settingGroup' => 'nami']))
|
|
||||||
->assertOk()
|
|
||||||
->assertComponent('setting/Nami');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('testDisplaySettings', function () {
|
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
|
||||||
app(NamiSettings::class)->fill([
|
|
||||||
'mglnr' => '0111',
|
|
||||||
'password' => 'secret',
|
|
||||||
'default_group_id' => '12345',
|
|
||||||
'search_params' => [],
|
|
||||||
])->save();
|
|
||||||
|
|
||||||
$this->get(route('setting.data', ['settingGroup' => 'nami']))
|
|
||||||
->assertOk()
|
|
||||||
->assertComponent('setting/Nami')
|
|
||||||
->assertInertiaPath('data.mglnr', '0111')
|
|
||||||
->assertInertiaPath('data.password', '')
|
|
||||||
->assertInertiaPath('data.default_group_id', 12345);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('testItCanChangeSettings', function () {
|
|
||||||
$this->login()->loginNami();
|
|
||||||
Auth::success(90100, 'secret');
|
|
||||||
|
|
||||||
$response = $this->from('/setting/nami')->post('/setting/nami', [
|
|
||||||
'mglnr' => 90100,
|
|
||||||
'password' => 'secret',
|
|
||||||
'default_group_id' => '12345',
|
|
||||||
'search_params' => [],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response->assertRedirect('/setting/nami');
|
|
||||||
$settings = app(NamiSettings::class);
|
|
||||||
$this->assertEquals(90100, $settings->mglnr);
|
|
||||||
$this->assertEquals('secret', $settings->password);
|
|
||||||
$this->assertEquals('12345', $settings->default_group_id);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('validates settings', function () {
|
|
||||||
$this->login()->loginNami();
|
|
||||||
|
|
||||||
$this->from('/setting/nami')->post('/setting/nami', [
|
|
||||||
'mglnr' => 90100,
|
|
||||||
'password' => 'fdsfsdfdsf',
|
|
||||||
'default_group_id' => '12345',
|
|
||||||
'search_params' => [],
|
|
||||||
])->assertSessionHasErrors(['nami' => 'NaMi Login fehlgeschlagen.']);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can set mglnr to a string', function () {
|
|
||||||
$this->login()->loginNami();
|
|
||||||
Auth::success('090100', 'secret');
|
|
||||||
|
|
||||||
$response = $this->from('/setting/nami')->post('/setting/nami', [
|
|
||||||
'mglnr' => '090100',
|
|
||||||
'password' => 'secret',
|
|
||||||
'default_group_id' => '12345',
|
|
||||||
'search_params' => [],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response->assertRedirect('/setting/nami');
|
|
||||||
$settings = app(NamiSettings::class);
|
|
||||||
$this->assertSame('090100', $settings->mglnr);
|
|
||||||
$this->assertEquals('secret', $settings->password);
|
|
||||||
$this->assertEquals('12345', $settings->default_group_id);
|
|
||||||
});
|
|
|
@ -37,7 +37,7 @@ class TestCase extends BaseTestCase
|
||||||
$this->initInertiaTestcase();
|
$this->initInertiaTestcase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loginNami(string $mglnr = '12345', string $password = 'password', int|Group $groupId = 55): static
|
public function loginNami(int $mglnr = 12345, string $password = 'password', int|Group $groupId = 55): static
|
||||||
{
|
{
|
||||||
Auth::success($mglnr, $password);
|
Auth::success($mglnr, $password);
|
||||||
$group = is_int($groupId)
|
$group = is_int($groupId)
|
||||||
|
@ -49,7 +49,7 @@ class TestCase extends BaseTestCase
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withNamiSettings(string $mglnr = '12345', string $password = 'password', int $groupId = 55): self
|
public function withNamiSettings(int $mglnr = 12345, string $password = 'password', int $groupId = 55): self
|
||||||
{
|
{
|
||||||
NamiSettings::fake([
|
NamiSettings::fake([
|
||||||
'mglnr' => $mglnr,
|
'mglnr' => $mglnr,
|
||||||
|
|
Loading…
Reference in New Issue