Skip to content

Commit

Permalink
👷 Add support for Laravel 10 and PHP 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanduijker committed Feb 14, 2023
1 parent a0c0d0b commit 1fbfa75
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand All @@ -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 }}

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
28 changes: 22 additions & 6 deletions tests/Feature/BroadcasterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down

0 comments on commit 1fbfa75

Please sign in to comment.