PHP Classes

File: test/Helpers/SocketTestConnection.php

Recommend this page to a friend!
  Classes of Artur Graniszewski  >  ZEUS for PHP  >  test/Helpers/SocketTestConnection.php  >  Download  
File: test/Helpers/SocketTestConnection.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: ZEUS for PHP
Manage the execution of multiple parallel tasks
Author: By
Last change: Removed ReactPHP from ZEUS code
Memcached server switched to ZEUS socket server + test fixes
Improvements to Socket Server, moved network layer to Kernel and used SocketStream in FIFO IPC
Date: 3 years ago
Size: 3,432 bytes
 

Contents

Class file image Download
<?php

namespace ZeusTest\Helpers;

use
Zeus\Kernel\Networking\ConnectionInterface;
use
Zeus\Kernel\Networking\FlushableConnectionInterface;

class
SocketTestConnection implements ConnectionInterface, FlushableConnectionInterface
{
    protected
$dataSent = null;

    protected
$isConnectionClosed = false;

    protected
$isConnectionWritable = true;

    protected
$remoteAddress = '127.0.0.2:7071';

    protected
$serverAddress = '127.0.0.1:7070';

   
/**
     * Send data to the connection
     * @param string $data
     * @return ConnectionInterface
     */
   
public function write($data)
    {
       
$this->dataSent .= $data;
    }

   
/**
     * Close the connection
     * @param mixed[] $data
     */
   
public function end($data = [])
    {
       
$this->isConnectionClosed = true;
    }

    public function
getRemoteAddress()
    {
        return
$this->remoteAddress;
    }

    public function
getServerAddress()
    {
        return
$this->serverAddress;
    }

   
/**
     * @param null $dataSent
     * @return $this
     */
   
public function setDataSent($dataSent)
    {
       
$this->dataSent = $dataSent;

        return
$this;
    }

   
/**
     * @param boolean $isConnectionClosed
     * @return $this
     */
   
public function setIsConnectionClosed($isConnectionClosed)
    {
       
$this->isConnectionClosed = $isConnectionClosed;

        return
$this;
    }

   
/**
     * @param string $remoteAddress
     * @return $this
     */
   
public function setRemoteAddress($remoteAddress)
    {
       
$this->remoteAddress = $remoteAddress;

        return
$this;
    }

   
/**
     * @param string $serverAddress
     * @return $this
     */
   
public function setServerAddress($serverAddress)
    {
       
$this->serverAddress = $serverAddress;

        return
$this;
    }

   
/**
     * @return null|string
     */
   
public function getSentData()
    {
       
$data = $this->dataSent;
       
$this->dataSent = '';

        return
$data;
    }

   
/**
     * @return bool
     */
   
public function isConnectionClosed()
    {
        return
$this->isConnectionClosed;
    }

    public function
isReadable()
    {
       
// TODO: Implement isReadable() method.
   
}

    public function
close()
    {
       
// TODO: Implement close() method.
   
}

    public function
isWritable()
    {
        return
$this->isConnectionWritable;
    }

   
/**
     * @param bool $isConnectionWritable
     * @return $this
     */
   
public function setIsConnectionWritable($isConnectionWritable)
    {
       
$this->isConnectionWritable = $isConnectionWritable;

        return
$this;
    }

    public function
__construct($stream)
    {

    }

    public function
read($ending = false)
    {
       
// TODO: Implement read() method.
   
}

   
/**
     * @param int $timeout
     * @return bool
     */
   
public function select($timeout)
    {
       
// TODO: Implement select() method.
   
}

    public function
flush()
    {
       
// TODO: Implement flush() method.
   
}

    public function
setWriteBufferSize($size)
    {
       
// TODO: Implement setWriteBufferSize() method.
   
}

    public function
setReadBufferSize($size)
    {
       
// TODO: Implement setReadBufferSize() method.
   
}
}


For more information send a message to info at phpclasses dot org.