Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
joedixon committed Nov 27, 2023
1 parent 7b7222d commit 41055fb
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/spec-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ jobs:
crossbario/autobahn-testsuite \
wstest -m fuzzingclient -s /mnt/autobahn/client-spec.json
- name: Set workflow status based on Autobahn exit status
run: exit $?
- name: Analyze test results
working-directory: tests/Specification
run: php spec-analyze.php
Empty file.
33 changes: 33 additions & 0 deletions tests/Specification/spec-analyze.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Ratchet\RFC6455\Test;

use Illuminate\Support\Arr;

require __DIR__.'/../../vendor/autoload.php';

$hasFailures = false;

if (! file_exists($file = __DIR__.'/reports/index.json')) {
echo 'No test results found.'.PHP_EOL;

exit(1);
}

$results = file_get_contents($file);
$results = Arr::first(json_decode($results, true));

foreach ($results as $name => $result) {
if ($result['behavior'] === 'INFORMATIONAL') {
continue;
}

if (in_array($result['behavior'], ['OK', 'NON-STRICT'])) {
echo '✅ Test case '.$name.' passed.'.PHP_EOL;
} else {
$hasFailures = true;
echo '❌ Test case '.$name.' failed.'.PHP_EOL;
}
}

exit($hasFailures ? 1 : 0);
9 changes: 4 additions & 5 deletions tests/Specification/spec-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
use Laravel\Reverb\WebSockets\WsConnection;
use Psr\Http\Message\RequestInterface;
use React\EventLoop\Loop;
use React\Http\HttpServer;
use React\Socket\SocketServer;
use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RouteCollection;

require __DIR__ . '/vendor/autoload.php';
require __DIR__.'/../../vendor/autoload.php';

$loop = Loop::get();
$socket = new SocketServer("0.0.0.0:8080", [], $loop);
$socket = new SocketServer('0.0.0.0:8080', [], $loop);
$router = new Router(new UrlMatcher(routes(), new RequestContext));

$server = new Server($socket, $router, $loop);
Expand All @@ -28,7 +27,7 @@ function routes()
{
$routes = new RouteCollection;
$routes->add(
'sockets',
'sockets',
Route::get('/', function (RequestInterface $request, WsConnection $connection) {
$connection->onMessage(function ($message) use ($connection) {
$connection->send($message);
Expand All @@ -39,4 +38,4 @@ function routes()
);

return $routes;
}
}

0 comments on commit 41055fb

Please sign in to comment.