/** * @covers Brickoo\Component\IO\Printing\BufferedPrinter::doPrint * @covers Brickoo\Component\IO\Printing\StreamBufferedPrinter::getStreamWriter */ public function testStreamWriteResourceIsRefreshed() { $stream = new FileStream(new FileStreamConfig("php://memory", FileStream::MODE_READ + FileStream::MODE_WRITE)); $streamPrinter = new StreamBufferedPrinter($stream, strlen("test")); $streamPrinter->doPrint("test"); $streamPrinter->doPrint("Case"); $streamPrinter->flushBuffer(); fseek($stream->open(), 0); $this->assertSame("testCase", fgets($stream->open())); $stream->close(); }
/** * @covers Brickoo\Component\IO\Stream\FileStream::close * @covers Brickoo\Component\IO\Stream\FileStream::open * @covers Brickoo\Component\IO\Stream\FileStream::hasResource */ public function testOpenAndCloseFileStream() { $fileStream = new FileStream($this->getFileStreamConfigurationFixture()); $this->assertInternalType("resource", $fileStream->open()); $fileStream->close(); $this->assertAttributeEquals(null, "resource", $fileStream); }