Skip to content

Commit 416e0ab

Browse files
authored
Merge pull request #1506 from olexoliinyk0/test/case-of-1505
test: case for the issue #1505;
2 parents 726e595 + 9374952 commit 416e0ab

File tree

3 files changed

+168
-0
lines changed

3 files changed

+168
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\ArrayCastsWithComment\Models;
6+
7+
use Illuminate\Database\Eloquent\Model;
8+
9+
/**
10+
* @property array<int, string>|null $cast_to_array -- These three should not be duplicated
11+
* @property array<int, string> $cast_to_json some-description
12+
* @property \Illuminate\Support\Collection<int, string> $cast_to_collection some-description
13+
*
14+
* @property array|null $cast_to_encrypted_array -- These three are OK (no types)
15+
* @property array $cast_to_encrypted_json some-description
16+
* @property \Illuminate\Support\Collection $cast_to_encrypted_collection some-description
17+
*
18+
* @property string $cast_to_string -- The next three are OK (no description), this not included
19+
*
20+
* @property array<int, string>|null $cast_to_immutable_date
21+
* @property array<int, string> $cast_to_immutable_date_serialization
22+
* @property \Illuminate\Support\Collection<int, string> $cast_to_immutable_custom_datetime
23+
*/
24+
class ArrayCastsWithComment extends Model
25+
{
26+
protected $table = 'simple_casts';
27+
28+
protected $casts = [
29+
'cast_to_array' => 'array',
30+
'cast_to_json' => 'json',
31+
'cast_to_collection' => 'collection',
32+
33+
'cast_to_encrypted_array' => 'array',
34+
'cast_to_encrypted_json' => 'json',
35+
'cast_to_encrypted_collection' => 'collection',
36+
37+
'cast_to_string' => 'string',
38+
39+
'cast_to_immutable_date' => 'array',
40+
'cast_to_immutable_date_serialization' => 'json',
41+
'cast_to_immutable_custom_datetime' => 'collection',
42+
];
43+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\ArrayCastsWithComment;
6+
7+
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
8+
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
9+
10+
class Test extends AbstractModelsCommand
11+
{
12+
/**
13+
* The generated snapshot is wrong until
14+
* https://github.com/barryvdh/laravel-ide-helper/issues/1505 is fixed
15+
*/
16+
public function test(): void
17+
{
18+
$command = $this->app->make(ModelsCommand::class);
19+
20+
$tester = $this->runCommand($command, [
21+
'--write' => true,
22+
]);
23+
24+
$this->assertSame(0, $tester->getStatusCode());
25+
$this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay());
26+
$this->assertMatchesMockedSnapshot();
27+
}
28+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\ArrayCastsWithComment\Models;
6+
7+
use Illuminate\Database\Eloquent\Model;
8+
9+
/**
10+
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\ArrayCastsWithComment\Models\ArrayCastsWithComment
11+
*
12+
* @property array<int, string>|null $cast_to_array -- These three should not be duplicated
13+
* @property array<int, string> $cast_to_json some-description
14+
* @property \Illuminate\Support\Collection<int, string> $cast_to_collection some-description
15+
* @property array|null $cast_to_encrypted_array -- These three are OK (no types)
16+
* @property array $cast_to_encrypted_json some-description
17+
* @property \Illuminate\Support\Collection $cast_to_encrypted_collection some-description
18+
* @property string $cast_to_string -- The next three are OK (no description), this not included
19+
* @property array<int, string>|null $cast_to_immutable_date
20+
* @property array<int, string> $cast_to_immutable_date_serialization
21+
* @property \Illuminate\Support\Collection<int, string> $cast_to_immutable_custom_datetime
22+
* @property string $cast_to_int
23+
* @property string $cast_to_integer
24+
* @property string $cast_to_real
25+
* @property string $cast_to_float
26+
* @property string $cast_to_double
27+
* @property string $cast_to_decimal
28+
* @property string $cast_to_bool
29+
* @property string $cast_to_boolean
30+
* @property string $cast_to_object
31+
* @property array $cast_to_array
32+
* @property array $cast_to_json
33+
* @property \Illuminate\Support\Collection $cast_to_collection
34+
* @property string $cast_to_date
35+
* @property string $cast_to_datetime
36+
* @property string $cast_to_date_serialization
37+
* @property string $cast_to_datetime_serialization
38+
* @property string $cast_to_custom_datetime
39+
* @property string $cast_to_immutable_datetime
40+
* @property string $cast_to_immutable_datetime_serialization
41+
* @property string $cast_to_timestamp
42+
* @property string $cast_to_encrypted
43+
* @property string $cast_to_encrypted_object
44+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment newModelQuery()
45+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment newQuery()
46+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment query()
47+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToArray($value)
48+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToBool($value)
49+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToBoolean($value)
50+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToCollection($value)
51+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToCustomDatetime($value)
52+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDate($value)
53+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDateSerialization($value)
54+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDatetime($value)
55+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDatetimeSerialization($value)
56+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDecimal($value)
57+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDouble($value)
58+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToEncrypted($value)
59+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToEncryptedArray($value)
60+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToEncryptedCollection($value)
61+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToEncryptedJson($value)
62+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToEncryptedObject($value)
63+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToFloat($value)
64+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToImmutableCustomDatetime($value)
65+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToImmutableDate($value)
66+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToImmutableDateSerialization($value)
67+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToImmutableDatetime($value)
68+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToImmutableDatetimeSerialization($value)
69+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToInt($value)
70+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToInteger($value)
71+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToJson($value)
72+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToObject($value)
73+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToReal($value)
74+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToString($value)
75+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToTimestamp($value)
76+
* @mixin \Eloquent
77+
*/
78+
class ArrayCastsWithComment extends Model
79+
{
80+
protected $table = 'simple_casts';
81+
82+
protected $casts = [
83+
'cast_to_array' => 'array',
84+
'cast_to_json' => 'json',
85+
'cast_to_collection' => 'collection',
86+
87+
'cast_to_encrypted_array' => 'array',
88+
'cast_to_encrypted_json' => 'json',
89+
'cast_to_encrypted_collection' => 'collection',
90+
91+
'cast_to_string' => 'string',
92+
93+
'cast_to_immutable_date' => 'array',
94+
'cast_to_immutable_date_serialization' => 'json',
95+
'cast_to_immutable_custom_datetime' => 'collection',
96+
];
97+
}

0 commit comments

Comments
 (0)