Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Checks an assertion
<?php assert(mixed $assertion, Throwable|string|null $description = null): bool
<?php $fd = self::getNextFreeFd();
$socket = stream_socket_server('127.0.0.1:0');
assert($socket !== false);
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
$loop->expects($this->once())->method('addReadStream');
<?php $fd = self::getNextFreeFd();
$tmpfile = tmpfile();
assert($tmpfile !== false);
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
$loop->expects($this->never())->method('addReadStream');
<?php $fd = self::getNextFreeFd();
$client = stream_socket_client('tcp://' . stream_socket_get_name($socket, false));
assert($client !== false);
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
$loop->expects($this->never())->method('addReadStream');
<?php $fd = self::getNextFreeFd();
$socket = stream_socket_server('127.0.0.1:0');
assert($socket !== false);
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
<?php $fd = self::getNextFreeFd();
$socket = stream_socket_server('127.0.0.1:0');
assert($socket !== false);
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
$loop->expects($this->once())->method('removeReadStream');
<?php $fd = self::getNextFreeFd();
$socket = stream_socket_server('127.0.0.1:0');
assert($socket !== false);
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
$loop->expects($this->once())->method('removeReadStream');
<?php $fd = self::getNextFreeFd();
$socket = stream_socket_server('127.0.0.1:0');
assert($socket !== false);
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
$loop->expects($this->once())->method('addReadStream');
<?php $fd = self::getNextFreeFd();
$socket = stream_socket_server('127.0.0.1:0');
assert($socket !== false);
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
$loop->expects($this->once())->method('removeReadStream');
<?php $fd = self::getNextFreeFd();
$socket = stream_socket_server('127.0.0.1:0');
assert($socket !== false);
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
$loop->expects($this->once())->method('removeReadStream');
<?php $fd = self::getNextFreeFd();
$socket = stream_socket_server('127.0.0.1:0');
assert($socket !== false);
$client = stream_socket_client('tcp://' . stream_socket_get_name($socket, false));
<?php $fd = self::getNextFreeFd();
$socket = stream_socket_server('127.0.0.1:0');
assert($socket !== false);
$server = new FdServer($fd, $loop);
<?php $this->assertLessThan(1, $time);
$this->assertInstanceOf('RuntimeException', $exception);
assert($exception instanceof \RuntimeException);
$this->assertStringStartsWith('Unable to accept new connection: ', $exception->getMessage());
return $exception;
<?php });
$this->assertInstanceOf('RuntimeException', $exception);
assert($exception instanceof \RuntimeException);
$this->assertEquals('Connection to tcp://reactphp.org:80 failed during DNS lookup: DNS lookup error', $exception->getMessage());
$this->assertEquals(0, $exception->getCode());
<?php });
$this->assertInstanceOf('RuntimeException', $exception);
assert($exception instanceof \RuntimeException);
$this->assertEquals('Connection to tcp://reactphp.org:80 failed during DNS lookup. Last error for IPv6: DNS6 error. Previous error for IPv4: DNS4 error', $exception->getMessage());
$this->assertEquals(0, $exception->getCode());
<?php });
$this->assertInstanceOf('RuntimeException', $exception);
assert($exception instanceof \RuntimeException);
$this->assertEquals('Connection to tcp://reactphp.org:80 failed: Last error for IPv6: Connection refused (ECONNREFUSED). Previous error for IPv4: DNS failed', $exception->getMessage());
$this->assertEquals(defined('SOCKET_ECONNREFUSED') ? SOCKET_ECONNREFUSED : 111, $exception->getCode());