blob: 6611352a1dbdf5b062d3064178475de9f58dea42 (
plain) (
blame)
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
|
<?php
namespace React\Tests\Socket;
use Clue\React\Block;
use React\EventLoop\Factory;
use React\Socket\Connector;
use React\Socket\TcpServer;
class FunctionalConnectorTest extends TestCase
{
const TIMEOUT = 1.0;
/** @test */
public function connectionToTcpServerShouldSucceedWithLocalhost()
{
$loop = Factory::create();
$server = new TcpServer(9998, $loop);
$server->on('connection', $this->expectCallableOnce());
$server->on('connection', array($server, 'close'));
$connector = new Connector($loop);
$connection = Block\await($connector->connect('localhost:9998'), $loop, self::TIMEOUT);
$this->assertInstanceOf('React\Socket\ConnectionInterface', $connection);
$connection->close();
$server->close();
}
}
|