Compare commits
	
		
			18 Commits
		
	
	
		
			45e8d8e1a5
			...
			eaa6482b83
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | eaa6482b83 | |
|  | ea4d770f6d | |
|  | b34328c699 | |
|  | bb9b35174c | |
|  | ee9ce464ca | |
|  | fea184893c | |
|  | 4fb8a2c626 | |
|  | c025e5e454 | |
|  | 94efb99ea4 | |
|  | a3bdf5d9ee | |
|  | e86073d438 | |
|  | 36145a3c83 | |
|  | e37f01c977 | |
|  | 4dce426e4f | |
|  | f0fbce8e0c | |
|  | 49f645ac3f | |
|  | 6e2f1456aa | |
|  | 67fe88c9b4 | 
|  | @ -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 = (int) $request->input('mglnr'); |         $settings->mglnr = $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((int) $input['mglnr'], $input['password'])->searchLayerOptions( |         return Nami::login($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((int) $input['mglnr'], $input['password']); |         Nami::freshLogin($input['mglnr'], $input['password']); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  |  | ||||||
|  | @ -4,7 +4,6 @@ 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; | ||||||
|  | @ -12,7 +11,7 @@ use Zoomyboy\LaravelNami\Nami; | ||||||
| 
 | 
 | ||||||
| class NamiSettings extends LocalSettings implements Storeable | class NamiSettings extends LocalSettings implements Storeable | ||||||
| { | { | ||||||
|     public int $mglnr; |     public string $mglnr; | ||||||
| 
 | 
 | ||||||
|     public string $password; |     public string $password; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1 +1 @@ | ||||||
| Subproject commit 35bed01848492471d6e4141f303f74ab19d1fc09 | Subproject commit 47f01b3c3c98821603f3612511d713cf51a6a14c | ||||||
|  | @ -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(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -0,0 +1,84 @@ | ||||||
|  | <?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(int $mglnr = 12345, string $password = 'password', int|Group $groupId = 55): static |     public function loginNami(string $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(int $mglnr = 12345, string $password = 'password', int $groupId = 55): self |     public function withNamiSettings(string $mglnr = '12345', string $password = 'password', int $groupId = 55): self | ||||||
|     { |     { | ||||||
|         NamiSettings::fake([ |         NamiSettings::fake([ | ||||||
|             'mglnr' => $mglnr, |             'mglnr' => $mglnr, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue