PHPackages                             skrepr/dto-tester - 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. skrepr/dto-tester

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

skrepr/dto-tester
=================

Skrepr Data Transfer Object Tester

v0.2.6(2y ago)31.5k↓100%[2 issues](https://github.com/skrepr/dto-tester/issues)1MITPHPPHP &gt;=8.1

Since Jan 23Pushed 2y ago1 watchersCompare

[ Source](https://github.com/skrepr/dto-tester)[ Packagist](https://packagist.org/packages/skrepr/dto-tester)[ RSS](/packages/skrepr-dto-tester/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (12)Used By (1)

[ ![skrepr](https://camo.githubusercontent.com/1c7d0997192e2218cca5a1d6983b872faf0af3e027e85802356e3a16025d39b9/68747470733a2f2f736b726570722e636f6d2f7468656d652f736b726570722f696d672f736b726570722e7376673f61336435663739393431)](https://skrepr.com/)Data Transfer Object - Tester
=============================

[](#data-transfer-object---tester)

This is a simple library to make unit tests for DTO's and Entity objects easier. By using this DtoTestCase it will automatically test all public properties and get/set combinations.

Of course this is not just to satisfy the "coverage", but it is to test the basics and makes sure that your DTO's are always behave the same as you expect.

Note that you always must create your own extra tests for specific tasks and any business logic.

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

[](#installation)

You can install the package using the [Composer](https://getcomposer.org/) package manager. It is recommended that you install this only as a development package. You can install it by running this command in your project root:

```
composer require --dev skrepr/dto-tester
```

Usage
-----

[](#usage)

The abstract class DtoTestCase has 3 required methods for you to implement:

- `getInstance`
- `getTestValuesForProperty`
- `getTestValuesForMethod`

And at this moment one optional setting: - $markEmptyAsSkipped

The `getInstance` method should return a testable object. This object is only requested twice during all the tests. First for the properties and the second time when the methods are tested.

Next the `getTestValuesForProperty` and `getTestValuesForMethod` methods should return an array with possible values that should be tested.

The `getTestValuesForProperty` method gets the property name and type, here you can check and give values you want to test. You can also give a `null` value instead of an array, then the tests for that property are skipped (unless it is a nullable-property). The nullable variant will always be tested, it is not possible to use `null` as a value within the array.

The `getTestValuesForMethod` method works in the same way, it only gives back the method name extra.

For union types, the property/parameter will be tested for every type in the union.

When you don't have special needs, you can use "match" like this:

```
    protected function getTestValuesForMethod(string $methodName, string $parameterName, string $parameterType): ?array
    {
        return match ($parameterType) {
            'int' => [1, 42, 1337],
            'string' => ['test', 'skrper'],
            'bool' => [true, false],
            SomeClass::class => [new SomeClass(), $this->createMock(SomeClass::class)]
        };
    }
```

It is not recommended to use a "default" when using a match like this. In fact, you will get a nice readable exception, so you know what you missed.

Known issues
------------

[](#known-issues)

- Readonly properties are not supported
- Not yet possible to test for other result value from getter

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity22

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 ~39 days

Recently: every ~85 days

Total

11

Last Release

818d ago

Major Versions

v0.2.1 → v1.x-dev2023-02-09

### Community

Maintainers

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

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

---

Top Contributors

[![erkens](https://avatars.githubusercontent.com/u/10248696?v=4)](https://github.com/erkens "erkens (14 commits)")

---

Tags

phpunitentitydata-transfer-objectdtounittesttester

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/skrepr-dto-tester/health.svg)

```
[![Health](https://phpackages.com/badges/skrepr-dto-tester/health.svg)](https://phpackages.com/packages/skrepr-dto-tester)
```

###  Alternatives

[phpunit/phpunit

The PHP Unit Testing framework.

20.0k910.7M134.8k](/packages/phpunit-phpunit)[spatie/phpunit-snapshot-assertions

Snapshot testing with PHPUnit

69417.9M510](/packages/spatie-phpunit-snapshot-assertions)[dg/bypass-finals

Removes final keyword from source code on-the-fly and allows mocking of final methods and classes

56426.3M456](/packages/dg-bypass-finals)[phpspec/prophecy-phpunit

Integrating the Prophecy mocking library in PHPUnit test cases

19254.9M1.4k](/packages/phpspec-prophecy-phpunit)[rregeer/phpunit-coverage-check

Check the code coverage using the clover report of phpunit

606.1M179](/packages/rregeer-phpunit-coverage-check)[friendsofcake/fixturize

CakePHP Fixture classes to help increase productivity or performance

24504.7k1](/packages/friendsofcake-fixturize)

PHPackages © 2026

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