PHPackages                             erwane/phpunit-resource-helper - 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. erwane/phpunit-resource-helper

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

erwane/phpunit-resource-helper
==============================

File resources helpers for PHPUnit tests

2.1.1(10mo ago)02264MITPHPPHP ^8.1

Since Aug 2Pushed 10mo agoCompare

[ Source](https://github.com/Erwane/phpunit-resource-helper)[ Packagist](https://packagist.org/packages/erwane/phpunit-resource-helper)[ Docs](https://github.com/Erwane/phpunit-resource-helper)[ Fund](https://www.buymeacoffee.com/erwane)[ GitHub Sponsors](https://github.com/Erwane)[ RSS](/packages/erwane-phpunit-resource-helper/feed)WikiDiscussions 2.1 Synced today

READMEChangelogDependencies (3)Versions (10)Used By (4)

PhpUnit resource helper
=======================

[](#phpunit-resource-helper)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![codecov](https://camo.githubusercontent.com/69b16f7a53d7127651db4c4abe596c8ec5d57fe34bcecd53ed1309a9e13f467e/68747470733a2f2f636f6465636f762e696f2f67682f457277616e652f706870756e69742d7265736f757263652d68656c7065722f6272616e63682f322e312f67726170682f62616467652e7376673f746f6b656e3d684635486845546e6b67)](https://codecov.io/gh/Erwane/phpunit-resource-helper)[![Build Status](https://github.com/Erwane/phpunit-resource-helper/actions/workflows/ci.yml/badge.svg?branch=2.1)](https://github.com/Erwane/phpunit-resource-helper/actions)[![Packagist Downloads](https://camo.githubusercontent.com/bcf1d93a65d9c14c5134610b661ac1b34075c68792092c76cb53dcd51708d529/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f457277616e652f706870756e69742d7265736f757263652d68656c706572)](https://packagist.org/packages/Erwane/phpunit-resource-helper)[![Packagist Version](https://camo.githubusercontent.com/8fac39892530be5f3bfb57fa8afcdacf10fb93fed814ed8f03a3cfd95102401d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f457277616e652f706870756e69742d7265736f757263652d68656c706572)](https://packagist.org/packages/Erwane/phpunit-resource-helper)

Fixtures are for databases, resources for the rest.

Help your phpunit tests to load resources from files, like, json content, raw e-mails, logs file, etc.

Version map
-----------

[](#version-map)

branchThis package versionPHP minPHPUnit1.x^1.0PHP 7.2^7.1 | ^8.0 | ^9.02.02.0.\*PHP 8.0^8.5 | ^9.32.1^2.1PHP 8.1^8.5 | ^9.3 | ^10.0 | ^11.0 | ^12.0Usage
-----

[](#usage)

```
composer require --dev erwane/phpunit-resource-helper
```

Create a `resources` directory in your `tests` dir and put your files in. You can add subdirectories.

You can also configure your base directory and tmp directory in your `tests/bootstrap.php` file:

```
use ResourceHelper\ResourceHelper;

ResourceHelper::setBaseDir('/project/tests_resources/');
ResourceHelper::setTmpDir('/project/tmp/');
```

In your test, you can get your resources path, content or copy with `File` methods:

```
use ResourceHelper\File;

// Get /tests/resources/webhooks/mailgun.json content
$content = File::getContent('webhooks/mailgun.json');

// Create a copy you can manipulate without destroy your resource.
$copy = File::getCopy('accounting/invoices.csv');
```

You can clean your tmp directory with PHPUnit extension.
Only successful tests are cleaned, this allows you to check your resources copy files when test failed.
Set up ResourceHelper extension in your `phpunit.dist.xml` configuration file:

### PHPUnit ^8.5 &amp; ^9.3

[](#phpunit-85--93)

```

```

### PHPUnit &gt;=10

[](#phpunit-10)

```

```

`File` Methods
--------------

[](#file-methods)

### getPath(string $path): string

[](#getpathstring-path-string)

Get resource absolute path from relative `$path`.

```
$path = File::getPath('file.csv');
// $path = '/tests/resources/my-file.csv'
```

### getInfo(string $path): array

[](#getinfostring-path-array)

Get resource information from relative `$path`.

```
$info = File::getInfo('file.csv');
```

`$info` will contain:

```
[
    'path' => '/path/file.csv', // Absolute resource path
    'filename' => 'file.csv', // Filename
    'hash' => 'abcdef0123456789', // File hash
]
```

### getCopy(string $path, TestCase $test): array

[](#getcopystring-path-testcase-test-array)

Copy the resource to a temporary directory relative to current test.
Return the information of this copy.

```
$info = File::getCopy('file.csv');
```

`$info` will contain:

```
[
    'path' => '/tmp/project/Test_Method/file.ext', // Absolute resource copy path
    'filename' => 'file.ext', // Filename
    'hash' => 'abcdef0123456789', // File hash
]
```

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance53

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~1 days

Total

10

Last Release

326d ago

Major Versions

1.0.0 → 2.1.02025-08-11

1.x-dev → 2.0.12025-08-11

PHP version history (3 changes)1.0.0PHP ^7.2

2.1.0PHP ^8.1

2.0.0PHP 8.0.\*

### Community

Maintainers

![](https://www.gravatar.com/avatar/91732d78336582954080932d4350d08420a053dbba6728f1727b5500ab931c65?d=identicon)[Erwane](/maintainers/Erwane)

---

Top Contributors

[![Erwane](https://avatars.githubusercontent.com/u/712604?v=4)](https://github.com/Erwane "Erwane (8 commits)")

---

Tags

phpunithelperresources

### Embed Badge

![Health badge](/badges/erwane-phpunit-resource-helper/health.svg)

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

###  Alternatives

[brianium/paratest

Parallel testing for PHP

2.5k136.1M985](/packages/brianium-paratest)[spatie/phpunit-snapshot-assertions

Snapshot testing with PHPUnit

69619.8M640](/packages/spatie-phpunit-snapshot-assertions)[lchrusciel/api-test-case

Perfect PHPUnit TestCase for JSON/XML API TDD with Symfony.

4125.9M75](/packages/lchrusciel-api-test-case)[ergebnis/phpunit-slow-test-detector

Provides facilities for detecting slow tests in phpunit/phpunit.

1499.9M107](/packages/ergebnis-phpunit-slow-test-detector)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2022.6M343](/packages/drupal-core-dev)[allure-framework/allure-phpunit

Allure PHPUnit integration

6913.4M46](/packages/allure-framework-allure-phpunit)

PHPackages © 2026

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