-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathServerFactoryTest.php
More file actions
45 lines (37 loc) · 1.25 KB
/
ServerFactoryTest.php
File metadata and controls
45 lines (37 loc) · 1.25 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
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Runtime\React\Tests;
use PHPUnit\Framework\TestCase;
use Psr\Http\Server\RequestHandlerInterface;
use React\EventLoop\Loop;
use React\EventLoop\LoopInterface;
use Runtime\React\ServerFactory;
class ServerFactoryTest extends TestCase
{
private RequestHandlerInterface $handler;
private LoopInterface $loop;
public function setUp(): void
{
parent::setUp();
$this->handler = $this->createMock(RequestHandlerInterface::class);
$this->loop = $this->createMock(LoopInterface::class);
$this->loop->expects($this->never())->method('run');
Loop::set($this->loop);
}
public function testCreateServerWithDefaultOptions(): void
{
$factory = new ServerFactory();
$loop = $factory->createServer($this->handler);
self::assertInstanceOf(LoopInterface::class, $loop);
self::assertSame(ServerFactory::getDefaultOptions(), $factory->getOptions());
}
public function testCreateServerWithOptions(): void
{
$options = [
'host' => '0.0.0.0',
'port' => '9999',
];
$factory = new ServerFactory($options);
$factory->createServer($this->handler);
self::assertSame($options, $factory->getOptions());
}
}