everzet/persisted-objects

Overly simplistic persistance implementations for functional testing

Maintainers

👁 everzet

Package info

github.com/everzet/persisted-objects

pkg:composer/everzet/persisted-objects

Statistics

Installs: 70 861

Dependents: 7

Suggesters: 0

Stars: 132

v1.0.4 2018-02-12 12:14 UTC

Requires

  • php: >5.3,<7.3

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 1d3584c0f1e8d94cad10d28a4d1645b272d594b9

BDDtestrepositorydddpersistance

This package is auto-updated.

Last update: 2026-06-28 22:58:01 UTC


README

This repository is a collection of repositories (pun intended) that somebody might find useful in training or testing exercises. They provide an easy way to create Fakes for your repositories in the test infrastructure.

Why?

As stated in the header - for testing and demo purposes. These repos are optimised for cases where you have less than 20 records in your repository and there's always only one user accessing it at a time. In these particular cases these repositories are faster. But in every other instance they're exponentially not.

Usage

Install with:

$> composer require --dev everzet/persisted-objects

Use like this:

$repo = new FileRepository(TEMP_FILE, new AccessorObjectIdentifier('getId'));
$repo->save($user);

$user === $repo->findById($user->getId());

$repo->clear();

or like this:

$repo = new InMemoryRepository(new CallbackObjectIdentifier(
 function($obj) { return $obj->getFirstname() . $obj->getLastname(); }
);
$repo->save($user);

$user === $repo->findById($user->getFirstname() . $user->getLastname());

$repo->clear();