From 7d2ea97f25a612f32efa6893c1c3b1309158bdda Mon Sep 17 00:00:00 2001 From: uno-sw Date: Fri, 2 Aug 2024 13:21:45 +0900 Subject: [PATCH] Update test --- .../Collections/AdvancedCastCollection.php | 11 +++++ .../AdvancedCasts/Enums/AdvancedCastEnum.php | 12 ++++++ .../AdvancedCasts/Models/AdvancedCast.php | 41 ++++++++++-------- .../__snapshots__/Test__test__1.php | 43 +++++++++++-------- 4 files changed, 73 insertions(+), 34 deletions(-) create mode 100644 tests/Console/ModelsCommand/AdvancedCasts/Collections/AdvancedCastCollection.php create mode 100644 tests/Console/ModelsCommand/AdvancedCasts/Enums/AdvancedCastEnum.php diff --git a/tests/Console/ModelsCommand/AdvancedCasts/Collections/AdvancedCastCollection.php b/tests/Console/ModelsCommand/AdvancedCasts/Collections/AdvancedCastCollection.php new file mode 100644 index 000000000..0ce995ed5 --- /dev/null +++ b/tests/Console/ModelsCommand/AdvancedCasts/Collections/AdvancedCastCollection.php @@ -0,0 +1,11 @@ + 'date:Y-m-d', - 'cast_to_datetime_serialization' => 'datetime:Y-m-d H:i:s', - 'cast_to_custom_datetime' => 'custom_datetime:Y-m-d H:i:s', - 'cast_to_immutable_date' => 'immutable_date', - 'cast_to_immutable_custom_datetime' => 'immutable_custom_datetime:Y-m-d H:i:s', - 'cast_to_immutable_datetime' => 'immutable_datetime', - 'cast_to_timestamp' => 'timestamp', - 'cast_to_encrypted' => 'encrypted', - 'cast_to_encrypted_array' => 'encrypted:array', - 'cast_to_encrypted_collection' => 'encrypted:collection', - 'cast_to_encrypted_json' => 'encrypted:json', - 'cast_to_encrypted_object' => 'encrypted:object', - 'cast_to_as_collection' => AsCollection::class, - 'cast_to_as_enum_collection' => AsEnumCollection::class, - 'cast_to_as_array_object' => AsArrayObject::class, - ]; + protected function casts(): array + { + return [ + 'cast_to_date_serialization' => 'date:Y-m-d', + 'cast_to_datetime_serialization' => 'datetime:Y-m-d H:i:s', + 'cast_to_custom_datetime' => 'custom_datetime:Y-m-d H:i:s', + 'cast_to_immutable_date' => 'immutable_date', + 'cast_to_immutable_custom_datetime' => 'immutable_custom_datetime:Y-m-d H:i:s', + 'cast_to_immutable_datetime' => 'immutable_datetime', + 'cast_to_timestamp' => 'timestamp', + 'cast_to_encrypted' => 'encrypted', + 'cast_to_encrypted_array' => 'encrypted:array', + 'cast_to_encrypted_collection' => 'encrypted:collection', + 'cast_to_encrypted_json' => 'encrypted:json', + 'cast_to_encrypted_object' => 'encrypted:object', + 'cast_to_as_collection' => AsCollection::class, + 'cast_to_as_collection_using' => AsCollection::using(AdvancedCastCollection::class), + 'cast_to_as_enum_collection' => AsEnumCollection::class, + 'cast_to_as_enum_collection_of' => AsEnumCollection::of(AdvancedCastEnum::class), + 'cast_to_as_array_object' => AsArrayObject::class, + ]; + } } diff --git a/tests/Console/ModelsCommand/AdvancedCasts/__snapshots__/Test__test__1.php b/tests/Console/ModelsCommand/AdvancedCasts/__snapshots__/Test__test__1.php index 9c9972abd..4613c7af5 100644 --- a/tests/Console/ModelsCommand/AdvancedCasts/__snapshots__/Test__test__1.php +++ b/tests/Console/ModelsCommand/AdvancedCasts/__snapshots__/Test__test__1.php @@ -4,6 +4,8 @@ namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Models; +use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Collections\AdvancedCastCollection; +use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Enums\AdvancedCastEnum; use Illuminate\Database\Eloquent\Casts\AsArrayObject; use Illuminate\Database\Eloquent\Casts\AsCollection; use Illuminate\Database\Eloquent\Casts\AsEnumCollection; @@ -27,6 +29,8 @@ * @property \Illuminate\Support\Collection $cast_to_as_collection * @property \Illuminate\Support\Collection $cast_to_as_enum_collection * @property \ArrayObject $cast_to_as_array_object + * @property AdvancedCastCollection $cast_to_as_collection_using + * @property \Illuminate\Support\Collection $cast_to_as_enum_collection_of * @method static \Illuminate\Database\Eloquent\Builder|AdvancedCast newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|AdvancedCast newQuery() * @method static \Illuminate\Database\Eloquent\Builder|AdvancedCast query() @@ -49,21 +53,26 @@ */ class AdvancedCast extends Model { - protected $casts = [ - 'cast_to_date_serialization' => 'date:Y-m-d', - 'cast_to_datetime_serialization' => 'datetime:Y-m-d H:i:s', - 'cast_to_custom_datetime' => 'custom_datetime:Y-m-d H:i:s', - 'cast_to_immutable_date' => 'immutable_date', - 'cast_to_immutable_custom_datetime' => 'immutable_custom_datetime:Y-m-d H:i:s', - 'cast_to_immutable_datetime' => 'immutable_datetime', - 'cast_to_timestamp' => 'timestamp', - 'cast_to_encrypted' => 'encrypted', - 'cast_to_encrypted_array' => 'encrypted:array', - 'cast_to_encrypted_collection' => 'encrypted:collection', - 'cast_to_encrypted_json' => 'encrypted:json', - 'cast_to_encrypted_object' => 'encrypted:object', - 'cast_to_as_collection' => AsCollection::class, - 'cast_to_as_enum_collection' => AsEnumCollection::class, - 'cast_to_as_array_object' => AsArrayObject::class, - ]; + protected function casts(): array + { + return [ + 'cast_to_date_serialization' => 'date:Y-m-d', + 'cast_to_datetime_serialization' => 'datetime:Y-m-d H:i:s', + 'cast_to_custom_datetime' => 'custom_datetime:Y-m-d H:i:s', + 'cast_to_immutable_date' => 'immutable_date', + 'cast_to_immutable_custom_datetime' => 'immutable_custom_datetime:Y-m-d H:i:s', + 'cast_to_immutable_datetime' => 'immutable_datetime', + 'cast_to_timestamp' => 'timestamp', + 'cast_to_encrypted' => 'encrypted', + 'cast_to_encrypted_array' => 'encrypted:array', + 'cast_to_encrypted_collection' => 'encrypted:collection', + 'cast_to_encrypted_json' => 'encrypted:json', + 'cast_to_encrypted_object' => 'encrypted:object', + 'cast_to_as_collection' => AsCollection::class, + 'cast_to_as_collection_using' => AsCollection::using(AdvancedCastCollection::class), + 'cast_to_as_enum_collection' => AsEnumCollection::class, + 'cast_to_as_enum_collection_of' => AsEnumCollection::of(AdvancedCastEnum::class), + 'cast_to_as_array_object' => AsArrayObject::class, + ]; + } }