public function testPointerOffsetCanBeSet() { $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->assertIdenticalBinary(pack('C*', 0xd0, 0x94), $stream->read(1)); $stream->setPointer(0); $this->assertIdenticalBinary(pack('C*', 0xd0, 0x94), $stream->read(1)); $stream->setPointer(2); $this->assertIdenticalBinary(pack('C*', 0xd0, 0xbe), $stream->read(1)); }
public function testPointerOffsetCanBeSet() { $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->assertIdenticalBinary(pack('C*', 0xd0, 0x94), $stream->read(1)); $stream->setPointer(0); $this->assertIdenticalBinary(pack('C*', 0xd0, 0x94), $stream->read(1)); $stream->setPointer(2); $this->assertIdenticalBinary(pack('C*', 0xd0, 0xbe), $stream->read(1)); }