forked from barryvdh/laravel-ide-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request barryvdh#1506 from olexoliinyk0/test/case-of-1505
test: case for the issue barryvdh#1505;
- Loading branch information
Showing
3 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
tests/Console/ModelsCommand/ArrayCastsWithComment/Models/ArrayCastsWithComment.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\ArrayCastsWithComment\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* @property array<int, string>|null $cast_to_array -- These three should not be duplicated | ||
* @property array<int, string> $cast_to_json some-description | ||
* @property \Illuminate\Support\Collection<int, string> $cast_to_collection some-description | ||
* | ||
* @property array|null $cast_to_encrypted_array -- These three are OK (no types) | ||
* @property array $cast_to_encrypted_json some-description | ||
* @property \Illuminate\Support\Collection $cast_to_encrypted_collection some-description | ||
* | ||
* @property string $cast_to_string -- The next three are OK (no description), this not included | ||
* | ||
* @property array<int, string>|null $cast_to_immutable_date | ||
* @property array<int, string> $cast_to_immutable_date_serialization | ||
* @property \Illuminate\Support\Collection<int, string> $cast_to_immutable_custom_datetime | ||
*/ | ||
class ArrayCastsWithComment extends Model | ||
{ | ||
protected $table = 'simple_casts'; | ||
|
||
protected $casts = [ | ||
'cast_to_array' => 'array', | ||
'cast_to_json' => 'json', | ||
'cast_to_collection' => 'collection', | ||
|
||
'cast_to_encrypted_array' => 'array', | ||
'cast_to_encrypted_json' => 'json', | ||
'cast_to_encrypted_collection' => 'collection', | ||
|
||
'cast_to_string' => 'string', | ||
|
||
'cast_to_immutable_date' => 'array', | ||
'cast_to_immutable_date_serialization' => 'json', | ||
'cast_to_immutable_custom_datetime' => 'collection', | ||
]; | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/Console/ModelsCommand/ArrayCastsWithComment/Test.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\ArrayCastsWithComment; | ||
|
||
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand; | ||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand; | ||
|
||
class Test extends AbstractModelsCommand | ||
{ | ||
/** | ||
* The generated snapshot is wrong until | ||
* https://github.com/barryvdh/laravel-ide-helper/issues/1505 is fixed | ||
*/ | ||
public function test(): void | ||
{ | ||
$command = $this->app->make(ModelsCommand::class); | ||
|
||
$tester = $this->runCommand($command, [ | ||
'--write' => true, | ||
]); | ||
|
||
$this->assertSame(0, $tester->getStatusCode()); | ||
$this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay()); | ||
$this->assertMatchesMockedSnapshot(); | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
tests/Console/ModelsCommand/ArrayCastsWithComment/__snapshots__/Test__test__1.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\ArrayCastsWithComment\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\ArrayCastsWithComment\Models\ArrayCastsWithComment | ||
* | ||
* @property array<int, string>|null $cast_to_array -- These three should not be duplicated | ||
* @property array<int, string> $cast_to_json some-description | ||
* @property \Illuminate\Support\Collection<int, string> $cast_to_collection some-description | ||
* @property array|null $cast_to_encrypted_array -- These three are OK (no types) | ||
* @property array $cast_to_encrypted_json some-description | ||
* @property \Illuminate\Support\Collection $cast_to_encrypted_collection some-description | ||
* @property string $cast_to_string -- The next three are OK (no description), this not included | ||
* @property array<int, string>|null $cast_to_immutable_date | ||
* @property array<int, string> $cast_to_immutable_date_serialization | ||
* @property \Illuminate\Support\Collection<int, string> $cast_to_immutable_custom_datetime | ||
* @property string $cast_to_int | ||
* @property string $cast_to_integer | ||
* @property string $cast_to_real | ||
* @property string $cast_to_float | ||
* @property string $cast_to_double | ||
* @property string $cast_to_decimal | ||
* @property string $cast_to_bool | ||
* @property string $cast_to_boolean | ||
* @property string $cast_to_object | ||
* @property array $cast_to_array | ||
* @property array $cast_to_json | ||
* @property \Illuminate\Support\Collection $cast_to_collection | ||
* @property string $cast_to_date | ||
* @property string $cast_to_datetime | ||
* @property string $cast_to_date_serialization | ||
* @property string $cast_to_datetime_serialization | ||
* @property string $cast_to_custom_datetime | ||
* @property string $cast_to_immutable_datetime | ||
* @property string $cast_to_immutable_datetime_serialization | ||
* @property string $cast_to_timestamp | ||
* @property string $cast_to_encrypted | ||
* @property string $cast_to_encrypted_object | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment newModelQuery() | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment newQuery() | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment query() | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToArray($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToBool($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToBoolean($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToCollection($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToCustomDatetime($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDate($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDateSerialization($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDatetime($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDatetimeSerialization($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDecimal($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDouble($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToEncrypted($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToEncryptedArray($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToEncryptedCollection($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToEncryptedJson($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToEncryptedObject($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToFloat($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToImmutableCustomDatetime($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToImmutableDate($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToImmutableDateSerialization($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToImmutableDatetime($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToImmutableDatetimeSerialization($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToInt($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToInteger($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToJson($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToObject($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToReal($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToString($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToTimestamp($value) | ||
* @mixin \Eloquent | ||
*/ | ||
class ArrayCastsWithComment extends Model | ||
{ | ||
protected $table = 'simple_casts'; | ||
|
||
protected $casts = [ | ||
'cast_to_array' => 'array', | ||
'cast_to_json' => 'json', | ||
'cast_to_collection' => 'collection', | ||
|
||
'cast_to_encrypted_array' => 'array', | ||
'cast_to_encrypted_json' => 'json', | ||
'cast_to_encrypted_collection' => 'collection', | ||
|
||
'cast_to_string' => 'string', | ||
|
||
'cast_to_immutable_date' => 'array', | ||
'cast_to_immutable_date_serialization' => 'json', | ||
'cast_to_immutable_custom_datetime' => 'collection', | ||
]; | ||
} |