adrema/tests/TestCase.php

49 lines
1.1 KiB
PHP
Raw Normal View History

2020-04-10 20:32:12 +02:00
<?php
namespace Tests;
use App\Member\Member;
2021-11-23 01:02:18 +01:00
use App\Setting\GeneralSettings;
2020-04-10 20:32:12 +02:00
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
2021-07-17 15:58:38 +02:00
use Illuminate\Testing\TestResponse;
use Tests\Lib\InertiaMixin;
2021-11-17 22:44:07 +01:00
use Zoomyboy\LaravelNami\Backend\FakeBackend;
use Zoomyboy\LaravelNami\Nami;
2021-06-18 23:36:06 +02:00
use Zoomyboy\LaravelNami\NamiUser;
2020-04-10 20:32:12 +02:00
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
2021-06-13 11:30:31 +02:00
public function setUp(): void {
parent::setUp();
2021-07-17 15:58:38 +02:00
TestResponse::mixin(new InertiaMixin());
2021-06-13 11:30:31 +02:00
}
2022-01-03 01:17:24 +01:00
public function fakeAuthUser() {
2021-11-17 22:44:07 +01:00
app(FakeBackend::class)
->fakeLogin('123')
->addSearch(123, ['entries_vorname' => '::firstname::', 'entries_nachname' => '::lastname::', 'entries_gruppierungId' => 1000]);
2022-01-03 01:17:24 +01:00
}
public function login(): self
{
$this->fakeAuthUser();
2021-11-23 19:15:39 +01:00
auth()->loginNami([
2021-11-17 22:44:07 +01:00
'mglnr' => 123,
'password' => 'secret',
2021-06-18 23:36:06 +02:00
]);
return $this;
}
public function init(): self
{
Member::factory()->defaults()->create();
return $this;
2021-06-18 23:36:06 +02:00
}
2020-04-10 20:32:12 +02:00
}