@@ -103,21 +103,29 @@ public function testEncoding()
103
103
public function testCustomEncoderNeedsToRegisterFirst ()
104
104
{
105
105
$ this ->expectException (InvalidArgumentException::class);
106
- $ this ->expectExceptionMessage ('The encoding must be one of "quoted-printable", "base64", "8bit", "exception_test" ("upper_encoder" given). ' );
107
- TextPart::addEncoder ('exception_test ' , $ this ->createMock (ContentEncoderInterface::class));
108
- new TextPart ('content ' , 'utf-8 ' , 'plain ' , 'upper_encoder ' );
106
+ $ this ->expectExceptionMessage ('The encoding must be one of "quoted-printable", "base64", "8bit", "upper_encoder" ("this_encoding_does_not_exist" given). ' );
107
+
108
+ $ upperEncoder = $ this ->createMock (ContentEncoderInterface::class);
109
+ $ upperEncoder ->method ('getName ' )->willReturn ('upper_encoder ' );
110
+
111
+ TextPart::addEncoder ($ upperEncoder );
112
+ new TextPart ('content ' , 'utf-8 ' , 'plain ' , 'this_encoding_does_not_exist ' );
109
113
}
110
114
111
115
public function testOverwriteDefaultEncoder ()
112
116
{
113
117
$ this ->expectException (InvalidArgumentException::class);
114
118
$ this ->expectExceptionMessage ('You are not allowed to change the default encoders ("quoted-printable", "base64", and "8bit"). ' );
115
- TextPart::addEncoder ('8bit ' , $ this ->createMock (ContentEncoderInterface::class));
119
+
120
+ $ base64Encoder = $ this ->createMock (ContentEncoderInterface::class);
121
+ $ base64Encoder ->method ('getName ' )->willReturn ('base64 ' );
122
+
123
+ TextPart::addEncoder ($ base64Encoder );
116
124
}
117
125
118
126
public function testCustomEncoding ()
119
127
{
120
- TextPart::addEncoder (' upper_encoder ' , new class implements ContentEncoderInterface {
128
+ TextPart::addEncoder (new class implements ContentEncoderInterface {
121
129
public function encodeByteStream ($ stream , int $ maxLineLength = 0 ): iterable
122
130
{
123
131
$ filter = stream_filter_append ($ stream , 'string.toupper ' , \STREAM_FILTER_READ );
0 commit comments