public function dataTransferred()
 {
     $out = new MemoryOutputStream();
     $s = new StreamTransfer(new MemoryInputStream('Hello'), $out);
     $s->transferAll();
     $this->assertEquals('Hello', $out->getBytes());
 }
 public function multipeWrites()
 {
     $out = new MemoryOutputStream();
     $stream = new Base64OutputStream($out);
     $stream->write('Hello');
     $stream->write(' ');
     $stream->write('World');
     $stream->close();
     $this->assertEquals(base64_encode('Hello World'), $out->getBytes());
 }
 public function equalsSign()
 {
     $out = new MemoryOutputStream();
     $stream = new QuotedPrintableOutputStream($out);
     $stream->write('A=1');
     $stream->close();
     $this->assertEquals('A=3D1', $out->getBytes());
 }
 public function writeLinef()
 {
     $stream = new StringWriter($out = new MemoryOutputStream());
     $stream->writeLinef('This %s the %d line', 'is', 1);
     $this->assertEquals("This is the 1 line\n", $out->getBytes());
 }
 /**
  * Send a frame to server
  *
  */
 public function sendFrame(org·codehaus·stomp·frame·Frame $frame)
 {
     // Trace
     if ($this->cat) {
         $mo = new MemoryOutputStream();
         $frame->write(new StringWriter($mo));
         $this->cat->debug($this->getClassName(), '>>>', $mo->getBytes());
     }
     $frame->write($this->out);
     if ($frame->requiresImmediateResponse()) {
         return $this->recvFrame();
     }
     return NULL;
 }
示例#6
0
 /**
  * Asserts a given output stream contains the given bytes       
  *
  * @param   io.streams.MemoryOutputStream m
  * @param   string bytes
  * @throws  unittest.AssertionFailedError
  */
 protected function assertOnStream(MemoryOutputStream $m, $bytes, $message = 'Not contained')
 {
     strstr($m->getBytes(), $bytes) || $this->fail($message, $m->getBytes(), $bytes);
 }
 public function writePng()
 {
     $s = new MemoryOutputStream();
     $this->image->saveTo(new PngStreamWriter($s));
     $this->assertNotEmpty($s->getBytes());
 }