wyrihaximus/test-utilities

🛠️ Test utilities for api-clients packages

Maintainers

Package info

github.com/WyriHaximus/php-test-utilities

Language:Makefile

Type:composer-plugin

pkg:composer/wyrihaximus/test-utilities

Transparency log

Fund package maintenance!

WyriHaximus

Statistics

Installs: 1 684 933

Dependents: 65

Suggesters: 0

Stars: 7

Open Issues: 11

14.0.0 2026-08-09 21:33 UTC

README

Test utilities for api-clients packages.

Continuous Integration Latest Stable Version Total Downloads Type Coverage License

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:

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 test
  • getRandomNameSpace() — a unique namespace string for each test
  • getFilesInDirectory() — list files in a directory recursively
  • rmdir() — recursively remove a directory, including symlinks
  • provideTrueFalse() — 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:

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.