fix failing tests

This commit is contained in:
Andrew Nagy 2022-04-07 19:58:59 +00:00
parent 3ddc65b2ae
commit a0d98b6729
4 changed files with 2 additions and 108 deletions

View File

@ -147,9 +147,9 @@ class Module extends BaseModule
/** /**
* @Then I see exit code :code * @Then I see exit code :code
*/ */
public function seeExitCode(int $exitCode): void public function seeExitCode(string $exitCode): void
{ {
if ($this->exitCode === $exitCode) { if ($this->exitCode === (int) $exitCode) {
return; return;
} }

View File

@ -177,32 +177,6 @@ Feature: Eloquent Builder types
When I run Psalm When I run Psalm
Then I see no errors Then I see no errors
Scenario: cannot call firstOrNew and firstOrCreate without parameters in Laravel 6.x
Given I have the "laravel/framework" package satisfying the "6.*"
And I have the following code
"""
/**
* @psalm-param Builder<User> $builder
* @psalm-return User
*/
function test_firstOrCreate(Builder $builder): User {
return $builder->firstOrCreate();
}
/**
* @psalm-param Builder<User> $builder
* @psalm-return User
*/
function test_firstOrNew(Builder $builder): User {
return $builder->firstOrNew();
}
"""
When I run Psalm
Then I see these errors
| Type | Message |
| TooFewArguments | Too few arguments for method Illuminate\Database\Eloquent\Builder::firstorcreate saw 0 |
| TooFewArguments | Too few arguments for method Illuminate\Database\Eloquent\Builder::firstornew saw 0 |
Scenario: can call firstOrNew and firstOrCreate without parameters in Laravel 8.x Scenario: can call firstOrNew and firstOrCreate without parameters in Laravel 8.x
Given I have the "laravel/framework" package satisfying the ">= 8.0" Given I have the "laravel/framework" package satisfying the ">= 8.0"
And I have the following code And I have the following code

View File

@ -357,35 +357,6 @@ Feature: Eloquent Relation types
When I run Psalm When I run Psalm
Then I see no errors Then I see no errors
Scenario: cannot call firstOrNew and firstOrCreate without parameters in Laravel 6.x
Given I have the "laravel/framework" package satisfying the "6.*"
And I have the following code
"""
function test_hasOne_firstOrCreate(User $user): Phone {
return $user->phone()->firstOrCreate();
}
function test_hasOne_firstOrNew(User $user): Phone {
return $user->phone()->firstOrNew();
}
function test_hasMany_firstOrCreate(Post $post): Comment {
return $post->comments()->firstOrCreate();
}
function test_hasMany_firstOrNew(Post $post): Comment {
return $post->comments()->firstOrNew();
}
"""
When I run Psalm
Then I see these errors
| Type | Message |
| TooFewArguments | Too few arguments for method Illuminate\Database\Eloquent\Relations\HasOneOrMany::firstorcreate saw 0 |
| TooFewArguments | Too few arguments for method Illuminate\Database\Eloquent\Relations\HasOneOrMany::firstornew saw 0 |
| TooFewArguments | Too few arguments for method Illuminate\Database\Eloquent\Relations\HasOneOrMany::firstorcreate saw 0 |
| TooFewArguments | Too few arguments for method Illuminate\Database\Eloquent\Relations\HasOneOrMany::firstornew saw 0 |
Scenario: can call firstOrNew and firstOrCreate without parameters in Laravel 8.x Scenario: can call firstOrNew and firstOrCreate without parameters in Laravel 8.x
Given I have the "laravel/framework" package satisfying the ">= 8.0" Given I have the "laravel/framework" package satisfying the ">= 8.0"
And I have the following code And I have the following code

View File

@ -24,57 +24,6 @@ Feature: factory()
use Tests\Psalm\LaravelPlugin\Models\User; use Tests\Psalm\LaravelPlugin\Models\User;
""" """
Scenario: can use factory helper in Laravel 6.x and 7.x
Given I have the "laravel/framework" package satisfying the "6.*"
And I have the following code
"""
class FactoryTest {
/**
* @return FactoryBuilder<User, 1>
*/
public function getFactory(): FactoryBuilder
{
return factory(User::class);
}
/**
* @return FactoryBuilder<User, 2>
*/
public function getFactoryForTwo(): FactoryBuilder
{
return factory(User::class, 2);
}
public function makeUser(): User
{
return factory(User::class)->make();
}
public function createUser(): User
{
return factory(User::class)->create();
}
/**
* @return Collection<User>
*/
public function createUsers(): Collection
{
return factory(User::class, 2)->create();
}
/**
* @return Collection<User>
*/
public function createUsersWithNameAttribute(): Collection
{
return factory(User::class, 'new name', 2)->create();
}
}
"""
When I run Psalm
Then I see no errors
Scenario: cannot use factory helper in Laravel 8.x and later Scenario: cannot use factory helper in Laravel 8.x and later
Given I have the "laravel/framework" package satisfying the ">= 8.0" Given I have the "laravel/framework" package satisfying the ">= 8.0"
And I have the following code And I have the following code