PHPackages                             valkyrja/phpunit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. valkyrja/phpunit

ActiveProject[Testing &amp; Quality](/categories/testing)

valkyrja/phpunit
================

PHPUnit for the Valkyrja Project.

v26.4.1(1w ago)05.1k—9.6%MITPHPPHP &gt;=8.4CI passing

Since Apr 16Pushed 1w agoCompare

[ Source](https://github.com/valkyrjaio/ci-phpunit-php)[ Packagist](https://packagist.org/packages/valkyrja/phpunit)[ Docs](https://www.valkyrja.io/)[ RSS](/packages/valkyrja-phpunit/feed)WikiDiscussions 26.x Synced 1w ago

READMEChangelog (8)Dependencies (5)Versions (19)Used By (0)

[ ![](https://raw.githubusercontent.com/valkyrjaio/art/refs/heads/master/long-banner/orange/php.png)](https://valkyrja.io)

Valkyrja PHPUnit
================

[](#valkyrja-phpunit)

Shared PHPUnit configuration for Valkyrja PHP projects — custom assertions, a reusable test case base class, and a workflow that runs PHPUnit across consuming repositories.

 [![PHP Version Require](https://camo.githubusercontent.com/f74c8b3fbab476c86273501ec77535cd7a39c30d039cfde6dd5c5a03969646f3/68747470733a2f2f706f7365722e707567782e6f72672f76616c6b79726a612f706870756e69742f726571756972652f706870)](https://packagist.org/packages/valkyrja/phpunit) [![Latest Stable Version](https://camo.githubusercontent.com/111036ff978635d1f75e071a7c85de7b4ef7d8debdb98bd26511462a7066339b/68747470733a2f2f706f7365722e707567782e6f72672f76616c6b79726a612f706870756e69742f76)](https://packagist.org/packages/valkyrja/phpunit) [![License](https://camo.githubusercontent.com/5a19196b0c86159c8c635d8ae4d8e8c5f20b143f3adb8f76e4e91f3586261e31/68747470733a2f2f706f7365722e707567782e6f72672f76616c6b79726a612f706870756e69742f6c6963656e7365)](https://packagist.org/packages/valkyrja/phpunit) [![CI Status](https://github.com/valkyrjaio/ci-phpunit-php/actions/workflows/ci.yml/badge.svg?branch=26.x)](https://github.com/valkyrjaio/ci-phpunit-php/actions/workflows/ci.yml?query=branch%3A26.x) [![Scrutinizer](https://camo.githubusercontent.com/cb35f0403138da139001811d2a256cbdec43f44149113177cc560c4579f566af/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f76616c6b79726a61696f2f63692d706870756e69742d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d32362e78)](https://scrutinizer-ci.com/g/valkyrjaio/ci-phpunit-php/?branch=26.x) [![Coverage Status](https://camo.githubusercontent.com/67e1e147449304bd6477226b435bfc7db7497bf52c7fb0830c899e648d12b0a7/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f76616c6b79726a61696f2f63692d706870756e69742d7068702f62616467652e7376673f6272616e63683d32362e78)](https://coveralls.io/github/valkyrjaio/ci-phpunit-php?branch=26.x) [![Psalm Shepherd](https://camo.githubusercontent.com/3e357227abfd5442d7eca5ef874e83b587c8208c74fb07d39eef43da600b3cd5/68747470733a2f2f73686570686572642e6465762f6769746875622f76616c6b79726a61696f2f63692d706870756e69742d7068702f636f7665726167652e737667)](https://shepherd.dev/github/valkyrjaio/ci-phpunit-php) [![Maintainability Rating](https://camo.githubusercontent.com/778c02392ade4baf80d976d67d71c5625f28533884abddab3973f8acf1281660/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d76616c6b79726a61696f5f706870756e6974266d65747269633d7371616c655f726174696e67)](https://sonarcloud.io/summary/new_code?id=valkyrjaio_phpunit)

Overview
--------

[](#overview)

This repository provides `ValkyrjaTestCase`, an abstract base class that extends PHPUnit's `TestCase` with additional assertion helpers used across the Valkyrja monorepo.

Installation
------------

[](#installation)

```
composer require valkyrja/phpunit

```

Usage
-----

[](#usage)

Extend `ValkyrjaTestCase` (or the provided `PhpUnitTestCase` subclass) in your test classes to gain access to the additional assertions:

```
use Valkyrja\PhpUnit\Abstract\ValkyrjaTestCase;

final class MyTest extends ValkyrjaTestCase
{
    public function testSomething(): void
    {
        self::assertIsA(MyInterface::class, MyClass::class);
    }
}

```

Additional Assertions
---------------------

[](#additional-assertions)

### `assertIsA(string $expected, string $actual)`

[](#assertisastring-expected-string-actual)

Asserts that `$actual` is `$expected` or one of its descendants/implementations, using `is_a()` with `$allow_string = true`.

```
self::assertIsA(ParentClass::class, ChildClass::class);
self::assertIsA(MyInterface::class, MyClass::class);

```

### `assertMethodExists(object|string $class, string $method)`

[](#assertmethodexistsobjectstring-class-string-method)

Asserts that `$method` exists on the given class name or object instance.

```
self::assertMethodExists(MyClass::class, 'myMethod');
self::assertMethodExists(new MyClass(), 'myMethod');

```

### `assertClassExists(string $class)`

[](#assertclassexistsstring-class)

Asserts that the given class name resolves to a loadable class.

```
self::assertClassExists(MyClass::class);

```

### `assertInterfaceExists(string $interface)`

[](#assertinterfaceexistsstring-interface)

Asserts that the given name resolves to a loadable interface.

```
self::assertInterfaceExists(MyInterface::class);

```

### `assertTraitExists(string $trait)`

[](#asserttraitexistsstring-trait)

Asserts that the given name resolves to a loadable trait.

```
self::assertTraitExists(MyTrait::class);

```

### `assertSameCount(array|Countable $expected, array|Countable $actual)`

[](#assertsamecountarraycountable-expected-arraycountable-actual)

Asserts that `$actual` has the same number of elements as `$expected`.

```
self::assertSameCount($expectedCollection, $actualCollection);

```

### `isA(string $expected, string $actual)`

[](#isastring-expected-string-actual)

Alias for `assertIsA`.

```
self::isA(ParentClass::class, ChildClass::class);

```

Workflows
---------

[](#workflows)

The [`_workflow-call.yml`](.github/workflows/_workflow-call.yml) reusable workflow runs PHPUnit against the calling repository's source. It is designed to be called from other repositories via `workflow_call`.

### Inputs

[](#inputs)

InputTypeDefaultDescription`paths`string—**Required.** YAML filter spec with two keys: `ci` (CI config files that trigger a base-branch fetch) and `files` (all files that trigger the check).`post-pr-comment`boolean`true`Post a PR comment on failure and remove it on success. Disable when the calling workflow handles its own reporting.`composer-options`string`''`Extra flags passed to every `composer install` step (e.g. `--ignore-platform-req=ext-openswoole`).`ci-directory`string`'.github/ci/phpunit'`Path to the CI directory containing `composer.json` and the tool config.`extensions`string`'mbstring, intl'`PHP extensions to install via `shivammathur/setup-php`.`php-versions`string`'["8.4"]'`JSON array of PHP versions to test against. Each version runs as a separate matrix job.`php-version-bleeding-edge`string`''`PHP version treated as bleeding edge — runs with `continue-on-error` and `--ignore-platform-req=php+`.`coverage-php-version`string`'8.4'`PHP version that collects coverage (all other matrix versions run plain phpunit).### Usage

[](#usage-1)

```
jobs:
  phpunit:
    uses: valkyrjaio/ci-phpunit-php/.github/workflows/_workflow-call.yml@26.x
    permissions:
      pull-requests: write
      contents: read
    with:
      php-versions: '["8.4", "8.5"]'
      php-version-bleeding-edge: '8.5'
      paths: |
        ci:
          - '.github/ci/phpunit/**'
          - '.github/workflows/phpunit.yml'
        files:
          - '.github/ci/phpunit/**'
          - '.github/workflows/phpunit.yml'
          - 'src/**/*.php'
          - 'tests/**/*.php'
          - 'composer.json'
    secrets: inherit
```

`secrets: inherit` is required to pass the `VALKYRJA_GHA_APP_ID` and `VALKYRJA_GHA_PRIVATE_KEY` org secrets used for PR comments.

Contributing
------------

[](#contributing)

See [`CONTRIBUTING.md`](https://github.com/valkyrjaio/.github/blob/master/CONTRIBUTING.md) for the submission process and [`VOCABULARY.md`](https://github.com/valkyrjaio/.github/blob/master/VOCABULARY.md) for the terminology used across Valkyrja.

Security Issues
---------------

[](#security-issues)

If you discover a security vulnerability, please follow our [disclosure procedure](https://github.com/valkyrjaio/.github/blob/master/SECURITY.md).

License
-------

[](#license)

Licensed under the [MIT license](https://opensource.org/licenses/MIT). See [`LICENSE.md`](./LICENSE.md).

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance98

Actively maintained with recent releases

Popularity25

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 52.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

9

Last Release

8d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fbb43a59fb790365b014e53f82e3f26893867e4a47a249fc92962b6dc76878f2?d=identicon)[MelechMizrachi](/maintainers/MelechMizrachi)

---

Top Contributors

[![MelechMizrachi](https://avatars.githubusercontent.com/u/1179171?v=4)](https://github.com/MelechMizrachi "MelechMizrachi (58 commits)")[![valkyrja-volundr[bot]](https://avatars.githubusercontent.com/in/2462900?v=4)](https://github.com/valkyrja-volundr[bot] "valkyrja-volundr[bot] (53 commits)")

---

Tags

phpunitcivalkyrja

### Embed Badge

![Health badge](/badges/valkyrja-phpunit/health.svg)

```
[![Health](https://phpackages.com/badges/valkyrja-phpunit/health.svg)](https://phpackages.com/packages/valkyrja-phpunit)
```

###  Alternatives

[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k41.3M38.3k](/packages/orchestra-testbench)[brianium/paratest

Parallel testing for PHP

2.5k129.9M905](/packages/brianium-paratest)[spatie/phpunit-snapshot-assertions

Snapshot testing with PHPUnit

69519.1M604](/packages/spatie-phpunit-snapshot-assertions)[ergebnis/phpunit-slow-test-detector

Provides facilities for detecting slow tests in phpunit/phpunit.

1489.3M94](/packages/ergebnis-phpunit-slow-test-detector)[allure-framework/allure-phpunit

Allure PHPUnit integration

6913.2M44](/packages/allure-framework-allure-phpunit)[rregeer/phpunit-coverage-check

Check the code coverage using the clover report of phpunit

606.3M203](/packages/rregeer-phpunit-coverage-check)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
