コード例 #1
0
 public function testWrite()
 {
     $stream = new Yamdi_OutputStream($this->testFileName);
     /* writing bytes */
     $stream->write('321');
     /* passing input source through */
     $inputStream = new Yamdi_InputStream($this->passthroughFileName);
     $stream->passthrough($inputStream, 3);
     $inputStream->close();
     /* checking writen data */
     $fh = fopen($this->testFileName, 'r');
     $bytes = fread($fh, 6 + 1);
     // reading beyond the eof
     $this->assertTrue(feof($fh));
     $this->assertEqual($bytes, '321abc');
     fclose($fh);
     $stream->close();
 }
コード例 #2
0
 public function testWriteAndPassthroughFromPosition()
 {
     $stream = new Yamdi_OutputStream($this->outtputFileName);
     // writing bytes
     $stream->write('321');
     // passing input source through
     $inputStream = new Yamdi_InputStream($this->inputFileName);
     $stream->passthrough($inputStream, 3);
     $inputStream->close();
     // reading written file back
     $fh = fopen($this->outtputFileName, 'r');
     $bytes = fread($fh, 6 + 1);
     // reading until the eof
     // assert file length is 6 bytes
     $this->assertTrue(feof($fh));
     // assert writen 3 bytes from $stream->write() and 3 bytes from $stream->passthrough()
     $this->assertEquals($bytes, '321abc');
     fclose($fh);
     $stream->close();
 }