mirror of
https://github.com/danog/psalm-plugin-laravel.git
synced 2024-11-30 04:39:01 +01:00
fix failing tests
This commit is contained in:
parent
3ddc65b2ae
commit
a0d98b6729
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user