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:----rnJ8Q30i7Fye1XSb0KB3eWcJ4B3eqcDwQwmRy4596MNOEqVNLFeClIR0lT/Ldg29LxQvmS2z0RqIdka1Q1FQ/SL7gF09JHBsUTdteqCvKVYZZokegwOrmngnRr1LgJqoHn2JiTDf1WK9kYQFOWrhjJfJ3VJ4Ylau4D+7TlhdemeK6uQpI7E7bK/K2zvu3VOeayzsIhohPesj0eNL+Dnmi883RDTKkFN9ySaLHXAW3kCpcxtmVu3aLJZ4b6+LHvmc5c4zfw39Ls0cul4+CskxfRKZdXiQBL/R4jvRErDK0cjM+QufOM1eZUKt1FOKO43aRfLN0CgRrDzzQYIOAh2OTf524Cd2WBJb0ovkl9aG2Jo4v2fU4zT0ILdGPsR1bqT3/BQRPvlkbtOebhI9/BK1KkJX7mlFctF+O2SGXpheT3mJckpBk84sk4THhxGNgZG4UIv0gDjb4hvE3XSpgvhJ6mEHcoIgv8Ma4dcRvki4fcC17SIK4SFZDlmixtq8tKKt6I4QZvZCvlNP/pykqrNtG21PR4OyjY70cIo+FNxX+bKmn4rFM3+WVRWvc9WPZxrq4PZttndfIOhN/iPdDLPBlYyUDLyBhasPS8ZslcW+IJcUm5NN878ZZzJgWlhVOoe0u+pE0tUoI3qcQX/xgqgwhOq4AwRmX7jdh8v3GNIDFzE=----ATTACHMENT:----Njc3NTE2MzM0ODU2MjY0MyA2NDU2NjMzNTc1MjkwNzY1IDYyNTUwMjY5MTc4MTU3NzQ=