-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathCallableRunnerTest.php
More file actions
34 lines (25 loc) · 1.11 KB
/
CallableRunnerTest.php
File metadata and controls
34 lines (25 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
declare(strict_types=1);
namespace Runtime\Swoole\Tests\Unit;
use PHPUnit\Framework\TestCase;
use Runtime\Swoole\CallableRunner;
use Runtime\Swoole\ServerFactory;
use Runtime\Swoole\SwooleServerEventListenerInterface;
use Swoole\Http\Server;
class CallableRunnerTest extends TestCase
{
public function testRun(): void
{
$eventListener = $this->createMock(SwooleServerEventListenerInterface::class);
$application = static function (): void {
};
$server = $this->createMock(Server::class);
$server->expects(self::once())->method('start');
$server->expects(self::exactly(8))->method('on')->with($this->anything(), $this->anything());
$factory = $this->createMock(ServerFactory::class);
$factory->expects(self::once())->method('createServer')->with(self::equalTo($application))->willReturn($server);
$factory->expects(self::once())->method('getOptions')->willReturn(['server_event_listener_factory' => fn () => $eventListener]);
$runner = new CallableRunner($factory, $application);
self::assertSame(0, $runner->run());
}
}