akondas / exspecto
Small PHP DSL for synchronizing asynchronous operations (busy-waiting)
Installs: 1 735
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=8.2
Requires (Dev)
- php-cs-fixer/shim: ^3.64
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.4
This package is auto-updated.
Last update: 2024-11-24 14:52:43 UTC
README
Small PHP DSL for synchronizing asynchronous operations (busy-waiting).
A simple and useful library recommended especially for testing asynchronous systems. Exspecto allows you to express expectations of an asynchronous system in a concise and easy to read manner. Example:
await()->atMost(1)->until(function() { return customerStatusIsUpdated(); });
You can use pollInterval
to set how often the condition should be checked (default value is 100 milliseconds):
await()->atMost(3)->pollInterval(200)->until(function() { return customerStatusIsUpdated(); });
You can also await for given value in case the returning method (closure) could throw an exception:
$value = await()->atMost(3)->pollInterval(200)->on(fn() => getValue());
exspecto - from latin: wait for, await
Install
composer require akondas/exspecto
Roadmap
-
untilAsserted
for example:untilAsserted('UserRepository::size', equaltTo(3))
- support different poll interval strategy (fixed, fibonacci, iterative)
-
ignoreExceptions
do not stop when exceptions occur (ignoreException(string $exceptionClass)
) -
atLeast
-
unitlNotNull
,untilNull
etc.
License
Exspecto is released under the MIT Licence. See the bundled LICENSE file for details.
Author
Arkadiusz Kondas (@ArkadiuszKondas)