Author: Chris Corbyn
Inheritance: extends Swift_Encoder_QpEncoder, implements Swift_Mime_ContentEncoder
 public function testEncodingAndDecodingSamples()
 {
     $sampleFp = opendir($this->_samplesDir);
     while (false !== ($encodingDir = readdir($sampleFp))) {
         if (substr($encodingDir, 0, 1) == '.') {
             continue;
         }
         $encoding = $encodingDir;
         $charStream = new Swift_CharacterStream_NgCharacterStream($this->_factory, $encoding);
         $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream);
         $sampleDir = $this->_samplesDir . '/' . $encodingDir;
         if (is_dir($sampleDir)) {
             $fileFp = opendir($sampleDir);
             while (false !== ($sampleFile = readdir($fileFp))) {
                 if (substr($sampleFile, 0, 1) == '.') {
                     continue;
                 }
                 $text = file_get_contents($sampleDir . '/' . $sampleFile);
                 $os = new Swift_ByteStream_ArrayByteStream();
                 $os->write($text);
                 $is = new Swift_ByteStream_ArrayByteStream();
                 $encoder->encodeByteStream($os, $is);
                 $encoded = '';
                 while (false !== ($bytes = $is->read(8192))) {
                     $encoded .= $bytes;
                 }
                 $this->assertEquals(quoted_printable_decode($encoded), $text, '%s: Encoded string should decode back to original string for sample ' . $sampleDir . '/' . $sampleFile);
             }
             closedir($fileFp);
         }
     }
     closedir($sampleFp);
 }
 /**
  * {@inheritdoc}
  */
 public function charsetChanged($charset)
 {
     $this->charset = $charset;
     $this->safeEncoder->charsetChanged($charset);
 }
 public function testObserverInterfaceCanChangeCharset()
 {
     $stream = $this->_createCharacterStream();
     $stream->shouldReceive('setCharacterSet')->once()->with('windows-1252');
     $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($stream);
     $encoder->charsetChanged('windows-1252');
 }
 public function testObserverInterfaceCanChangeCharset()
 {
     $stream = $this->_createCharacterStream();
     $this->_checking(Expectations::create()->one($stream)->setCharacterSet('windows-1252')->ignoring($stream));
     $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($stream);
     $encoder->charsetChanged('windows-1252');
 }