PHPackages                             keboola/php-test-utils - 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. keboola/php-test-utils

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

keboola/php-test-utils
======================

PHP test utilities skeleton.

0.1.0(7mo ago)0432↓28.6%MITPHPPHP &gt;=8.4

Since Sep 15Pushed 2mo agoCompare

[ Source](https://github.com/keboola/php-test-utils)[ Packagist](https://packagist.org/packages/keboola/php-test-utils)[ RSS](/packages/keboola-php-test-utils/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (12)Versions (18)Used By (0)

PHP Test Utils
==============

[](#php-test-utils)

Utilities to make writing PHPUnit tests easier. Currently provides helpers for working with environment variables so that they're properly validated:

Usage
-----

[](#usage)

### TestEnvVarsTrait

[](#testenvvarstrait)

```
use PHPUnit\Framework\TestCase;
use Keboola\PhpTestUtils\TestEnvVarsTrait;

final class MyEnvTest extends TestCase
{
    use TestEnvVarsTrait;

    public function testOptionalEnv(): void
    {
        $clientOptions = new ClientOptions(
            url: new ServiceClient(self::getRequiredEnv('HOSTNAME_SUFFIX'))->getConnectionServiceUrl(),
            token: self::getRequiredEnv('TEST_STORAGE_API_TOKEN_SNOWFLAKE'),
        );
}
```

- **getOptionalEnv(name)**: returns the env var value as a non-empty string, or `null` if not set/empty.
- **getRequiredEnv(name)**: returns the env var value as a non-empty string; fails the env if missing.
- **overrideEnv(name, value|null)**: sets or unsets the variable consistently in `$_ENV` and the process via `putenv`.

### Array and Object Property Assertions

[](#array-and-object-property-assertions)

The library also provides small helpers for asserting nested array values and private object properties via traits:

- AssertArrayPropertySameTrait: assert that a dot-separated path inside an array equals the expected scalar value.
- AssertObjectPropertyValueTrait: assert that an object's property has the expected value.

```
use PHPUnit\Framework\TestCase;
use Keboola\PhpTestUtils\AssertArrayPropertySameTrait;
use Keboola\PhpTestUtils\AssertObjectPropertyValueTrait;

final class MyAssertionsTest extends TestCase
{
    use AssertArrayPropertySameTrait;
    use AssertObjectPropertyValueTrait;

    public function testHelpers(): void
    {
        // Assert nested array property value
        $row = ['customer' => ['id' => 123, 'name' => 'Acme']];
        self::assertArrayPropertySame(123, $row, 'customer.id');

        // Assert (even private) object property value
        $obj = new class() {
            private string $token = 'abc';
        };
        self::assertObjectPropertyValue('abc', $obj, 'token');
    }
}
```

Development
-----------

[](#development)

Clone this repository and init the workspace with following command:

```
git clone https://github.com/keboola/platform-libraries.git
cd php-test-utils
docker-compose build
docker-compose run --rm dev composer install --no-scripts

```

Create `.env.local` file with following contents: Set the token to master storage token to a Snowflake project.

```
HOSTNAME_SUFFIX=keboola.com
TEST_STORAGE_API_TOKEN_SNOWFLAKE=xxx-xxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```

Run the test suite using this command:

```
docker-compose run --rm dev composer tests

```

License
-------

[](#license)

MIT licensed, see [LICENSE](./LICENSE) file.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance76

Regular maintenance activity

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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 ~10 days

Total

4

Last Release

215d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/101dbf2551a0709ddab522f97669f13a2c4cc2d0a1e8d009f3af6ba80accb1a9?d=identicon)[Keboola](/maintainers/Keboola)

---

Top Contributors

[![odinuv](https://avatars.githubusercontent.com/u/4319320?v=4)](https://github.com/odinuv "odinuv (8 commits)")[![devin-ai-integration[bot]](https://avatars.githubusercontent.com/in/811515?v=4)](https://github.com/devin-ai-integration[bot] "devin-ai-integration[bot] (2 commits)")[![pepamartinec](https://avatars.githubusercontent.com/u/271753?v=4)](https://github.com/pepamartinec "pepamartinec (1 commits)")[![romantmb](https://avatars.githubusercontent.com/u/228957?v=4)](https://github.com/romantmb "romantmb (1 commits)")

---

Tags

phptestutilskeboola

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/keboola-php-test-utils/health.svg)

```
[![Health](https://phpackages.com/badges/keboola-php-test-utils/health.svg)](https://phpackages.com/packages/keboola-php-test-utils)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[letsdrink/ouzo-goodies

Utility classes, test assertions and mocking framework extracted from Ouzo framework.

132617.9k7](/packages/letsdrink-ouzo-goodies)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[playwright-php/playwright

Modern PHP library for Playwright automation: browsing, scraping, screenshots, testing, and more.

7613.0k5](/packages/playwright-php-playwright)[quizlet/hammock

Hammock is a stand-alone mocking library for Hacklang.

27445.5k](/packages/quizlet-hammock)

PHPackages © 2026

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