Lint tests
This commit is contained in:
parent
ea57e1c552
commit
5243b7341d
|
@ -8,6 +8,7 @@ use Spatie\LaravelData\Attributes\WithCast;
|
||||||
use Spatie\LaravelData\Data;
|
use Spatie\LaravelData\Data;
|
||||||
use Zoomyboy\LaravelNami\Casters\CarbonCast;
|
use Zoomyboy\LaravelNami\Casters\CarbonCast;
|
||||||
use Zoomyboy\LaravelNami\Casters\StringCast;
|
use Zoomyboy\LaravelNami\Casters\StringCast;
|
||||||
|
use Zoomyboy\LaravelNami\Tests\Factories\MemberRequestFactory;
|
||||||
|
|
||||||
class Member extends Data
|
class Member extends Data
|
||||||
{
|
{
|
||||||
|
@ -134,4 +135,9 @@ class Member extends Data
|
||||||
'zeitschriftenversand' => $this->sendNewspaper,
|
'zeitschriftenversand' => $this->sendNewspaper,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function factory(): MemberRequestFactory
|
||||||
|
{
|
||||||
|
return MemberRequestFactory::new();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,18 +5,40 @@ namespace Zoomyboy\LaravelNami\Tests\Factories;
|
||||||
use GuzzleHttp\Promise\FulfilledPromise;
|
use GuzzleHttp\Promise\FulfilledPromise;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Worksome\RequestFactories\RequestFactory;
|
use Worksome\RequestFactories\RequestFactory;
|
||||||
|
use Zoomyboy\LaravelNami\Data\Member;
|
||||||
|
|
||||||
class MemberRequestFactory extends RequestFactory
|
class MemberRequestFactory extends RequestFactory
|
||||||
{
|
{
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'vorname' => $this->faker->firstName,
|
'firstname' => $this->faker->firstName,
|
||||||
'nachname' => $this->faker->lastName,
|
'lastname' => $this->faker->lastName,
|
||||||
'nickname' => $this->faker->firstName,
|
'nickname' => $this->faker->firstName,
|
||||||
|
'groupId' => $this->faker->numberBetween(100, 200),
|
||||||
|
'genderId' => $this->faker->numberBetween(100, 200),
|
||||||
|
'confessionId' => $this->faker->numberBetween(100, 200),
|
||||||
|
'joinedAt' => $this->faker->dateTime()->format('Y-m-d').' 00:00:00',
|
||||||
|
'birthday' => $this->faker->dateTime()->format('Y-m-d').' 00:00:00',
|
||||||
|
'email' => $this->faker->safeEmail(),
|
||||||
|
'countryId' => $this->faker->numberBetween(100, 200),
|
||||||
|
'keepdata' => $this->faker->boolean(),
|
||||||
|
'sendNewspaper' => $this->faker->boolean(),
|
||||||
|
'regionId' => $this->faker->numberBetween(100, 200),
|
||||||
|
'nationalityId' => $this->faker->numberBetween(100, 200),
|
||||||
|
'beitragsartId' => $this->faker->numberBetween(100, 200),
|
||||||
|
'id' => null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function inNami(int $groupId, int $namiId): self
|
||||||
|
{
|
||||||
|
return $this->state([
|
||||||
|
'id' => $namiId,
|
||||||
|
'groupId' => $groupId,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function withEmptyNames(): self
|
public function withEmptyNames(): self
|
||||||
{
|
{
|
||||||
return $this->state([
|
return $this->state([
|
||||||
|
@ -36,4 +58,12 @@ class MemberRequestFactory extends RequestFactory
|
||||||
'responseType' => null,
|
'responseType' => null,
|
||||||
]), 200);
|
]), 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $attributes
|
||||||
|
*/
|
||||||
|
public function toMember(array $attributes = []): Member
|
||||||
|
{
|
||||||
|
return Member::from($this->create($attributes));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ class PutMemberTest extends TestCase
|
||||||
public function testPushASingleMember(): void
|
public function testPushASingleMember(): void
|
||||||
{
|
{
|
||||||
app(MemberFake::class)->createsSuccessfully(103, 16);
|
app(MemberFake::class)->createsSuccessfully(103, 16);
|
||||||
$member = Member::from([
|
$member = Member::factory()->toMember([
|
||||||
'firstname' => 'Max',
|
'firstname' => 'Max',
|
||||||
'lastname' => 'Nach1',
|
'lastname' => 'Nach1',
|
||||||
'nickname' => 'spitz1',
|
'nickname' => 'spitz1',
|
||||||
|
@ -55,10 +55,8 @@ class PutMemberTest extends TestCase
|
||||||
{
|
{
|
||||||
app(MemberFake::class)
|
app(MemberFake::class)
|
||||||
->updatesSuccessfully(103, 16)
|
->updatesSuccessfully(103, 16)
|
||||||
->shows(103, 16, [
|
->shows(103, 16);
|
||||||
'foreign' => 'fff',
|
$member = Member::factory()->toMember([
|
||||||
]);
|
|
||||||
$member = Member::from([
|
|
||||||
'firstname' => 'Max',
|
'firstname' => 'Max',
|
||||||
'lastname' => 'Nach1',
|
'lastname' => 'Nach1',
|
||||||
'nickname' => 'spitz1',
|
'nickname' => 'spitz1',
|
||||||
|
@ -94,6 +92,23 @@ class PutMemberTest extends TestCase
|
||||||
'zeitschriftenversand' => false,
|
'zeitschriftenversand' => false,
|
||||||
'regionId' => 11,
|
'regionId' => 11,
|
||||||
'staatsangehoerigkeitId' => 12,
|
'staatsangehoerigkeitId' => 12,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testItMergesKontoverbindung(): void
|
||||||
|
{
|
||||||
|
app(MemberFake::class)
|
||||||
|
->updatesSuccessfully(103, 16)
|
||||||
|
->shows(103, 16, [
|
||||||
|
'foreign' => 'fff',
|
||||||
|
'kontoverbindung' => ['a' => 'b'],
|
||||||
|
]);
|
||||||
|
$response = $this->login()->putMember(Member::factory()->inNami(103, 16)->toMember());
|
||||||
|
|
||||||
|
$this->assertEquals(16, $response);
|
||||||
|
|
||||||
|
app(MemberFake::class)->assertUpdated(103, 16, [
|
||||||
|
'kontoverbindung' => '{"a":"b"}',
|
||||||
'foreign' => 'fff',
|
'foreign' => 'fff',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue