Download the PHP package mattiasgeniar/phpunit-query-count-assertions without Composer
On this page you can find all versions of the php package mattiasgeniar/phpunit-query-count-assertions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mattiasgeniar/phpunit-query-count-assertions
More information about mattiasgeniar/phpunit-query-count-assertions
Files in mattiasgeniar/phpunit-query-count-assertions
Package phpunit-query-count-assertions
Short Description A custom assertion for phpunit that allows you to count the amount of SQL queries used in a test. Can be used to enforce certain performance characteristics (ie: limit queries to X for a certain action).
License MIT
Homepage https://github.com/mattiasgeniar/phpunit-query-count-assertions
Informations about the package phpunit-query-count-assertions
Laravel query count assertions for PHPUnit
A custom assertion for phpunit that allows you to count the number of SQL queries used in a test. Can be used to enforce certain performance characteristics (ie: limit queries to X for a certain action).
This works for Laravel only at the moment.
Installation
You can install the package via composer:
Usage
Add the AssertsQueryCounts
trait to your test-class, initialize it in the setup()
and you can start asserting queries.
Available assertions/methods
You can use the following methods, their names should be self-explanatory:
All these methods can accept a closure as an extra argument. The assertion will only take in account the queries performed inside the closure. If you use this way of testing, you don't need to call trackQueries
yourself.
Testing
License
The MIT License (MIT). Please see License File for more information.