Skip to content

Commit

Permalink
add swoole test
Browse files Browse the repository at this point in the history
  • Loading branch information
shellphy committed Jun 25, 2024
1 parent 6379c88 commit 2623540
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"suggest": {
"ext-msgpack": "MessagePack codec support",
"ext-protobuf": "Protobuf codec support",
"ext-swoole": "Swoole gocoroutine support",
"rybakit/msgpack": "(^0.7) MessagePack codec support",
"google/protobuf": "(^3.0) Protobuf codec support"
},
Expand Down
5 changes: 5 additions & 0 deletions src/RelayInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ public function waitFrame(): Frame;
* @param Frame $frame
*/
public function send(Frame $frame): void;

/**
* @return int
*/
public function getNextSeq(): int;
}
50 changes: 50 additions & 0 deletions tests/Goridge/SwooleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare(strict_types=1);

namespace Spiral\Goridge\Tests;

use Swoole\Coroutine as Co;
use Swoole\Coroutine\Barrier;

class SwooleTest extends RPCTest
{
public function testNoExceptionWithSwooleCoroutine(): void
{
Co::set(['hook_flags'=> SWOOLE_HOOK_ALL]);
Co\run(function () {
$methods = [
'testManualConnect',
'testReconnect',
'testPingPong',
'testPrefixPingPong',
'testPingNull',
'testNegate',
'testNegateNegative',
'testLongEcho',
'testRawBody',
'testPayload',
'testPayloadWithMap',

// 'testBrokenPayloadMap',
// 'testJsonException'
// 'testInvalidService',
// 'testInvalidMethod',
// 'testConvertException',
// 'testBadPayload',

// 'testLongRawBody',
];

foreach ($methods as $method) {
$barrier = Barrier::make();
for ($i = 0; $i < 2; $i++) {
go(function () use ($barrier, $method) {
$this->$method();
});
}
Barrier::wait($barrier);
}
});
}
}

0 comments on commit 2623540

Please sign in to comment.