Skip to content

Commit e43d85c

Browse files
authored
Merge pull request #37 from clue-labs/update-tests
Update test suite and report failed assertions
2 parents 6b57d63 + 43215fb commit e43d85c

File tree

6 files changed

+44
-23
lines changed

6 files changed

+44
-23
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88
PHPUnit:
99
name: PHPUnit (PHP ${{ matrix.php }})
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-22.04
1111
strategy:
1212
matrix:
1313
php:
@@ -23,11 +23,12 @@ jobs:
2323
- 5.4
2424
- 5.3
2525
steps:
26-
- uses: actions/checkout@v2
26+
- uses: actions/checkout@v3
2727
- uses: shivammathur/setup-php@v2
2828
with:
2929
php-version: ${{ matrix.php }}
3030
coverage: xdebug
31+
ini-file: development
3132
- run: composer install
3233
- run: vendor/bin/phpunit --coverage-text
3334
if: ${{ matrix.php >= 7.3 }}

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# clue/reactphp-mq
22

3-
[![CI status](https://github.com/clue/reactphp-mq/workflows/CI/badge.svg)](https://github.com/clue/reactphp-mq/actions)
3+
[![CI status](https://github.com/clue/reactphp-mq/actions/workflows/ci.yml/badge.svg)](https://github.com/clue/reactphp-mq/actions)
44
[![installs on Packagist](https://img.shields.io/packagist/dt/clue/mq-react?color=blue&label=installs%20on%20Packagist)](https://packagist.org/packages/clue/mq-react)
55

66
Mini Queue, the lightweight in-memory message queue to concurrently do many (but not too many) things at once,
@@ -485,7 +485,7 @@ This project follows [SemVer](https://semver.org/).
485485
This will install the latest supported version:
486486

487487
```bash
488-
$ composer require clue/mq-react:^1.5
488+
composer require clue/mq-react:^1.5
489489
```
490490

491491
See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
@@ -500,13 +500,13 @@ To run the test suite, you first need to clone this repo and then install all
500500
dependencies [through Composer](https://getcomposer.org/):
501501

502502
```bash
503-
$ composer install
503+
composer install
504504
```
505505

506506
To run the test suite, go to the project root and run:
507507

508508
```bash
509-
$ vendor/bin/phpunit
509+
vendor/bin/phpunit
510510
```
511511

512512
## License

composer.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,24 @@
1010
"email": "christian@clue.engineering"
1111
}
1212
],
13-
"autoload": {
14-
"psr-4": { "Clue\\React\\Mq\\": "src/" }
15-
},
16-
"autoload-dev": {
17-
"psr-4": { "Clue\\Tests\\React\\Mq\\": "tests/" }
18-
},
1913
"require": {
2014
"php": ">=5.3",
2115
"react/promise": "^3 || ^2.2.1 || ^1.2.1"
2216
},
2317
"require-dev": {
24-
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35",
18+
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36",
2519
"react/async": "^4 || ^3 || ^2",
2620
"react/event-loop": "^1.2",
2721
"react/http": "^1.8"
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"Clue\\React\\Mq\\": "src/"
26+
}
27+
},
28+
"autoload-dev": {
29+
"psr-4": {
30+
"Clue\\Tests\\React\\Mq\\": "tests/"
31+
}
2832
}
2933
}

phpunit.xml.dist

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<!-- PHPUnit configuration file with new format for PHPUnit 9.3+ -->
4-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
3+
<!-- PHPUnit configuration file with new format for PHPUnit 9.6+ -->
4+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
66
bootstrap="vendor/autoload.php"
7-
colors="true"
87
cacheResult="false"
8+
colors="true"
99
convertDeprecationsToExceptions="true">
1010
<testsuites>
11-
<testsuite name="MQ React Test Suite">
11+
<testsuite name="MQ Test Suite">
1212
<directory>./tests/</directory>
1313
</testsuite>
1414
</testsuites>
@@ -17,4 +17,12 @@
1717
<directory>./src/</directory>
1818
</include>
1919
</coverage>
20+
<php>
21+
<ini name="error_reporting" value="-1" />
22+
<!-- Evaluate assertions, requires running with "php -d zend.assertions=1 vendor/bin/phpunit" -->
23+
<!-- <ini name="zend.assertions" value="1" /> -->
24+
<ini name="assert.active" value="1" />
25+
<ini name="assert.exception" value="1" />
26+
<ini name="assert.bail" value="0" />
27+
</php>
2028
</phpunit>

phpunit.xml.legacy

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<!-- PHPUnit configuration file with old format for PHPUnit 9.2 or older -->
3+
<!-- PHPUnit configuration file with old format for legacy PHPUnit -->
44
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
66
bootstrap="vendor/autoload.php"
7-
colors="true"
8-
convertDeprecationsToExceptions="true">
7+
colors="true">
98
<testsuites>
10-
<testsuite name="MQ React Test Suite">
9+
<testsuite name="MQ Test Suite">
1110
<directory>./tests/</directory>
1211
</testsuite>
1312
</testsuites>
@@ -16,4 +15,12 @@
1615
<directory>./src/</directory>
1716
</whitelist>
1817
</filter>
18+
<php>
19+
<ini name="error_reporting" value="-1" />
20+
<!-- Evaluate assertions, requires running with "php -d zend.assertions=1 vendor/bin/phpunit" -->
21+
<!-- <ini name="zend.assertions" value="1" /> -->
22+
<ini name="assert.active" value="1" />
23+
<ini name="assert.exception" value="1" />
24+
<ini name="assert.bail" value="0" />
25+
</php>
1926
</phpunit>

src/Queue.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ public function __invoke()
363363
$queue[] = null;
364364
end($queue);
365365
$id = key($queue);
366+
assert(is_int($id));
366367

367368
$deferred = new Deferred(function ($_, $reject) use (&$queue, $id, &$deferred) {
368369
// forward cancellation to pending operation if it is currently executing
@@ -420,8 +421,8 @@ public function processQueue()
420421
return;
421422
}
422423

423-
/* @var $deferred Deferred */
424424
$deferred = reset($this->queue);
425+
assert($deferred instanceof Deferred);
425426
unset($this->queue[key($this->queue)]);
426427

427428
// once number of pending jobs is below concurrency limit again:

0 commit comments

Comments
 (0)