Compare commits
	
		
			No commits in common. "593386b16bba3ecc7a045ed47a6752c66a266d5b" and "8abe2174306c7440e4659823df8f1a9947d7291b" have entirely different histories.
		
	
	
		
			593386b16b
			...
			8abe217430
		
	
		|  | @ -18,6 +18,7 @@ use Illuminate\Http\RedirectResponse; | |||
| use Illuminate\Validation\ValidationException; | ||||
| use Lorisleiva\Actions\ActionRequest; | ||||
| use Lorisleiva\Actions\Concerns\AsAction; | ||||
| use Zoomyboy\LaravelNami\Api; | ||||
| use Zoomyboy\LaravelNami\Nami; | ||||
| 
 | ||||
| class InitializeAction | ||||
|  | @ -42,12 +43,12 @@ class InitializeAction | |||
|         InitializeMembers::class, | ||||
|     ]; | ||||
| 
 | ||||
|     public function handle(): void | ||||
|     { | ||||
|         $api = app(NamiSettings::class)->login(); | ||||
|     private Api $api; | ||||
| 
 | ||||
|     public function handle(int $mglnr, string $password, int $groupId): void | ||||
|     { | ||||
|         foreach ($this->initializers as $initializer) { | ||||
|             app($initializer)->handle($api); | ||||
|             app($initializer)->handle($this->api); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | @ -73,32 +74,38 @@ class InitializeAction | |||
|         ]; | ||||
|     } | ||||
| 
 | ||||
|     public function asController(ActionRequest $request): RedirectResponse | ||||
|     public function asController(ActionRequest $request, NamiSettings $settings): RedirectResponse | ||||
|     { | ||||
|         $api = Nami::freshLogin($request->input('mglnr'), $request->input('password')); | ||||
|         $this->api = Nami::login($request->input('mglnr'), $request->input('password')); | ||||
| 
 | ||||
|         if (!$api->hasGroup($request->input('group_id'))) { | ||||
|         if (!$this->api->hasGroup($request->input('group_id'))) { | ||||
|             throw ValidationException::withMessages(['nami' => 'Gruppierung nicht gefunden.']); | ||||
|         } | ||||
| 
 | ||||
|         $this->setApi((int) $request->input('mglnr'), $request->input('password'), (int) $request->input('group_id')); | ||||
|         self::dispatch(); | ||||
|         $settings->mglnr = $request->input('mglnr'); | ||||
|         $settings->password = $request->input('password'); | ||||
|         $settings->default_group_id = $request->input('group_id'); | ||||
|         $settings->save(); | ||||
| 
 | ||||
|         $this->handle( | ||||
|             (int) $request->input('mglnr', 0), | ||||
|             (string) $request->input('password', ''), | ||||
|             (int) $request->input('group_id', 0) | ||||
|         ); | ||||
| 
 | ||||
|         return redirect()->route('home')->success('Initialisierung beauftragt. Wir benachrichtigen dich per Mail wenn alles fertig ist.'); | ||||
|     } | ||||
| 
 | ||||
|     public function asCommand(Command $command): void | ||||
|     public function asCommand(Command $command, NamiSettings $settings): void | ||||
|     { | ||||
|         $this->setApi((int) $command->option('mglnr'), $command->option('password'), (int) $command->option('group')); | ||||
|         self::dispatch(); | ||||
|     } | ||||
| 
 | ||||
|     private function setApi(int $mglnr, string $password, int $groupId): void | ||||
|     { | ||||
|         $settings = app(NamiSettings::class); | ||||
|         $mglnr = (int) $command->option('mglnr'); | ||||
|         $password = $command->option('password'); | ||||
|         $group = (int) $command->option('group'); | ||||
|         $this->api = Nami::login($mglnr, $password); | ||||
|         $settings->mglnr = $mglnr; | ||||
|         $settings->password = $password; | ||||
|         $settings->default_group_id = $groupId; | ||||
|         $settings->default_group_id = $group; | ||||
|         $settings->save(); | ||||
|         $this->handle((int) $mglnr, (string) $password, (int) $group); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -9247,7 +9247,7 @@ | |||
|             "dist": { | ||||
|                 "type": "path", | ||||
|                 "url": "./packages/tex", | ||||
|                 "reference": "48251272de62e3fea044a7ad31e1a411c15eb4c6" | ||||
|                 "reference": "6f162102ef7ceca41822d18c3e694abd926f550b" | ||||
|             }, | ||||
|             "type": "library", | ||||
|             "extra": { | ||||
|  |  | |||
|  | @ -1 +1 @@ | |||
| Subproject commit 75983ebb4bad205629b57e18915b2f15fa38e835 | ||||
| Subproject commit a41b190cc2509ee940967b6c108a557b0a9c5def | ||||
|  | @ -564,6 +564,11 @@ parameters: | |||
|             count: 1 | ||||
|             path: tests/Feature/Initialize/InitializeActionTest.php | ||||
| 
 | ||||
|         - | ||||
|             message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:with\\(\\)\\.$#" | ||||
|             count: 1 | ||||
|             path: tests/Feature/Initialize/InitializeActionTest.php | ||||
| 
 | ||||
|         - | ||||
|             message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:once\\(\\)\\.$#" | ||||
|             count: 2 | ||||
|  |  | |||
|  | @ -26,7 +26,7 @@ class InitializeActionTest extends TestCase | |||
|     public function testItSetsSettingsBeforeRunningInitializer(): void | ||||
|     { | ||||
|         $this->withoutExceptionHandling()->login(); | ||||
|         InitializeAction::partialMock()->shouldReceive('handle')->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']]); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue