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.
Asserts that the value is an instance of \Illuminate\Support\Collection
expect(collect[1,2,3])->toBeCollection();
Asserts the given model to be deleted.
expect($model)->toBeDeleted();
Asserts the given model to be soft deleted.
expect($model)->toBeSoftDeleted();
Asserts that the value is an instance of \Illuminate\Database\Eloquent\Collection
expect(User::all())->toBeCollection();
Asserts that the given where condition exists in the database
expect(['name' => 'Fabio'])->toBeInDatabase(table: 'users');
Asserts 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.