Skip to content

Commit 63fa674

Browse files
committed
fix: serve command not working, add test scaffolding
1 parent 5d2a8f0 commit 63fa674

File tree

8 files changed

+82
-5
lines changed

8 files changed

+82
-5
lines changed

extensions/realtime/composer.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,19 @@
6868
"kyrne/websocket": "*"
6969
},
7070
"scripts": {
71-
"analyse:phpstan": "phpstan analyse",
72-
"clear-cache:phpstan": "phpstan clear-result-cache"
71+
"test": [
72+
"@test:unit",
73+
"@test:integration"
74+
],
75+
"test:unit": "phpunit -c tests/phpunit.unit.xml",
76+
"test:integration": "phpunit -c tests/phpunit.integration.xml",
77+
"test:setup": "@php tests/integration/setup.php"
7378
},
7479
"scripts-descriptions": {
75-
"analyse:phpstan": "Run static analysis"
80+
"test": "Runs all tests.",
81+
"test:unit": "Runs all unit tests.",
82+
"test:integration": "Runs all integration tests.",
83+
"test:setup": "Sets up a database for use with integration tests. Execute this only once."
7684
},
7785
"require-dev": {
7886
"fof/best-answer": "^2.0.0-beta",

extensions/realtime/resources/routes/websocket.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* LICENSE file that was distributed with this source code.
88
*/
99

10-
use Blomstra\Realtime\Websocket\Connection;
11-
use Blomstra\Realtime\Websocket\Logger\WebsocketLogger;
10+
use Flarum\Realtime\Websocket\Connection;
11+
use Flarum\Realtime\Websocket\Logger\WebsocketLogger;
1212
use Ratchet\WebSocket\MessageComponentInterface;
1313
use Ratchet\WebSocket\WsServer;
1414
use Symfony\Component\Routing\Route;

extensions/realtime/src/Websocket/Console/ServeCommand.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@ protected function loggers(): void
110110

111111
public function errorHandler(int $errno, string $errstr, string $errfile, int $errline): bool
112112
{
113+
// Don't throw exceptions for deprecation notices, warnings, or notices in debug mode
114+
// Just log them to output instead
115+
if (in_array($errno, [E_DEPRECATED, E_USER_DEPRECATED, E_NOTICE, E_USER_NOTICE])) {
116+
if ($this->option('debug')) {
117+
$this->warn("[$errno] $errstr in $errfile:$errline");
118+
}
119+
return true;
120+
}
121+
122+
// Throw exceptions for actual errors
113123
throw new \Exception("$errno, $errstr, $errfile:$errline");
114124
}
115125

extensions/realtime/tests/fixtures/.gitkeep

Whitespace-only changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
/*
4+
* This file is part of Flarum.
5+
*
6+
* For detailed copyright and license information, please view the
7+
* LICENSE file that was distributed with this source code.
8+
*/
9+
10+
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
11+
12+
$setup->run();
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
5+
backupGlobals="false"
6+
cacheDirectory=".phpunit.cache"
7+
backupStaticProperties="false"
8+
colors="true"
9+
processIsolation="true"
10+
stopOnFailure="false"
11+
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
12+
>
13+
<source>
14+
<include>
15+
<directory suffix=".php">../src/</directory>
16+
</include>
17+
</source>
18+
<testsuites>
19+
<testsuite name="Flarum Integration Tests">
20+
<directory suffix="Test.php">./integration</directory>
21+
<exclude>./integration/tmp</exclude>
22+
</testsuite>
23+
</testsuites>
24+
</phpunit>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
5+
backupGlobals="false"
6+
cacheDirectory=".phpunit.cache"
7+
backupStaticProperties="false"
8+
colors="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
12+
>
13+
<source>
14+
<include>
15+
<directory suffix=".php">../src/</directory>
16+
</include>
17+
</source>
18+
<testsuites>
19+
<testsuite name="Flarum Unit Tests">
20+
<directory suffix="Test.php">./unit</directory>
21+
</testsuite>
22+
</testsuites>
23+
</phpunit>

extensions/realtime/tests/unit/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)