NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist
Packagist, #3453 most downloaded on Packagist
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).
Latest stable
1.4.0
Last release 13 days ago
09 Nov 2026
Release timing varies
gaps range from 2 weeks to 1.1 years
Most releases are documented
notes for 15 of 25 stable releases
Nothing withdrawn
no release was ever pulled
6 years old
25 releases · first in 2020
Drag across the ruler to compare, or tap a release to open it.
Bump actions/checkout from 6 to 7 by @dependabot[bot] in https://github.com/mattiasgeniar/phpunit-query-count-assertions/pull/22
Full Changelog: https://github.com/mattiasgeniar/phpunit-query-count-assertions/compare/1.3.2...1.4.0
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Add Doctrine/Symfony and Phalcon support via a driver-based architecture, while keeping Laravel zero-config
Full Changelog: https://github.com/mattiasgeniar/phpunit-query-count-assertions/compare/1.2.4...1.2.5
Full Changelog: https://github.com/mattiasgeniar/phpunit-query-count-assertions/compare/1.2.4...1.2.5
Support multiple connections by @mattiasgeniar in https://github.com/mattiasgeniar/phpunit-query-count-assertions/pull/17
Full Changelog: https://github.com/mattiasgeniar/phpunit-query-count-assertions/compare/1.2.2...1.2.4
Full Changelog: https://github.com/mattiasgeniar/phpunit-query-count-assertions/compare/1.2.1...1.2.3
Full Changelog: https://github.com/mattiasgeniar/phpunit-query-count-assertions/compare/1.2.1...1.2.3
Nothing published for this version
Nothing published for this version
`trackQueriesForEfficiency()` is deprecated
trackQueriesForEfficiency() into trackQueries() — one method now does everythingtrackQueries() from static to instance method for consistent $this-> APIself::trackQueries() → $this->trackQueries()
The method is no longer static. Update your setUp/beforeEach:
// Before
protected function setUp(): void
{
parent::setUp();
self::trackQueries();
}
// After
protected function setUp(): void
{
parent::setUp();
$this->trackQueries();
}
trackQueriesForEfficiency() is deprecated
Replace with trackQueries():
// Before
$this->trackQueriesForEfficiency();
// After
$this->trackQueries();
Find and replace in your test files:
| Find | Replace |
|---|---|
self::trackQueries() |
$this->trackQueries() |
$this->trackQueriesForEfficiency() |
$this->trackQueries() |
The previous API had two methods that were confusingly similar:
trackQueries() — basic query loggingtrackQueriesForEfficiency() — query logging + N+1 detectionNow there's just one method that does everything. If you only need query counts, the efficiency tracking has zero overhead — just don't call assertQueriesAreEfficient().
Skip unused index warnings for small tables where MySQL optimizer prefers full scans
Skip unused index warnings for small tables where MySQL optimizer prefers full scans
Add query location reporting to assertion failures by @mattiasgeniar in https://github.com/mattiasgeniar/phpunit-query-count-assertions/pull/14
Full Changelog: https://github.com/mattiasgeniar/phpunit-query-count-assertions/compare/1.1.6...1.1.7
This release adds powerful query performance assertions to catch inefficient queries in your tests.
This release adds powerful query performance assertions to catch inefficient queries in your tests.
Detect full table scans and missing indexes by running EXPLAIN on your queries:
$this->assertAllQueriesUseIndexes(function () {
User::where('email', 'test@example.com')->first();
});
Supports MySQL, MariaDB, and SQLite. Detects full table scans, unused indexes, filesort, temporary tables, and more.
Catch repeated identical queries:
$this->assertNoDuplicateQueries(function () {
User::find(1);
User::find(1); // Fails - duplicate
});
Set performance budgets for your queries:
$this->assertMaxQueryTime(100, fn() => ...); // No single query over 100ms
$this->assertTotalQueryTime(500, fn() => ...); // Total time under 500ms
Fail when queries examine too many rows:
$this->assertMaxRowsExamined(1000, fn() => User::where('status', 'active')->get());
Check everything at once—N+1, duplicates, and index usage:
$this->assertQueriesAreEfficient(function () {
$users = User::with('posts')->get();
});
Or use trackQueriesForEfficiency() in setUp/beforeEach for test-wide tracking.
Add support for additional databases:
AssertsQueryCounts::registerQueryAnalyser(new PostgresAnalyser());
Fully backwards compatible. All existing methods unchanged.
PHP 8.4 support
PHP 8.4 support
Support for Laravel 12
Support for Laravel 12
Support for Laravel 11.x added
Support for Laravel 11.x added
- support Laravel 10
- support Laravel 9
- support Laravel 9
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.