Skip to content

Commit ad091af

Browse files
committed
Initial commit
0 parents  commit ad091af

8 files changed

+132
-0
lines changed

.editorconfig

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true
7+
indent_style = spaces
8+
charset = utf-8

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.editorconfig export-ignore
2+
/.gitattributes export-ignore
3+
/.gitignore export-ignore

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/coverage/
2+
/composer.lock
3+
/vendor/
4+
/.idea/

CONTRIBUTING.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## Submitting useful bug reports
2+
3+
Please search existing issues first to make sure this is not a duplicate.
4+
Every issue report has a cost for the developers required to field it; be
5+
respectful of others' time and ensure your report isn't spurious prior to
6+
submission. Please adhere to [sound bug reporting principles](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html).
7+
8+
## Development ideology
9+
10+
Truths which we believe to be self-evident:
11+
12+
- **It's an asynchronous world.** Be wary of anything that undermines
13+
async principles.
14+
15+
- **The answer is not more options.** If you feel compelled to expose
16+
new preferences to the user it's very possible you've made a wrong
17+
turn somewhere.
18+
19+
- **There are no power users.** The idea that some users "understand"
20+
concepts better than others has proven to be, for the most part, false.
21+
If anything, "power users" are more dangerous than the rest, and we
22+
should avoid exposing dangerous functionality to them.
23+
24+
## Code style
25+
26+
The amphp project adheres to the PSR-2 style guide with the exception that
27+
opening braces for classes and methods must appear on the same line as
28+
the declaration:
29+
30+
https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 amphp
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# phpunit-util
2+
3+
![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)
4+
5+
`amphp/phpunit-util` is a small helper package to ease testing with PHPUnit in combination with the [`amp`](https://github.com/amphp/amp) concurrency framework.
6+
7+
**Required PHP Version**
8+
9+
- PHP 7.0+
10+
11+
**Installation**
12+
13+
```bash
14+
composer require --dev amphp/phpunit-util
15+
```
16+
17+
**Usage**
18+
19+
Currently, this package only provides a PHPUnit `TestListener` to reset the global event loop after each test. By adding the listener to your PHPUnit configuration, each test will be executed with a completely new event loop instance.
20+
21+
```xml
22+
<phpunit>
23+
<!-- ... -->
24+
25+
<listeners>
26+
<listener class="Amp\PHPUnit\LoopReset" />
27+
</listeners>
28+
29+
<!-- ... -->
30+
</phpunit>
31+
```

composer.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "amphp/phpunit-util",
3+
"license": "MIT",
4+
"authors": [
5+
{
6+
"name": "Niklas Keller",
7+
"email": "me@kelunik.com"
8+
}
9+
],
10+
"support": {
11+
"issues": "https://github.com/amphp/phpunit-util/issues"
12+
},
13+
"require": {
14+
"amphp/amp": "^2@dev",
15+
"phpunit/phpunit": "^6"
16+
},
17+
"autoload": {
18+
"psr-4": {
19+
"Amp\\PHPUnit\\": "src"
20+
}
21+
}
22+
}

src/LoopReset.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Amp\PHPUnit;
4+
5+
use Amp\Loop;
6+
use PHPUnit\Framework\BaseTestListener;
7+
use PHPUnit\Framework\Test;
8+
9+
class LoopReset extends BaseTestListener {
10+
public function endTest(Test $test, $time) {
11+
Loop::set((new Loop\Factory)->create());
12+
}
13+
}

0 commit comments

Comments
 (0)