public function testApiHandleMessage_ClosesConnection_WhenHeadersAreInvalid()
{
$conn = $this->getMock(NetworkConnectionInterface::class, [], [], '', false);
$conn->httpBuffer = new Buffer();
$conn->httpHeadersReceived = false;
$mssg = new NetworkMessage($text = 'text');
$aware = $this->createAware();
$component = $this->createComponent();
$component->expects($this->never())->method('handleConnect');
$component->expects($this->never())->method('handleMessage');
$server = $this->createServer($aware, $component, ['close']);
$server->expects($this->once())->method('close')->with($conn, 413);
$driver = $this->createDriver();
$driver->expects($this->once())->method('readRequest')->with($conn->httpBuffer, $text)->will($this->throwException(new Exception()));
$server->handleMessage($conn, $mssg);
}