PHP Classes

File: tests/StreamFactoryTest.php

Recommend this page to a friend!
  Classes of Robert Young   PHP Multiplexed I/O   tests/StreamFactoryTest.php   Download  
File: tests/StreamFactoryTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test for StreamFactory class
Class: PHP Multiplexed I/O
Manage multiple simultaneous network connections
Author: By
Last change: moved to tests directory
Date: 16 years ago
Size: 1,109 bytes
 

Contents

Class file image Download
<?php
require_once MIO_PATH . 'StreamFactory.php';

class
MioStreamFactoryTest extends UnitTestCase
{
    private
       
$factory;
    public function
setUp()
    {
       
$this->factory = new MioStreamFactory();
    }
    public function
tearDown()
    {
        unset(
$this->factory );
    }
    public function
testCreatingServerSocket()
    {
       
$stream = $this->factory->createServerStream( '127.0.0.1:8888' );
        if(
$stream instanceof MioStream ) {
           
$this->pass();
        }
    }
    public function
testCreatingFileStream()
    {
       
$stream = $this->factory->createFileStream( '/tmp/mytest', 'w+' );
        if(
$stream instanceof MioStream ) {
           
$this->pass();
        }
    }
    public function
testCreatingSocketStream()
    {
       
// we must first create something listening
       
$server = $this->factory->createServerStream( '127.0.0.1:8888' );
       
$stream = $this->factory->createSocketStream( '127.0.0.1', 8888 );
        if(
$stream instanceof MioStream ) {
           
$this->pass();
        }
    }
}