Exemplo n.º 1
0
 public function testProxyMethods()
 {
     $input = $this->getMockBuilder('ZerusTech\\Component\\IO\\Stream\\Input\\AbstractInputStream')->setMethods(['input', 'available', 'mark', 'markSupported', 'reset', 'close'])->getMock();
     $instance = new FilterInputStream($input);
     $data = "hello";
     $input->expects($this->exactly(2))->method('input')->will($this->returnCallback(function (&$bytes, $length) use(&$data) {
         $bytes = substr($data, 0, $length);
         $data = substr($data, $length);
         return 0 === strlen($bytes) ? -1 : strlen($bytes);
     }));
     $input->expects($this->once())->method('available')->willReturn(strlen($data));
     $input->expects($this->once())->method('mark')->with(5)->will($this->returnSelf());
     $input->expects($this->once())->method('markSupported')->willReturn(false);
     $input->expects($this->once())->method('reset')->will($this->returnSelf());
     $input->expects($this->once())->method('close')->will($this->returnSelf());
     $this->assertEquals(5, $instance->available());
     $this->assertSame($instance, $instance->mark(5));
     $this->assertFalse($instance->markSupported());
     $this->assertSame($instance, $instance->reset());
     $this->assertEquals(1, $instance->skip(1));
     $this->assertEquals(4, $this->input->invokeArgs($instance, [&$bytes, 4]));
     $this->assertEquals('ello', $bytes);
     $this->assertFalse($instance->isClosed());
     $this->assertSame($instance, $instance->close());
     $this->assertTrue($instance->isClosed());
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function close()
 {
     parent::close();
     $this->buffer = '';
     return $this;
 }