diff --git a/.gitattributes b/.gitattributes
index a353f44..404fd5d 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -3,4 +3,5 @@
/.gitignore export-ignore
/examples/ export-ignore
/phpunit.xml.dist export-ignore
+/phpunit.xml.legacy export-ignore
/tests/ export-ignore
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 438fcc4..f8b1999 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -7,7 +7,7 @@ on:
jobs:
PHPUnit:
name: PHPUnit (PHP ${{ matrix.php }})
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-22.04
strategy:
matrix:
php:
@@ -20,10 +20,13 @@ jobs:
- 5.4
- 5.3
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
- run: composer install
- run: vendor/bin/phpunit --coverage-text
+ if: ${{ matrix.php >= 7.3 }}
+ - run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy
+ if: ${{ matrix.php < 7.3 }}
diff --git a/README.md b/README.md
index 58eb26c..fd0774a 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# clue/sse-react
-[](https://github.com/clue/php-sse-react/actions)
+[](https://github.com/clue/php-sse-react/actions)
[](https://packagist.org/packages/clue/sse-react)
Streaming, async HTML5 Server-Sent Events server (aka. SSE or EventSource), built on top of [React PHP](http://reactphp.org/).
@@ -13,7 +13,11 @@ See the [examples](examples).
## Install
-The recommended way to install this library is [through composer](http://getcomposer.org). [New to composer?](http://getcomposer.org/doc/00-intro.md)
+The recommended way to install this library is [through Composer](https://getcomposer.org/).
+[New to Composer?](https://getcomposer.org/doc/00-intro.md)
+
+Once released, this project will follow [SemVer](https://semver.org/).
+At the moment, this will install the latest development version:
```JSON
{
@@ -23,21 +27,25 @@ The recommended way to install this library is [through composer](http://getcomp
}
```
+This project aims to run on any platform and thus does not require any PHP
+extensions and supports running on legacy PHP 5.3 through PHP 7.3.
+It's *highly recommended to use the latest supported PHP version* for this project.
+
## Tests
To run the test suite, you first need to clone this repo and then install all
-dependencies [through Composer](http://getcomposer.org):
+dependencies [through Composer](http://getcomposer.org/):
```bash
-$ composer install
+composer install
```
To run the test suite, go to the project root and run:
```bash
-$ php vendor/bin/phpunit
+php vendor/bin/phpunit
```
## License
-MIT
+MIT, see [LICENSE file](LICENSE).
diff --git a/composer.json b/composer.json
index 5da0c8d..c6c7278 100644
--- a/composer.json
+++ b/composer.json
@@ -10,9 +10,6 @@
"email": "christian@lueck.tv"
}
],
- "autoload": {
- "psr-4": { "Clue\\React\\Sse\\": "src/" }
- },
"require": {
"php": ">=5.3",
"react/event-loop": "^1.0",
@@ -21,6 +18,16 @@
},
"require-dev": {
"clue/redis-react": "^2.4",
- "phpunit/phpunit": "^5.0 || ^4.8"
+ "phpunit/phpunit": "^9.6 || ^7.5 || ^4.8.36"
+ },
+ "autoload": {
+ "psr-4": {
+ "Clue\\React\\Sse\\": "src/"
+ }
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "Clue\\React\\Tests\\Sse\\": "tests/"
+ }
}
}
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 4633355..2c1a022 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,19 +1,23 @@
-
+
+ convertDeprecationsToExceptions="true">
./tests/
-
-
+
+
./src/
-
-
-
\ No newline at end of file
+
+
+
+
+
+
diff --git a/phpunit.xml.legacy b/phpunit.xml.legacy
new file mode 100644
index 0000000..c9978bd
--- /dev/null
+++ b/phpunit.xml.legacy
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+ ./tests/
+
+
+
+
+ ./src/
+
+
+
+
+
+
diff --git a/tests/BufferedChannelTest.php b/tests/BufferedChannelTest.php
index 2cd4cdb..639bd3f 100644
--- a/tests/BufferedChannelTest.php
+++ b/tests/BufferedChannelTest.php
@@ -1,5 +1,7 @@
encoder = new Encoder();
}
diff --git a/tests/TestCase.php b/tests/TestCase.php
new file mode 100644
index 0000000..66af970
--- /dev/null
+++ b/tests/TestCase.php
@@ -0,0 +1,32 @@
+createCallableMock();
+
+ $mock
+ ->expects($this->once())
+ ->method('__invoke');
+
+ return $mock;
+ }
+
+ protected function createCallableMock()
+ {
+ if (method_exists('PHPUnit\Framework\MockObject\MockBuilder', 'addMethods')) {
+ // PHPUnit 9+
+ return $this->getMockBuilder('stdClass')->addMethods(array('__invoke'))->getMock();
+ } else {
+ // legacy PHPUnit 4 - PHPUnit 8
+ return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
+ }
+ }
+}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
deleted file mode 100644
index 572fa88..0000000
--- a/tests/bootstrap.php
+++ /dev/null
@@ -1,34 +0,0 @@
-createCallableMock();
-
- $mock
- ->expects($this->once())
- ->method('__invoke');
-
- return $mock;
- }
-
- /**
- * @link https://github.com/reactphp/react/blob/master/tests/React/Tests/Socket/TestCase.php (taken from reactphp/react)
- */
- protected function createCallableMock()
- {
- return $this->getMockBuilder('CallableStub')->getMock();
- }
-}
-
-class CallableStub
-{
- public function __invoke()
- {
- }
-}