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:----PJEzguBQ2c1kIVOASlN8FugZK76gFCxojX2kn/pp7I6MhpCSTTtfkBiJzxx3ypBAo1gmTKPAxLmBMl/XcDED7+IiwNkR8DwtYIg6mudAw2npJ0yMtwsH/ZGp3ha80Mpfz81D8qFW4nVgCzgjZxKWWuGwd5n1oVfuTqKR0967YvQjd0WRsJCkJ67Sh8KccStlJxEX0VX1thOoU6HdMUPy2KiaekK/b1USpFqawAdMmjZ8gz1BvV1SZ5ZymWQNH0ktmNSdHd4JSTlyTq3tElM7pr50Hsk/YBAQitVGthS1qgEdtmuX8sHi74WHRFIOswv1WSVwYcPQyKkmKDmMRzTw35U3CUI3R/qLMXTu75CGg2/VWtAJtPe5edkw+eAxFbS6mTiswdpwPsoq5bvvabmuOwUvsazJNxostubYk7E7eJmAslClLxNl4Er4cBX9hHtYtSdBjwFLbUq3OhseWgRnC5Z/EGc0iKjve1do0gJ0s/PjzJwqOkDXGHFKMGNk8JUuogcXO2yM5LsoA5LGZANl9skzp2PX8UncJw/5SKwSrNnAAJe+fG4vmwFKugLU/oAmchOa/d3z9amKrO86e+dV6HGn9ZKUw3ltBCSg0CVJSbqdOvOdW00oX+TYVku0aKyJ4FIH608zTB8fWJOL8NuNMS9sfY4tjw3xuFTYi5wrl8s=----ATTACHMENT:----MjM1MjgxNTA2MTQwODgyMSA3MjkyNDQ5NzY5OTE4NDcwIDI5MjYzNDYyMTQwOTk2MQ==