Skip to content

Commit c4a2cd6

Browse files
committed
test: extract preamble for FactoryTest
1 parent 7198bb4 commit c4a2cd6

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

tests/acceptance/FactoryTypes.feature

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,31 @@ Feature: factory()
1515
</plugins>
1616
</psalm>
1717
"""
18-
19-
Scenario:
20-
Given I have the following code
18+
And I have the following code preamble
2119
"""
2220
<?php declare(strict_types=1);
2321
22+
use Illuminate\Database\Eloquent\Collection;
23+
use Illuminate\Database\Eloquent\FactoryBuilder;
2424
use Tests\Psalm\LaravelPlugin\Models\User;
25+
"""
2526

27+
Scenario:
28+
Given I have the following code
29+
"""
2630
class FactoryTest {
2731
/**
28-
* @return \Illuminate\Database\Eloquent\FactoryBuilder<User, 1>
29-
*/
30-
public function getFactory(): \Illuminate\Database\Eloquent\FactoryBuilder
32+
* @return FactoryBuilder<User, 1>
33+
*/
34+
public function getFactory(): FactoryBuilder
3135
{
3236
return factory(User::class);
3337
}
3438
3539
/**
36-
* @return \Illuminate\Database\Eloquent\FactoryBuilder<User, 2>
37-
*/
38-
public function getFactoryForTwo(): \Illuminate\Database\Eloquent\FactoryBuilder
40+
* @return FactoryBuilder<User, 2>
41+
*/
42+
public function getFactoryForTwo(): FactoryBuilder
3943
{
4044
return factory(User::class, 2);
4145
}
@@ -51,17 +55,17 @@ Feature: factory()
5155
}
5256
5357
/**
54-
* @return \Illuminate\Database\Eloquent\Collection<User>
55-
*/
56-
public function createUsers(): \Illuminate\Database\Eloquent\Collection
58+
* @return Collection<User>
59+
*/
60+
public function createUsers(): Collection
5761
{
5862
return factory(User::class, 2)->create();
5963
}
6064
6165
/**
62-
* @return \Illuminate\Database\Eloquent\Collection<User>
63-
*/
64-
public function createUsersWithNameAttribute(): \Illuminate\Database\Eloquent\Collection
66+
* @return Collection<User>
67+
*/
68+
public function createUsersWithNameAttribute(): Collection
6569
{
6670
return factory(User::class, 'new name', 2)->create();
6771
}

0 commit comments

Comments
 (0)