pest-plugin-laravel maintained by soyhuce
Pest plugin for Laravel development
Installation
You can install the package via composer:
composer require soyhuce/pest-plugin-laravel --dev
Usage
Expectations
toBeModelexpects that the value matches current model
expect($model)->toBeModel($expectedModel)
toBeCollectionexpects that the collection matches current collection
expect($collection)->toBeCollection(new Collection([1,2,3]));
/// Expected collection can be given as array
expect($collection)->toBeCollection([1,2,3]);
Keys and order of the collections are checked and must match.
toBeCollectionCanonicalizingexpects that the collection matches current collection, ignoring order
expect($collection)->toBeCollectionCanonicalizing(new Collection([1,2,3]));
/// Expected collection can be given as array
expect($collection)->toBeCollectionCanonicalizing([3,1,2]);
Keys of the collections are checked and must match.
toBeAbleToexpect that the autenticatable can perform the given action
expect($user)->toBeAbleTo('update', $post);
Data expectations : require spatie/laravel-data package
toBeDataexpects that the value matches current data object
expect($data)->toBeData(new UserData(['name' => 'John Doe']));
toBeDataCollectionexpects that the collection matches current data collection
expect($dataCollection)->toBeDataCollection(new UserDataCollection([
new UserData(['name' => 'John Doe']),
new UserData(['name' => 'Jane Doe']),
]));
// Expected collection can be given as array
expect($dataCollection)->toBeDataCollection([['name' => 'John Doe'], ['name' => 'Jane Doe']]);