wyrihaximus/test-utilities
A set of PHP test utilities for package development: a PHPUnit TestCase with helpers like random namespaces and temp directories, plus ready-made configuration defaults for PHPStan and Rector (paths and docblock-to-attribute conversions).
Test utilities for api-clients packages.
To install via Composer, use the command below, it will automatically detect the latest version and bind it with ^.
composer require wyrihaximus/test-utilities
When wyrihaximus/makefiles is present, this package registers as a Composer plugin and adds make on-install-or-update || true to your composer.json scripts on install and update.
This package provides a PHPStan extension so your test classes may extend WyriHaximus\TestUtilities\TestCase.
When phpstan/extension-installer is enabled, the extension is registered automatically—no manual configuration required.
If extension-installer is not available, include the extension from your PHPStan configuration:
includes:
- vendor/wyrihaximus/test-utilities/extension.neon
The following PHPStan extensions are provided through wyrihaximus/phpstan-rules-wrapper:
ergebnis/phpstan-rulesphpstan/extension-installerphpstan/phpstanphpstan/phpstan-deprecation-rulesphpstan/phpstan-mockeryphpstan/phpstan-phpunitphpstan/phpstan-strict-rulesshipmonk/dead-code-detectorshipmonk/phpstan-rulesstaabm/phpstan-psr3symplify/phpstan-extensionstomasvotruba/type-coveragewyrihaximus/phpstan-no-safeyamadashy/phpstan-friendly-formatterExtend WyriHaximus\TestUtilities\TestCase in your tests for temporary directories, unique namespaces, and helpers suited to file-storage tests.
Before each test, initializeTemporaryTestEnvironment() creates a unique temporary directory and namespace. After each test, cleanUpTemporaryTestEnvironment() removes them.
Mockery integration is included, along with helpers such as:
getTmpDir() — a unique temporary directory for each testgetRandomNameSpace() — a unique namespace string for each testgetFilesInDirectory() — list files in a directory recursivelyrmdir() — recursively remove a directory, including symlinksprovideTrueFalse() — a data provider for boolean values (don't ask)waitUntilTheNextSecond() — wait until the next second boundaryRector configuration is provided through wyrihaximus/rector-config, which pulls in rector/rector and applies defaults for etc, examples, src, and tests. It also converts supported docblock annotations to attributes.
Create etc/qa/rector.php:
<?php
declare(strict_types=1);
use WyriHaximus\RectorPHP\RectorConfig;
return RectorConfig::configure(dirname(__DIR__, 2));
Most QA tooling is bundled through wyrihaximus/qa-tooling-wrapper:
ergebnis/composer-normalizeergebnis/phpunit-slow-test-detectoricanhazstring/composer-unusedinfection/infectionmaglnet/composer-require-checkermockery/mockeryphp-parallel-lint/php-console-highlighterphp-parallel-lint/php-parallel-lintphpstan/phpstanphpunit/phpunitrector/rectorroave/backward-compatibility-checkshipmonk/coverage-guardsquizlabs/php_codesnifferwyrihaximus/coding-standardThe MIT License (MIT)
Copyright (c) 2026 Cees-Jan Kiewiet
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
How can I help you explore Laravel packages today?