Skip to content

Commit

Permalink
Implement MVP version of exspecto
Browse files Browse the repository at this point in the history
  • Loading branch information
akondas committed Jan 27, 2021
1 parent dc04be4 commit 5dd944b
Show file tree
Hide file tree
Showing 14 changed files with 4,535 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* text=auto

/.codecov.yml export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs.dist export-ignore
/buddy.yml export-ignore
/phpunit.xml.dist export-ignore
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/vendor/
.phpunit.cache
phpunit.xml
.php_cs.cache
43 changes: 43 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
;

return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PHP71Migration' => true,
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'no_unused_imports' => true,
'declare_strict_types' => true,
'ordered_imports' => [
'importsOrder' => null,
'sortAlgorithm' => 'alpha',
],
'phpdoc_order' => true,
'phpdoc_align' => true,
'phpdoc_no_access' => true,
'phpdoc_separation' => true,
'pre_increment' => true,
'single_quote' => true,
'trim_array_spaces' => true,
'single_blank_line_before_namespace' => true,
'yoda_style' => null,
'global_namespace_import' => [
'import_classes' => false,
'import_constants' => false,
'import_functions' => false
],
// risky -->
'strict_param' => true,
])
->setFinder($finder)
;
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2021 Arkadiusz Kondas <arkadiusz.kondas[at]gmail>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Exspecto

[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.4-8892BF.svg)](https://php.net/)

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:

```php
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):

```php
await()->atMost(3)->pollInterval(200)->until(function() {
return customerStatusIsUpdated();
});
```

---

*exspecto* - from latin: *wait for*, *await*

## Install

```shell
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)
59 changes: 59 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "akondas/exspecto",
"type": "library",
"description": "Small PHP DSL for synchronizing asynchronous operations (busy-waiting)",
"keywords": [
"php",
"asynchronous",
"busy-waiting",
"testing",
"quality-assurance"
],
"license": "MIT",
"authors": [
{
"name": "Arkadiusz Kondas",
"email": "[email protected]"
}
],
"require": {
"php": "^7.4"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.18",
"phpstan/phpstan": "^0.12.69",
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
"Akondas\\Exspecto\\": "src/"
},
"files": [
"src/functions.php"
]
},
"autoload-dev": {
"psr-4": {
"Akondas\\Exspecto\\Tests\\": "tests/"
}
},
"scripts": {
"build": [
"@check-cs",
"@phpstan",
"@phpunit"
],
"check-cs": [
"php-cs-fixer fix --dry-run --diff"
],
"fix-cs": [
"php-cs-fixer fix"
],
"phpstan": [
"phpstan analyse src tests --level=max"
],
"phpunit": [
"phpunit"
]
}
}
Loading

0 comments on commit 5dd944b

Please sign in to comment.