This Pest plugin adds Laravel specific expectations to the testing ecosystem
it('can check model exists', function(){
$user = User::factory()->create();
expect($user)->toExist();
});
You can install the package via composer:
composer require --dev defstudio/pest-plugin-laravel-expectations
The expectations added by this plugin are authomatically loaded into Pest's expectation system. They can be used along other expectations.
Assert that the given User is authenticated
expect($user)->toBeAuthenticated();
Assert that the given credentials are valid.
expect(['email' => 'test@email.it', 'password' => 'foo'])->toBeValidCredentials();
Assert that the given credentials are invalid.
expect(['email' => 'test@email.it', 'password' => 'wrongpassword'])->toBeInvalidCredentials();
Assert that the value is an instance of \Illuminate\Support\Collection
expect(collect[1,2,3])->toBeCollection();
Assert the given model to be deleted.
expect($model)->toBeDeleted();
Assert the given model to be soft deleted.
expect($model)->toBeSoftDeleted();
Assert that the value is an instance of \Illuminate\Database\Eloquent\Collection
expect(User::all())->toBeCollection();
Assert the given model exists in the database.
expect($model)->toExist();
Run all tests:
composer test
Check types:
composer test:types
Unit tests:
composer test:unit
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.