readBytes() public method

Read $length characters from the stream and return a 1-dimensional array containing there octet values.
public readBytes ( integer $length ) : integer[]
$length integer
return integer[]
 public function testRequestingByteArrayCountPastEndOfStream()
 {
     $reader = $this->_getReader();
     $factory = $this->_getFactory($reader);
     $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8');
     $seq = $this->_mockery()->sequence('read-sequence');
     $this->_checking(Expectations::create()->ignoring($reader)->getInitialByteSize()->returns(1)->one($reader)->validateByteSequence(array(0xd0), 1)->inSequence($seq)->returns(1)->one($reader)->validateByteSequence(array(0xd0), 1)->inSequence($seq)->returns(1)->one($reader)->validateByteSequence(array(0xd0), 1)->inSequence($seq)->returns(1));
     $stream->importString(pack('C*', 0xd0, 0x94, 0xd0, 0xb6, 0xd0, 0xbe));
     $this->assertEqual(array(0xd0, 0x94, 0xd0, 0xb6, 0xd0, 0xbe), $stream->readBytes(100));
     $this->assertIdentical(false, $stream->readBytes(1));
 }
コード例 #2
0
 public function testRequestingByteArrayCountPastEndOfStream()
 {
     $reader = $this->_getReader();
     $factory = $this->_getFactory($reader);
     $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8');
     $reader->shouldReceive('getInitialByteSize')->zeroOrMoreTimes()->andReturn(1);
     $reader->shouldReceive('validateByteSequence')->once()->with(array(0xd0), 1)->andReturn(1);
     $reader->shouldReceive('validateByteSequence')->once()->with(array(0xd0), 1)->andReturn(1);
     $reader->shouldReceive('validateByteSequence')->once()->with(array(0xd0), 1)->andReturn(1);
     $stream->importString(pack('C*', 0xd0, 0x94, 0xd0, 0xb6, 0xd0, 0xbe));
     $this->assertEquals(array(0xd0, 0x94, 0xd0, 0xb6, 0xd0, 0xbe), $stream->readBytes(100));
     $this->assertSame(false, $stream->readBytes(1));
 }