Fixed tests
This commit is contained in:
parent
a30d2659ad
commit
c3adcc6fdb
|
@ -5,7 +5,6 @@ namespace App\Console\Commands;
|
|||
use App\Initialize\Initializer;
|
||||
use Illuminate\Console\Command;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\NamiUser;
|
||||
|
||||
class NamiInitializeCommand extends Command
|
||||
{
|
||||
|
@ -40,15 +39,7 @@ class NamiInitializeCommand extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
app(Initializer::class)->run(NamiUser::fromPayload([
|
||||
'credentials' => [
|
||||
'mglnr' => $this->option('mglnr'),
|
||||
'password' => $this->option('password'),
|
||||
],
|
||||
'firstname' => 'Console',
|
||||
'lastname' => 'Console',
|
||||
'group_id' => $this->option('group_id'),
|
||||
]));
|
||||
app(Initializer::class)->run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -21,16 +21,16 @@ class CourseController extends Controller
|
|||
return redirect()->back()->success('Ausbildung erstellt');
|
||||
}
|
||||
|
||||
public function update(Member $member, CourseMember $course, UpdateRequest $request): RedirectResponse
|
||||
public function update(Member $member, CourseMember $course, UpdateRequest $request, NamiSettings $settings): RedirectResponse
|
||||
{
|
||||
$request->persist($member, $course);
|
||||
$request->persist($member, $course, $settings);
|
||||
|
||||
return redirect()->back()->success('Ausbildung aktualisiert');
|
||||
}
|
||||
|
||||
public function destroy(Member $member, CourseMember $course, DestroyRequest $request): RedirectResponse
|
||||
public function destroy(Member $member, CourseMember $course, DestroyRequest $request, NamiSettings $settings): RedirectResponse
|
||||
{
|
||||
$request->persist($member, $course);
|
||||
$request->persist($member, $course, $settings);
|
||||
|
||||
return redirect()->back()->success('Ausbildung gelöscht');
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Course\Requests;
|
|||
use App\Course\Models\Course;
|
||||
use App\Course\Models\CourseMember;
|
||||
use App\Member\Member;
|
||||
use App\Setting\NamiSettings;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
@ -32,13 +33,9 @@ class DestroyRequest extends FormRequest
|
|||
return [];
|
||||
}
|
||||
|
||||
public function persist(Member $member, CourseMember $course): void
|
||||
public function persist(Member $member, CourseMember $course, NamiSettings $settings): void
|
||||
{
|
||||
try {
|
||||
auth()->user()->api()->deleteCourse($member->nami_id, $course->nami_id);
|
||||
} catch(NamiException $e) {
|
||||
throw ValidationException::withMessages(['id' => 'Unbekannter Fehler']);
|
||||
}
|
||||
$settings->login()->deleteCourse($member->nami_id, $course->nami_id);
|
||||
|
||||
$course->delete();
|
||||
}
|
||||
|
|
|
@ -47,11 +47,7 @@ class StoreRequest extends FormRequest
|
|||
'course_id' => $course->nami_id,
|
||||
])->toArray();
|
||||
|
||||
try {
|
||||
$namiId = Nami::login($settings->mglnr, $settings->password)->createCourse($member->nami_id, $payload);
|
||||
} catch(NamiException $e) {
|
||||
throw ValidationException::withMessages(['id' => 'Unbekannter Fehler']);
|
||||
}
|
||||
$namiId = $settings->login()->createCourse($member->nami_id, $payload);
|
||||
|
||||
$member->courses()->create($this->safe()->collect()->put('nami_id', $namiId)->toArray());
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Course\Requests;
|
|||
use App\Course\Models\Course;
|
||||
use App\Course\Models\CourseMember;
|
||||
use App\Member\Member;
|
||||
use App\Setting\NamiSettings;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
@ -37,13 +38,13 @@ class UpdateRequest extends FormRequest
|
|||
];
|
||||
}
|
||||
|
||||
public function persist(Member $member, CourseMember $course): void
|
||||
public function persist(Member $member, CourseMember $course, NamiSettings $settings): void
|
||||
{
|
||||
try {
|
||||
auth()->user()->api()->updateCourse($member->nami_id, $course->nami_id, $this->safe()->merge(['course_id' => Course::find($this->input('course_id'))->nami_id])->toArray());
|
||||
} catch(NamiException $e) {
|
||||
throw ValidationException::withMessages(['id' => 'Unbekannter Fehler']);
|
||||
}
|
||||
$settings->login()->updateCourse(
|
||||
$member->nami_id,
|
||||
$course->nami_id,
|
||||
$this->safe()->merge(['course_id' => Course::find($this->input('course_id'))->nami_id])->toArray()
|
||||
);
|
||||
|
||||
$course->update($this->safe()->toArray());
|
||||
}
|
||||
|
|
|
@ -39,13 +39,6 @@ class Handler extends ExceptionHandler
|
|||
*/
|
||||
public function report(Throwable $exception)
|
||||
{
|
||||
if (is_a($exception, NamiException::class)) {
|
||||
\Log::error($exception->getMessage(), [
|
||||
'request' => $exception->request,
|
||||
'response' => $exception->response
|
||||
]);
|
||||
}
|
||||
|
||||
parent::report($exception);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ namespace App\Http\Controllers\Auth;
|
|||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Inertia\Response;
|
||||
use Zoomyboy\LaravelNami\AuthenticatesNamiUsers;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ class LoginController extends Controller
|
|||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesNamiUsers;
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
|
@ -42,4 +42,5 @@ class LoginController extends Controller
|
|||
public function showLoginForm(): Response {
|
||||
return \Inertia::render('VLogin');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use Illuminate\Http\Resources\Json\JsonResource;
|
|||
use Storage;
|
||||
|
||||
/**
|
||||
* @mixin \Zoomyboy\LaravelNami\NamiUser
|
||||
* @mixin \App\User
|
||||
*/
|
||||
class UserResource extends JsonResource
|
||||
{
|
||||
|
@ -19,8 +19,8 @@ class UserResource extends JsonResource
|
|||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'name' => $this->getFirstname(),
|
||||
'email' => null,
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'avatar' => [
|
||||
'src' => Storage::url('avatar.png')
|
||||
]
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Initialize;
|
||||
|
||||
use Zoomyboy\LaravelNami\Api;
|
||||
use Zoomyboy\LaravelNami\NamiUser;
|
||||
|
||||
class InitializeActivities {
|
||||
|
||||
|
@ -13,8 +12,9 @@ class InitializeActivities {
|
|||
$this->api = $api;
|
||||
}
|
||||
|
||||
public function handle(NamiUser $user): void
|
||||
public function handle(): void
|
||||
{
|
||||
app(ActivityCreator::class)->createFor($this->api, $user->getNamiGroupId());
|
||||
$groupId = $this->api->groups()->first()->id;
|
||||
app(ActivityCreator::class)->createFor($this->api, $groupId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace App\Initialize;
|
|||
use App\Course\Models\Course;
|
||||
use Aweos\Agnoster\Progress\Progress;
|
||||
use Zoomyboy\LaravelNami\Api;
|
||||
use Zoomyboy\LaravelNami\NamiUser;
|
||||
|
||||
class InitializeCourses {
|
||||
|
||||
|
@ -15,7 +14,7 @@ class InitializeCourses {
|
|||
$this->api = $api;
|
||||
}
|
||||
|
||||
public function handle(NamiUser $user): void
|
||||
public function handle(): void
|
||||
{
|
||||
$this->api->courses()->each(function($course) {
|
||||
Course::create(['nami_id' => $course->id, 'name' => $course->name]);
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Initialize;
|
||||
|
||||
use App\Fee;
|
||||
use Zoomyboy\LaravelNami\Api;
|
||||
use Zoomyboy\LaravelNami\NamiUser;
|
||||
|
||||
class InitializeFees {
|
||||
|
||||
|
@ -13,10 +13,11 @@ class InitializeFees {
|
|||
$this->api = $api;
|
||||
}
|
||||
|
||||
public function handle(NamiUser $user): void
|
||||
public function handle(): void
|
||||
{
|
||||
$this->api->feesOf($user->getNamiGroupId())->each(function($fee) {
|
||||
\App\Fee::create(['nami_id' => $fee->id, 'name' => $fee->name])
|
||||
$group = $this->api->groups()->first()->id;
|
||||
$this->api->feesOf($group)->each(function($fee) {
|
||||
Fee::create(['nami_id' => $fee->id, 'name' => $fee->name])
|
||||
->subscriptions()->create([
|
||||
'name' => $fee->name,
|
||||
'amount' => 1000,
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Initialize;
|
||||
|
||||
use Zoomyboy\LaravelNami\Api;
|
||||
use Zoomyboy\LaravelNami\NamiUser;
|
||||
|
||||
class InitializeGenders {
|
||||
|
||||
|
@ -13,7 +12,7 @@ class InitializeGenders {
|
|||
$this->api = $api;
|
||||
}
|
||||
|
||||
public function handle(NamiUser $user): void
|
||||
public function handle(): void
|
||||
{
|
||||
$this->api->genders()->each(function($gender) {
|
||||
\App\Gender::create(['nami_id' => $gender->id, 'name' => $gender->name]);
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace App\Initialize;
|
|||
|
||||
use App\Group;
|
||||
use Zoomyboy\LaravelNami\Api;
|
||||
use Zoomyboy\LaravelNami\NamiUser;
|
||||
|
||||
class InitializeGroups {
|
||||
|
||||
|
|
|
@ -9,19 +9,11 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
|||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Zoomyboy\LaravelNami\NamiUser;
|
||||
|
||||
class InitializeJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasProgress;
|
||||
|
||||
public NamiUser $user;
|
||||
|
||||
public function __construct(NamiUser $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
|
@ -29,6 +21,6 @@ class InitializeJob implements ShouldQueue
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
app(Initializer::class)->run($this->user);
|
||||
app(Initializer::class)->run();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Initialize;
|
||||
|
||||
use App\Nationality;
|
||||
use Zoomyboy\LaravelNami\Api;
|
||||
|
||||
class InitializeNationalities {
|
||||
|
@ -12,10 +13,10 @@ class InitializeNationalities {
|
|||
$this->api = $api;
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
public function handle(Api $api): void
|
||||
{
|
||||
$this->api->nationalities()->each(function($nationality) {
|
||||
\App\Nationality::create(['nami_id' => $nationality->id, 'name' => $nationality->name]);
|
||||
Nationality::create(['nami_id' => $nationality->id, 'name' => $nationality->name]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
|
||||
namespace App\Initialize;
|
||||
|
||||
use App\Setting\NamiSettings;
|
||||
use Zoomyboy\LaravelNami\Api;
|
||||
use Zoomyboy\LaravelNami\NamiUser;
|
||||
|
||||
class Initializer {
|
||||
|
||||
public static array $initializers = [
|
||||
public NamiSettings $settings;
|
||||
public array $initializers = [
|
||||
InitializeNationalities::class,
|
||||
InitializeFees::class,
|
||||
InitializeConfessions::class,
|
||||
|
@ -19,9 +20,14 @@ class Initializer {
|
|||
InitializeMembers::class,
|
||||
];
|
||||
|
||||
public function run(NamiUser $namiUser): void {
|
||||
foreach (static::$initializers as $initializer) {
|
||||
(new $initializer($namiUser->api()))->handle($namiUser);
|
||||
public function __construct(NamiSettings $settings)
|
||||
{
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
public function run(): void {
|
||||
foreach ($this->initializers as $initializer) {
|
||||
app($initializer)->handle($this->settings->login());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
|||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\NamiUser;
|
||||
|
||||
class CreateJob implements ShouldQueue
|
||||
{
|
||||
|
@ -20,9 +19,8 @@ class CreateJob implements ShouldQueue
|
|||
|
||||
public int $memberId;
|
||||
public Member $member;
|
||||
public NamiUser $user;
|
||||
|
||||
public function __construct(Member $member, NamiUser $user)
|
||||
public function __construct(Member $member)
|
||||
{
|
||||
$this->memberId = $member->id;
|
||||
$this->user = $user;
|
||||
|
|
|
@ -9,7 +9,6 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
|||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\NamiUser;
|
||||
|
||||
class DeleteJob implements ShouldQueue
|
||||
{
|
||||
|
@ -17,9 +16,8 @@ class DeleteJob implements ShouldQueue
|
|||
|
||||
public int $memberId;
|
||||
public Member $member;
|
||||
public NamiUser $user;
|
||||
|
||||
public function __construct(Member $member, NamiUser $user)
|
||||
public function __construct(Member $member)
|
||||
{
|
||||
$this->memberId = $member->id;
|
||||
$this->user = $user;
|
||||
|
@ -38,7 +36,7 @@ class DeleteJob implements ShouldQueue
|
|||
return;
|
||||
}
|
||||
|
||||
Nami::login($this->user->mglnr)->deleteMember($this->member->nami_id);
|
||||
$setting->login()->deleteMember($this->member->nami_id);
|
||||
|
||||
Member::withoutEvents(function() {
|
||||
$this->member->update(['nami_id' => null]);
|
||||
|
|
|
@ -10,7 +10,6 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
|||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\NamiUser;
|
||||
|
||||
class UpdateJob implements ShouldQueue
|
||||
{
|
||||
|
@ -18,12 +17,10 @@ class UpdateJob implements ShouldQueue
|
|||
|
||||
public int $memberId;
|
||||
public Member $member;
|
||||
public NamiUser $user;
|
||||
|
||||
public function __construct(Member $member, NamiUser $user)
|
||||
public function __construct(Member $member)
|
||||
{
|
||||
$this->memberId = $member->id;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +36,7 @@ class UpdateJob implements ShouldQueue
|
|||
return;
|
||||
}
|
||||
|
||||
$response = Nami::login($this->user->mglnr)->putMember([
|
||||
$response = $this->service->login()->putMember([
|
||||
'firstname' => $this->member->firstname,
|
||||
'lastname' => $this->member->lastname,
|
||||
'joined_at' => $this->member->joined_at,
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
namespace App\Setting;
|
||||
|
||||
use Spatie\LaravelSettings\Settings;
|
||||
use Zoomyboy\LaravelNami\Api;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
|
||||
class NamiSettings extends Settings
|
||||
{
|
||||
|
@ -16,4 +18,9 @@ class NamiSettings extends Settings
|
|||
return 'nami';
|
||||
}
|
||||
|
||||
public function login(): Api
|
||||
{
|
||||
return Nami::login($this->mglnr, $this->password);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b8d2a04d43dd7634ac6e653b26b07b317c5566db
|
||||
Subproject commit 63cef423857c4d87c0e813e761102f518502cd5f
|
|
@ -18,8 +18,7 @@ class DeleteTest extends TestCase
|
|||
|
||||
public function testItDeletesACourse(): void
|
||||
{
|
||||
$this->withoutExceptionHandling();
|
||||
$this->login()->init();
|
||||
$this->login()->loginNami();
|
||||
app(CourseFake::class)->deleteSuccessful(123, 999);
|
||||
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->inNami(999)->for(Course::factory()), 'courses')->createOne();
|
||||
|
||||
|
@ -31,14 +30,13 @@ class DeleteTest extends TestCase
|
|||
|
||||
public function testItReceivesUnknownErrors(): void
|
||||
{
|
||||
$this->login()->init();
|
||||
$this->login()->loginNami();
|
||||
app(CourseFake::class)->deleteFailed(123, 999);
|
||||
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->inNami(999)->for(Course::factory()), 'courses')->createOne();
|
||||
|
||||
$response = $this->delete("/member/{$member->id}/course/{$member->courses->first()->id}");
|
||||
|
||||
$this->assertDatabaseCount('course_members', 1);
|
||||
|
||||
$response->assertSessionHasErrors(['id' => 'Unbekannter Fehler']);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ class UpdateTest extends TestCase
|
|||
*/
|
||||
public function testItValidatesInput(array $payload, array $errors): void
|
||||
{
|
||||
$this->login();
|
||||
$this->login()->loginNami();
|
||||
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->for(Course::factory()), 'courses')->createOne();
|
||||
$newCourse = Course::factory()->inNami(789)->create();
|
||||
|
||||
|
@ -67,13 +67,13 @@ class UpdateTest extends TestCase
|
|||
'organizer' => '::org::',
|
||||
], $payload));
|
||||
|
||||
$response->assertSessionHasErrors($errors);
|
||||
$this->assertErrors($errors, $response);
|
||||
}
|
||||
|
||||
public function testItUpdatesACourse(): void
|
||||
{
|
||||
$this->withoutExceptionHandling();
|
||||
$this->login()->init();
|
||||
$this->login()->loginNami();
|
||||
app(CourseFake::class)->updatesSuccessful(123, 999);
|
||||
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->inNami(999)->for(Course::factory()), 'courses')->createOne();
|
||||
$newCourse = Course::factory()->inNami(789)->create();
|
||||
|
@ -101,9 +101,25 @@ class UpdateTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function testItThrowsErrorWhenLoginIsWrong(): void
|
||||
{
|
||||
$this->login()->failedNami();
|
||||
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->inNami(999)->for(Course::factory()), 'courses')->createOne();
|
||||
$newCourse = Course::factory()->inNami(789)->create();
|
||||
|
||||
$response = $this->patch("/member/{$member->id}/course/{$member->courses->first()->id}", array_merge([
|
||||
'course_id' => $newCourse->id,
|
||||
'completed_at' => '1999-02-03',
|
||||
'event_name' => '::newevent::',
|
||||
'organizer' => '::neworg::',
|
||||
]));
|
||||
|
||||
$this->assertErrors(['nami' => 'NaMi Login fehlgeschlagen.'], $response);
|
||||
}
|
||||
|
||||
public function testItReceivesUnknownErrors(): void
|
||||
{
|
||||
$this->login()->init();
|
||||
$this->login()->loginNami();
|
||||
app(CourseFake::class)->doesntUpdateWithError(123, 999);
|
||||
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->inNami(999)->for(Course::factory()), 'courses')->createOne();
|
||||
$newCourse = Course::factory()->inNami(789)->create();
|
||||
|
|
|
@ -17,6 +17,7 @@ use Illuminate\Support\Facades\Artisan;
|
|||
use Illuminate\Support\Facades\Http;
|
||||
use Tests\TestCase;
|
||||
use Zoomyboy\LaravelNami\Backend\FakeBackend;
|
||||
use Zoomyboy\LaravelNami\Fakes\GroupFake;
|
||||
|
||||
class InitializeTest extends TestCase
|
||||
{
|
||||
|
@ -25,8 +26,8 @@ class InitializeTest extends TestCase
|
|||
|
||||
public function initializeProvider(callable $callback = null): void
|
||||
{
|
||||
app(GroupFake::class)->get([1000 => ['name' => 'testgroup']]);
|
||||
$backend = app(FakeBackend::class)
|
||||
->fakeLogin('123')
|
||||
->addSearch(123, ['entries_vorname' => '::firstname::', 'entries_nachname' => '::lastname::', 'entries_gruppierungId' => 1000])
|
||||
->fakeNationalities([['name' => 'deutsch', 'id' => 291]])
|
||||
->fakeFees(1000, [['name' => 'Family', 'id' => 300]])
|
||||
|
@ -67,9 +68,8 @@ class InitializeTest extends TestCase
|
|||
|
||||
public function testItInitializesAll(): void
|
||||
{
|
||||
$this->withoutExceptionHandling();
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$this->initializeProvider();
|
||||
$this->login();
|
||||
|
||||
$this->post('/initialize');
|
||||
|
||||
|
@ -119,12 +119,12 @@ class InitializeTest extends TestCase
|
|||
]);
|
||||
$this->assertEquals([306], Activity::where('nami_id', 305)->firstOrFail()->subactivities()->pluck('nami_id')->toArray());
|
||||
|
||||
Http::assertSentCount(16);
|
||||
Http::assertSentCount(15);
|
||||
}
|
||||
|
||||
public function testItInitializesFromCommandLine(): void
|
||||
{
|
||||
$this->withoutExceptionHandling();
|
||||
$this->withoutExceptionHandling()->loginNami();
|
||||
$this->initializeProvider();
|
||||
GeneralSettings::fake(['allowed_nami_accounts' => [123]]);
|
||||
|
||||
|
@ -142,7 +142,7 @@ class InitializeTest extends TestCase
|
|||
|
||||
public function testSyncCoursesOfMember(): void
|
||||
{
|
||||
$this->withoutExceptionHandling();
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$this->initializeProvider(function($backend) {
|
||||
$backend->fakeMembers([
|
||||
$this->member(['courses' => [ ['bausteinId' => 506, 'id' => 788, 'veranstalter' => 'KJA', 'vstgName' => 'eventname', 'vstgTag' => '2021-11-12 00:00:00'] ]])
|
||||
|
@ -345,7 +345,7 @@ class InitializeTest extends TestCase
|
|||
if (!$backendCallback) {
|
||||
$backendCallback = function($backend) { return $backend; };
|
||||
}
|
||||
$this->withoutExceptionHandling();
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$this->initializeProvider(function($backend) use ($membership, $backendCallback) {
|
||||
$backend->fakeMembers([
|
||||
$this->member([
|
||||
|
@ -361,7 +361,6 @@ class InitializeTest extends TestCase
|
|||
]);
|
||||
$backendCallback($backend);
|
||||
});
|
||||
$this->login();
|
||||
|
||||
$this->post('/initialize');
|
||||
|
||||
|
@ -370,7 +369,7 @@ class InitializeTest extends TestCase
|
|||
|
||||
public function testItDoesntGetMembersWithNoJoinedAtDate(): void
|
||||
{
|
||||
$this->withoutExceptionHandling();
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$this->initializeProvider(function($backend) {
|
||||
$backend->fakeMembers([$this->member(['eintrittsdatum' => null])]);
|
||||
});
|
||||
|
@ -401,7 +400,7 @@ class InitializeTest extends TestCase
|
|||
*/
|
||||
public function testItInitializesPages(int $num): void
|
||||
{
|
||||
$this->withoutExceptionHandling();
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$this->initializeProvider(function($backend) use ($num) {
|
||||
$members = collect([]);
|
||||
|
||||
|
|
|
@ -30,14 +30,10 @@ class UserLoginTest extends TestCase
|
|||
|
||||
$this->post('/login', [
|
||||
'email' => 'mail@example.com',
|
||||
'provider' => 'database',
|
||||
'password' => 'secret'
|
||||
]);
|
||||
|
||||
$key = session()->get('auth_key');
|
||||
$cache = Cache::get("namiauth-{$key}");
|
||||
$this->assertEquals($user->id, data_get($cache, 'id'));
|
||||
$this->assertTrue(auth()->check());
|
||||
$this->assertAuthenticated();
|
||||
}
|
||||
|
||||
public function testItThrowsExceptionWhenLoginFailed(): void
|
||||
|
@ -47,7 +43,6 @@ class UserLoginTest extends TestCase
|
|||
|
||||
$this->post('/login', [
|
||||
'email' => 'mail@example.com',
|
||||
'provider' => 'database',
|
||||
'password' => 'wrong'
|
||||
])->assertRedirect('/');
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ use Tests\Lib\TestsInertia;
|
|||
use Zoomyboy\LaravelNami\Authentication\Auth;
|
||||
use Zoomyboy\LaravelNami\Backend\FakeBackend;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\NamiUser;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue