File: tests/stream-tests/StandardOutputStreamTest.php

Recommend this page to a friend!
  Classes of Maik Greubel  >  PHP Generics  >  tests/stream-tests/StandardOutputStreamTest.php  >  Download  
File: tests/stream-tests/StandardOutputStreamTest.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Generics
Framework for accessing streams, sockets and logs
Author: By
Last change: Test enhancement
Date: 1 year ago
Size: 1,396 bytes
 

Contents

Class file image Download
<?php
namespace Generics\Tests;

use
PHPUnit\Framework\TestCase;
use
Generics\Streams\Interceptor\CachedStreamInterceptor;
use
Generics\Streams\StandardOutputStream;

class
StandardOutputStreamTest extends TestCase
{
    public function
testOutputUsingInterceptor()
    {
       
$interceptor = new CachedStreamInterceptor();
       
$this->assertEmpty($interceptor->getCache());

       
$stdout = new StandardOutputStream();
       
$stdout->setInterceptor($interceptor);

       
$this->assertTrue($stdout->isOpen());
       
$this->assertTrue($stdout->isWriteable());
       
$this->assertTrue($stdout->ready());

       
$stdout->write("very important content");
       
$this->assertEquals("very important content", $interceptor->getCache());
       
$this->assertEquals(0, $stdout->count());

       
$stdout->flush();

       
$this->assertEmpty($interceptor->getCache());

       
$stdout->close();

       
$this->assertFalse($stdout->isOpen());
       
$this->assertFalse($stdout->isWriteable());
       
$this->assertFalse($stdout->ready());

       
$stdout->reset();

       
$this->assertTrue($stdout->isOpen());
       
$this->assertTrue($stdout->isWriteable());
       
$this->assertTrue($stdout->ready());
       
$this->assertEmpty($interceptor->getCache());

       
$stdout->write("second data");
       
$this->assertEquals("second data", $interceptor->getCache());
    }
}


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