write() public method

Write $chars to the end of the stream.
public write ( string $chars )
$chars string
コード例 #1
0
 public function testCharactersCanBeReadAsByteArrays()
 {
     $reader = $this->_getReader();
     $factory = $this->_getFactory($reader);
     $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8');
     $reader->shouldReceive('getInitialByteSize')->zeroOrMoreTimes()->andReturn(1);
     //String
     $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
     $reader->shouldReceive('validateByteSequence')->once()->with(array(0xd0), 1)->andReturn(1);
     $reader->shouldReceive('validateByteSequence')->once()->with(array(0xd1), 1)->andReturn(1);
     $reader->shouldReceive('validateByteSequence')->once()->with(array(0xd0), 1)->andReturn(1);
     $reader->shouldReceive('validateByteSequence')->once()->with(array(0xd1), 1)->andReturn(1);
     $reader->shouldReceive('validateByteSequence')->once()->with(array(0xd1), 1)->andReturn(1);
     $stream->importString(pack('C*', 0xd0, 0x94, 0xd0, 0xb6, 0xd0, 0xbe));
     $stream->write(pack('C*', 0xd0, 0xbb, 0xd1, 0x8e, 0xd0, 0xb1, 0xd1, 0x8b, 0xd1, 0x85));
     $this->assertEquals(array(0xd0, 0x94), $stream->readBytes(1));
     $this->assertEquals(array(0xd0, 0xb6, 0xd0, 0xbe), $stream->readBytes(2));
     $this->assertEquals(array(0xd0, 0xbb), $stream->readBytes(1));
     $this->assertEquals(array(0xd1, 0x8e, 0xd0, 0xb1, 0xd1, 0x8b), $stream->readBytes(3));
     $this->assertEquals(array(0xd1, 0x85), $stream->readBytes(1));
     $this->assertSame(false, $stream->readBytes(1));
 }
 public function testCharactersCanBeReadAsByteArrays()
 {
     $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)->one($reader)->validateByteSequence(array(0xd0), 1)->inSequence($seq)->returns(1)->one($reader)->validateByteSequence(array(0xd1), 1)->inSequence($seq)->returns(1)->one($reader)->validateByteSequence(array(0xd0), 1)->inSequence($seq)->returns(1)->one($reader)->validateByteSequence(array(0xd1), 1)->inSequence($seq)->returns(1)->one($reader)->validateByteSequence(array(0xd1), 1)->inSequence($seq)->returns(1));
     $stream->importString(pack('C*', 0xd0, 0x94, 0xd0, 0xb6, 0xd0, 0xbe));
     $stream->write(pack('C*', 0xd0, 0xbb, 0xd1, 0x8e, 0xd0, 0xb1, 0xd1, 0x8b, 0xd1, 0x85));
     $this->assertEqual(array(0xd0, 0x94), $stream->readBytes(1));
     $this->assertEqual(array(0xd0, 0xb6, 0xd0, 0xbe), $stream->readBytes(2));
     $this->assertEqual(array(0xd0, 0xbb), $stream->readBytes(1));
     $this->assertEqual(array(0xd1, 0x8e, 0xd0, 0xb1, 0xd1, 0x8b), $stream->readBytes(3));
     $this->assertEqual(array(0xd1, 0x85), $stream->readBytes(1));
     $this->assertIdentical(false, $stream->readBytes(1));
 }