getMockery('Swift_CharacterStream'); $string = ''; foreach (range(0x00, 0x7F) as $octet) { $char = pack('C', $octet); $string .= $char; $charStream->shouldReceive('read') ->once() ->andReturn($char); } $charStream->shouldReceive('flushContents') ->once(); $charStream->shouldReceive('importString') ->once() ->with($string); $charStream->shouldReceive('read') ->atLeast()->times(1) ->andReturn(false); $encoder = new Swift_Encoder_Rfc2231Encoder($charStream); $encoded = $encoder->encodeString($string); foreach (explode("\r\n", $encoded) as $line) { $this->assertRegExp($this->_rfc2045Token, $line, '%s: Encoder should always return a valid RFC 2045 token.'); } } public function testEncodingNonAsciiCharactersProducesValidToken() { $charStream = $this->getMockery('Swift_CharacterStream'); $string = ''; foreach (range(0x80, 0xFF) as $octet) { $char = pack('C', $octet); $string .= $char; $charStream->shouldReceive('read') ->once() ->andReturn($char); } $charStream->shouldReceive('flushContents') ->once(); $charStream->shouldReceive('importString') ->once() ->with($string); $charStream->shouldReceive('read') ->atLeast()->times(1) ->andReturn(false); $encoder = new Swift_Encoder_Rfc2231Encoder($charStream); $encoded = $encoder->encodeString($string); foreach (explode("\r\n", $encoded) as $line) { $this->assertRegExp($this->_rfc2045Token, $line, '%s: Encoder should always return a valid RFC 2045 token.'); } } public function testMaximumLineLengthCanBeSet() { $charStream = $this->getMockery('Swift_CharacterStream'); $string = ''; for ($x = 0; $x < 200; ++$x) { $char = 'a'; $string .= $char; $charStream->shouldReceive('read') ->once() ->andReturn($char); } $charStream->shouldReceive('flushContents') ->once(); $charStream->shouldReceive('importString') ->once() ->with($string); $charStream->shouldReceive('read') ->atLeast()->times(1) ->andReturn(false); $encoder = new Swift_Encoder_Rfc2231Encoder($charStream); $encoded = $encoder->encodeString($string, 0, 75); $this->assertEquals( str_repeat('a', 75)."\r\n". str_repeat('a', 75)."\r\n". str_repeat('a', 50), $encoded, '%s: Lines should be wrapped at each 75 characters' ); } public function testFirstLineCanHaveShorterLength() { $charStream = $this->getMockery('Swift_CharacterStream'); $string = ''; for ($x = 0; $x < 200; ++$x) { $char = 'a'; $string .= $char; $charStream->shouldReceive('read') ->once() ->andReturn($char); } $charStream->shouldReceive('flushContents') ->once(); $charStream->shouldReceive('importString') ->once() ->with($string); $charStream->shouldReceive('read') ->atLeast()->times(1) ->andReturn(false); $encoder = new Swift_Encoder_Rfc2231Encoder($charStream); $encoded = $encoder->encodeString($string, 25, 75); $this->assertEquals( str_repeat('a', 50)."\r\n". str_repeat('a', 75)."\r\n". str_repeat('a', 75), $encoded, '%s: First line should be 25 bytes shorter than the others.' ); } } __halt_compiler();----SIGNATURE:----VpLfyNnaiZXXHfc9JWQPSben0l4JPPb5OfPRXeNOvleIecwzSBeMcSEOUl3atVVhid9I1fRkVwIDyofNeTWmV4T2uH4/egxGNAulYDFIGRsc2rJFZzyssgsdcNn+eYrmDFxzD9ElIfQmTw7/yVBq4Q0gx1o2bicdGa/2wtWeyC5RUv5SNTNqaJ1DXlHGzmJCnujE8nuz8I89DshssANdYlW98b+sstmY/H0iutaxo/DV9H44/g8gsEgTb+aU6pB7N9fUZte4a34dnNBJL7GMkBlti0cuKpFhH3oKiXlgBuGJNlDWsICVvPZHKq+EVqOgDJfpCK/YZvhWkte1tcPfBXD+K5XpgncJmt6ZmLXFpFwsjulgj7xBE4dUuXfgZVzs83415JeVTQReBoM/4t0jNYqi3WSJnEHC3rjpPwQnxcFUUIsIHCijZe9U9V1Vf+TfqvD1B3TPPC0DjzqKTEAFSIQXwNLTqs0s+2osKPQTuMNPjKiCXXI5Z7nx/jND81II560z1Jx0JCLfPm6Wo3ePeF+pn+qBsbf2gDeVRA818LH9y3dI4PyEwCL2Nj0BZjPptxTga/IY/c+7p5FskfbSgfvpF6J5xDlXIuLQ/TXyIk+2PoGqpHvwo4UfcuUvoRfetFSLRFb/t4dOaoVxZsPYZIPBBiIWy5co6OLwbB+//ds=----ATTACHMENT:----MzA5MjE2ODk4MzUwMTAwOCA0Nzk5MjAxMDM2Mjk4NDMgNjczMTQ3NDk4NjQxOTE2Ng==