PHPackages                             kodzila/data-assertions - 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. kodzila/data-assertions

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

kodzila/data-assertions
=======================

Library for assertions utils of entities returned from E2E tests.

1.0.0(4y ago)05PHPPHP ^7.4 | ^8.0

Since Sep 8Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Kodzila/data-assertions)[ Packagist](https://packagist.org/packages/kodzila/data-assertions)[ RSS](/packages/kodzila-data-assertions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

Data assertions
===============

[](#data-assertions)

This library helps to deal with asserting proper structure returned via array. Main usage are E2E tests where entities are returned in non-strict way.

Usages
======

[](#usages)

Validate structure of single entity
-----------------------------------

[](#validate-structure-of-single-entity)

Consider an example: There is a webservice which returns a single note. Structure of the note should be as follows:

Resource Note:

- @id: iri
- title: string
- description: string
- location: GeoLocation
- startDate: string
- endDate: string
- personal: boolean
- content: iri
- author: iri
- createdAt: string

You can write assertions in that way:

```
use Kodzila\DataAssertions\EntityAssertion;

$noteData = $webService->getNote();

$assertions = EntityAssertion::build($noteData);
$assertions->field('@id')->iri();
$assertions->field('title')->string();
$assertions->field('description')->string();
$assertions->field('location')->entity();
$assertions->field('startDate')->string();
$assertions->field('endDate')->string();
$assertions->field('personal')->bool();
$assertions->field('content')->iri();
$assertions->field('author')->iri();
$assertions->field('createdAt')->string();
```

It will accept data like that:

```
$noteData = [
    '@id' => '/api/note/dd85948e-6573-4d66-b743-cca4835448e9',
    'title' => 'Note title',
    'description' => 'Note title',
    'location' => [
        'lat' => 1,
        'lng' => 2,
        'name' => 'Kodzila note',
    ],
    'startDate' => '2020-04-06T00:00:00+02:00',
    'endDate' => '2020-04-10T00:00:00+02:00',
    'personal' => true,
    'content' => '/api/projects/dd85948e-6573-4d66-b743-cca4835448e9',
    'author' => '/api/people/b1a93fec-45f1-461f-a93b-b7d2497e9eeb',
    'createdAt' => '2020-09-14T12:55:17+02:00',
];
```

Validate structure of entity collection
---------------------------------------

[](#validate-structure-of-entity-collection)

Beside single entity, the often scenario is to hit an endpoint with collection of entities.

Consider an endpoint GET /notes with returned structure:

Resource SimpleNote:

- @id: iri
- title: string
- description: string
- location: GeoLocation
- startDate: string
- endDate: string
- personal: boolean
- content: iri
- author: iri
- createdAt: string

You can write assertions in that way:

```
use Kodzila\DataAssertions\EntityAssertion;

$notesData = $webService->getNotes();

EntityCollectionAssertion::build($notesData)
    ->each(function (EntityAssertion $entityAssertion): void {
        $entityAssertion->field('@id')->iri();
        $entityAssertion->field('title')->string();
        $entityAssertion->field('description')->string();
    });
```

It will accept data like that:

```
$notesData = [
    [
        '@id' => '/api/note/dd85948e-6573-4d66-b743-cca4835448e9',
        'title' => 'Note title',
        'description' => 'Note title',
    ],
    [
        '@id' => '/api/note/b1a93fec-45f1-461f-a93b-b7d2497e9eeb',
        'title' => 'Note title 2',
        'description' => 'Note title 2',
    ],
];
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

Unknown

Total

1

Last Release

1708d ago

### Community

Maintainers

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

---

Top Contributors

[![pawel-kozik](https://avatars.githubusercontent.com/u/174309081?v=4)](https://github.com/pawel-kozik "pawel-kozik (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/kodzila-data-assertions/health.svg)

```
[![Health](https://phpackages.com/badges/kodzila-data-assertions/health.svg)](https://phpackages.com/packages/kodzila-data-assertions)
```

###  Alternatives

[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k26.2M1.8k](/packages/infection-infection)[phparkitect/phparkitect

Enforce architectural constraints in your PHP applications

8853.8M17](/packages/phparkitect-phparkitect)[nyholm/nsa

See everything and do whatever you want. No privacy rule will stop us. Used in tests, debugging and fixtures to access properties and methods.

2286.0M79](/packages/nyholm-nsa)[symplify/phpstan-rules

Set of Symplify rules for PHPStan

26211.1M223](/packages/symplify-phpstan-rules)[tomasvotruba/unused-public

Detect unused public properties, constants and methods in your code

1923.2M100](/packages/tomasvotruba-unused-public)[rector/type-perfect

Next level type declaration checks

1015.0M132](/packages/rector-type-perfect)

PHPackages © 2026

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