Update casters
This commit is contained in:
parent
aa862f1264
commit
7c876d75c9
|
@ -17,9 +17,6 @@ class CarbonCast implements Cast
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string, mixed> $context
|
|
||||||
*/
|
|
||||||
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): DateTimeInterface|Uncastable|null
|
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): DateTimeInterface|Uncastable|null
|
||||||
{
|
{
|
||||||
if ($property->type->isNullable && !$value) {
|
if ($property->type->isNullable && !$value) {
|
||||||
|
@ -27,7 +24,7 @@ class CarbonCast implements Cast
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return (new DateTimeInterfaceCast($this->format, null, null, null))->cast($property, $value, $context);
|
return (new DateTimeInterfaceCast($this->format, null, null, null))->cast($property, $value, $properties, $context);
|
||||||
} catch (CannotCastDate $e) {
|
} catch (CannotCastDate $e) {
|
||||||
if (!$property->type->isNullable) {
|
if (!$property->type->isNullable) {
|
||||||
throw $e;
|
throw $e;
|
||||||
|
|
|
@ -12,9 +12,6 @@ class GroupCast implements Cast
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string, mixed> $context
|
|
||||||
*/
|
|
||||||
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): ?string
|
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): ?string
|
||||||
{
|
{
|
||||||
if ($property->type->isNullable && !$value) {
|
if ($property->type->isNullable && !$value) {
|
||||||
|
|
|
@ -15,9 +15,6 @@ class NullValueCast implements Cast
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string, mixed> $context
|
|
||||||
*/
|
|
||||||
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): DateTimeInterface|Uncastable|null|int
|
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): DateTimeInterface|Uncastable|null|int
|
||||||
{
|
{
|
||||||
if ($this->id === $value) {
|
if ($this->id === $value) {
|
||||||
|
|
|
@ -12,9 +12,6 @@ class StringCast implements Cast
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string, mixed> $context
|
|
||||||
*/
|
|
||||||
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): ?string
|
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): ?string
|
||||||
{
|
{
|
||||||
if ($property->type->isNullable && !$value) {
|
if ($property->type->isNullable && !$value) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ class PutMemberTest extends TestCase
|
||||||
public function testPushASingleMember(): void
|
public function testPushASingleMember(): void
|
||||||
{
|
{
|
||||||
app(MemberFake::class)->stores(103, 16);
|
app(MemberFake::class)->stores(103, 16);
|
||||||
$member = Member::factory()->toMember([
|
$member = Member::toFactory()->toMember([
|
||||||
'firstname' => 'Max',
|
'firstname' => 'Max',
|
||||||
'lastname' => 'Nach1',
|
'lastname' => 'Nach1',
|
||||||
'nickname' => 'spitz1',
|
'nickname' => 'spitz1',
|
||||||
|
@ -79,7 +79,7 @@ class PutMemberTest extends TestCase
|
||||||
app(MemberFake::class)
|
app(MemberFake::class)
|
||||||
->updatesSuccessfully(103, 16)
|
->updatesSuccessfully(103, 16)
|
||||||
->shows(103, 16);
|
->shows(103, 16);
|
||||||
$member = Member::factory()->toMember([
|
$member = Member::toFactory()->toMember([
|
||||||
'firstname' => 'Max',
|
'firstname' => 'Max',
|
||||||
'lastname' => 'Nach1',
|
'lastname' => 'Nach1',
|
||||||
'nickname' => 'spitz1',
|
'nickname' => 'spitz1',
|
||||||
|
@ -123,7 +123,7 @@ class PutMemberTest extends TestCase
|
||||||
app(MemberFake::class)
|
app(MemberFake::class)
|
||||||
->updatesSuccessfully(103, 16)
|
->updatesSuccessfully(103, 16)
|
||||||
->shows(103, 16);
|
->shows(103, 16);
|
||||||
$member = Member::factory()->toMember([
|
$member = Member::toFactory()->toMember([
|
||||||
'email' => null,
|
'email' => null,
|
||||||
'groupId' => 103,
|
'groupId' => 103,
|
||||||
'id' => 16,
|
'id' => 16,
|
||||||
|
@ -145,7 +145,7 @@ class PutMemberTest extends TestCase
|
||||||
'foreign' => 'fff',
|
'foreign' => 'fff',
|
||||||
'kontoverbindung' => ['a' => 'b'],
|
'kontoverbindung' => ['a' => 'b'],
|
||||||
]);
|
]);
|
||||||
$response = $this->login()->putMember(Member::factory()->inNami(103, 16)->toMember());
|
$response = $this->login()->putMember(Member::toFactory()->inNami(103, 16)->toMember());
|
||||||
|
|
||||||
$this->assertEquals(16, $response);
|
$this->assertEquals(16, $response);
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ class PutMemberTest extends TestCase
|
||||||
'foreign' => 'fff',
|
'foreign' => 'fff',
|
||||||
'kontoverbindung' => ['a' => 'b'],
|
'kontoverbindung' => ['a' => 'b'],
|
||||||
]);
|
]);
|
||||||
$response = $this->login()->putMember(Member::factory()->inNami(103, 16)->toMember(['genderId' => null, 'regionId' => null]));
|
$response = $this->login()->putMember(Member::toFactory()->inNami(103, 16)->toMember(['genderId' => null, 'regionId' => null]));
|
||||||
|
|
||||||
$this->assertEquals(16, $response);
|
$this->assertEquals(16, $response);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue