Skip to content

Commit

Permalink
Remove tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvanassche committed Apr 4, 2024
1 parent 76f5686 commit 78d14c1
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 53 deletions.
1 change: 0 additions & 1 deletion src/Transformers/ArrayableTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class ArrayableTransformer implements Transformer
{
public function transform(DataProperty $property, mixed $value, TransformationContext $context): array
{
/** @var \Illuminate\Contracts\Support\Arrayable $value */
return $value->toArray();
}
}
51 changes: 0 additions & 51 deletions tests/DataTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php

use Illuminate\Contracts\Support\Responsable;
use Illuminate\Support\Collection;
use Illuminate\Validation\ValidationException;
use Spatie\LaravelData\Attributes\DataCollectionOf;
use Spatie\LaravelData\Concerns\AppendableData;
use Spatie\LaravelData\Concerns\BaseData;
use Spatie\LaravelData\Concerns\ContextableData;
Expand All @@ -22,11 +20,8 @@
use Spatie\LaravelData\Contracts\ValidateableData as ValidateableDataContract;
use Spatie\LaravelData\Contracts\WrappableData as WrappableDataContract;
use Spatie\LaravelData\Data;
use Spatie\LaravelData\DataCollection;
use Spatie\LaravelData\Dto;
use Spatie\LaravelData\Resource;
use Spatie\LaravelData\Tests\Fakes\DummyDto;
use Spatie\LaravelData\Tests\Fakes\MultiLazyData;
use Spatie\LaravelData\Tests\Fakes\SimpleDto;
use Spatie\LaravelData\Tests\Fakes\SimpleResource;

Expand Down Expand Up @@ -83,49 +78,3 @@ public static function fromString(string $string): static
'validate',
]);
});

// TODO: move

it('doesnt throw when nested collection lazy is not a data collection', function () {
$dataClass = new class () extends Data {
public Collection $nested;
};

$data = $dataClass::collect([
[
'nested' => [DummyDto::rick()],
],
], DataCollection::class);


expect($data->include('nested.artist')->toArray())->toMatchArray([
['nested' => [DummyDto::rick()]],
]);
});

it('can conditionally include nested collection', function () {
class TestDataCollectionWithNested extends Data
{
#[DataCollectionOf(MultiLazyData::class)]
public Collection $nested;
}

$data = TestDataCollectionWithNested::collect([
[
'nested' => [DummyDto::rick()],
], [
'nested' => [DummyDto::bon()],
],
], DataCollection::class);


expect($data->toArray())->toMatchArray([
['nested' => [[]]],
['nested' => [[]]],
]);

expect($data->include('nested.{artist,year}')->toArray())->toMatchArray([
['nested' => [['artist' => DummyDto::rick()->artist, 'year' => DummyDto::rick()->year]]],
['nested' => [['artist' => DummyDto::bon()->artist, 'year' => DummyDto::bon()->year]]],
]);
});
1 change: 0 additions & 1 deletion tests/PartialsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,6 @@ public function __construct(
]);
});


it('can fetch lazy properties like regular properties within PHP', function () {

$dataClass = new class () extends Data {
Expand Down

0 comments on commit 78d14c1

Please sign in to comment.