wyrihaximus / test-utilities
🛠️ Test utilities for api-clients packages
Package info
github.com/WyriHaximus/php-test-utilities
Language:Makefile
Type:composer-plugin
pkg:composer/wyrihaximus/test-utilities
Fund package maintenance!
Requires
- php: ^8.4
- composer-plugin-api: ^2
- ext-hash: ^8.4
- ext-json: ^8.4
- phpunit/phpunit: ^13.3
- wyrihaximus/phpstan-rules-wrapper: ^14.4.0
- wyrihaximus/qa-tooling-wrapper: ^2.0.0
- wyrihaximus/rector-config: ^1.0.0
Requires (Dev)
- wyrihaximus/makefiles: ^0.13.3
Suggests
- wyrihaximus/async-test-utilities: The recommended addition to this package when building ReactPHP packages and projects.
- wyrihaximus/makefiles: Provides autogenerated Makefile utilizing all utilities provided through this package.
Conflicts
- composer-unused/symbol-parser: <0.3.3
- composer/composer: <2.10.2
- composer/pcre: <3.3.2
- sanmai/di-container: <0.1.17
- sanmai/pipeline: <7.9
- wyrihaximus/makefiles: <0.5.0
This package is auto-updated.
Last update: 2026-08-15 15:18:56 UTC
README
Test utilities for api-clients packages.
Installation
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.
Usage
PHPStan
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.
Manual configuration
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-formatter
PHPUnit
Extend 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 boundary
Rector
Rector 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));
Included tooling
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-standard
License
The 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.