Skip to content

Commit

Permalink
Remove fake
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvanassche committed Oct 4, 2024
1 parent 7d2dd7a commit 01eea07
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 31 deletions.
30 changes: 0 additions & 30 deletions tests/Fakes/SimpleDataWithMappedOutputName.php

This file was deleted.

26 changes: 25 additions & 1 deletion tests/PartialsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Spatie\LaravelData\Attributes\DataCollectionOf;
use Spatie\LaravelData\Attributes\MapName;
use Spatie\LaravelData\Attributes\MapOutputName;
use Spatie\LaravelData\Data;
use Spatie\LaravelData\DataCollection;
use Spatie\LaravelData\Lazy;
use Spatie\LaravelData\Mappers\SnakeCaseMapper;
use Spatie\LaravelData\Resolvers\RequestQueryStringPartialsResolver;
use Spatie\LaravelData\Support\Partials\Partial;
use Spatie\LaravelData\Support\Partials\PartialsCollection;
Expand All @@ -23,7 +26,6 @@
use Spatie\LaravelData\Tests\Fakes\PartialClassConditionalData;
use Spatie\LaravelData\Tests\Fakes\SimpleChildDataWithMappedOutputName;
use Spatie\LaravelData\Tests\Fakes\SimpleData;
use Spatie\LaravelData\Tests\Fakes\SimpleDataWithMappedOutputName;
use Spatie\LaravelData\Tests\Fakes\UlarData;

/**
Expand Down Expand Up @@ -1578,6 +1580,28 @@ public function __construct()
});

it('handles parsing except from request with mapped output name', function () {
#[MapName(SnakeCaseMapper::class)]
class SimpleDataWithMappedOutputName extends Data
{
public function __construct(
public int $id,
#[MapOutputName('paid_amount')]
public float $amount,
public string $anyString,
public SimpleChildDataWithMappedOutputName $child
) {
}

public static function allowedRequestExcept(): ?array
{
return [
'amount',
'anyString',
'child',
];
}
}

$dataclass = SimpleDataWithMappedOutputName::from([
'id' => 1,
'amount' => 1000,
Expand Down

0 comments on commit 01eea07

Please sign in to comment.