diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 6a3ef8a..4accda4 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,10 +9,12 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest ] - php: [ 7.4, 8.0, 8.1 ] - laravel: [ 6.*, 7.*, 8.*, 9.* ] + php: [ 7.4, 8.0, 8.1, 8.2 ] + laravel: [ 6.*, 7.*, 8.*, 9.*, 10.* ] dependency-version: [ prefer-stable ] include: + - testbench: 8.* + laravel: 10.* - testbench: 7.* laravel: 9.* - testbench: 6.* @@ -26,8 +28,16 @@ jobs: laravel: 6.* - php: 8.1 laravel: 7.* + - php: 8.2 + laravel: 6.* + - php: 8.2 + laravel: 7.* - php: 7.4 laravel: 9.* + - php: 7.4 + laravel: 10.* + - php: 8.0 + laravel: 10.* name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} diff --git a/composer.json b/composer.json index 1ac5443..b82fc65 100644 --- a/composer.json +++ b/composer.json @@ -21,13 +21,13 @@ ], "require": { "php": "^7.4|^8.0", - "illuminate/broadcasting": "~6.0|~7.0|~8.0|~9.0", + "illuminate/broadcasting": "~6.0|~7.0|~8.0|~9.0|~10.0", "lcobucci/jwt": "~4.0", "symfony/mercure": "~0.4" }, "require-dev": { "larapack/dd": "^1.0", - "orchestra/testbench": "~4.0|~5.0|~6.0|~7.0", + "orchestra/testbench": "~4.0|~5.0|~6.0|~7.0|~8.0", "phpunit/phpunit": "^9.3", "symfony/process": "~4.4|~5.0|~6.0" }, diff --git a/tests/Feature/BroadcasterTest.php b/tests/Feature/BroadcasterTest.php index f8285de..df2abee 100644 --- a/tests/Feature/BroadcasterTest.php +++ b/tests/Feature/BroadcasterTest.php @@ -10,15 +10,29 @@ class BroadcasterTest extends TestCase { private $mercureDockerContainerId; - public function test_it_broadcasts() + /** + * @dataProvider supportedMercureVersionsDataProvider + */ + public function test_it_broadcasts($mercureVersion) { + $this->startMercureServer($mercureVersion); event(new ExampleEvent('example data')); $this->assertMercureDockerLog(function ($log) { - return strpos($log, '\"POST /.well-known/mercure HTTP/1.1\" 200 45"') > 0; + return strpos($log, '\"POST /.well-known/mercure HTTP/1.1\" 200 45"') > 0 + || (strpos($log, '"uri": "/.well-known/mercure"') > 0 && strpos($log, '"status": 200') > 0); }); } + public function supportedMercureVersionsDataProvider() + { + yield ['v0.11']; + yield ['v0.12']; + yield ['v0.13']; + yield ['v0.14']; + yield ['latest']; + } + private function assertMercureDockerLog(callable $matcher) { try { @@ -28,22 +42,24 @@ private function assertMercureDockerLog(callable $matcher) ->getErrorOutput(); if (!$matcher($output)) { - throw new \Exception; + throw new \Exception($output); }; return true; }, 100); } catch (\Exception $exception) { $result = false; + dump($exception->getMessage()); } + $this->assertTrue($result); } - /** @before */ - public function startMercureServer() + /** before */ + public function startMercureServer($version) { - $command = "docker run -e SERVER_NAME=':80' -e MERCURE_PUBLISHER_JWT_KEY='!ChangeMe!' -e MERCURE_SUBSCRIBER_JWT_KEY='!ChangeMe!' -d -p 3000:80 dunglas/mercure"; + $command = "docker run -e SERVER_NAME=':80' -e MERCURE_PUBLISHER_JWT_KEY='bfaf06ec-ac9d-11ed-a49f-6bc3bc0854c9' -e MERCURE_SUBSCRIBER_JWT_KEY='bfaf06ec-ac9d-11ed-a49f-6bc3bc0854c9' -d -p 3000:80 dunglas/mercure:$version"; $this->mercureDockerContainerId = Process::fromShellCommandline($command) ->mustRun() diff --git a/tests/TestCase.php b/tests/TestCase.php index cbca5a2..ce5c7d1 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -11,7 +11,7 @@ protected function getEnvironmentSetUp($app) $app['config']->set('broadcasting.default', 'mercure'); $app['config']->set('broadcasting.connections.mercure.driver', 'mercure'); $app['config']->set('broadcasting.connections.mercure.url', 'http://localhost:3000/.well-known/mercure'); - $app['config']->set('broadcasting.connections.mercure.secret', '!ChangeMe!'); + $app['config']->set('broadcasting.connections.mercure.secret', 'bfaf06ec-ac9d-11ed-a49f-6bc3bc0854c9'); } /**