|
102 | 102 | expect($result)->toEqual($expected); |
103 | 103 | }); |
104 | 104 |
|
105 | | -test('decodeUtf7Imap decodes UTF-7 encoded folder names', function () { |
| 105 | +test('fromImapUtf7 decodes UTF-7 encoded folder names', function () { |
106 | 106 | // Russian Cyrillic example from the bug report. |
107 | 107 | $encoded = '&BBoEPgRABDcEOAQ9BDA-'; |
108 | 108 | $decoded = 'Корзина'; |
109 | 109 |
|
110 | | - expect(Str::decodeUtf7Imap($encoded))->toBe($decoded); |
| 110 | + expect(Str::fromImapUtf7($encoded))->toBe($decoded); |
111 | 111 | }); |
112 | 112 |
|
113 | | -test('decodeUtf7Imap handles non-encoded strings', function () { |
| 113 | +test('fromImapUtf7 handles non-encoded strings', function () { |
114 | 114 | $plainString = 'INBOX'; |
115 | 115 |
|
116 | | - expect(Str::decodeUtf7Imap($plainString))->toBe($plainString); |
| 116 | + expect(Str::fromImapUtf7($plainString))->toBe($plainString); |
117 | 117 | }); |
118 | 118 |
|
119 | | -test('decodeUtf7Imap handles special characters', function () { |
| 119 | +test('fromImapUtf7 handles special characters', function () { |
120 | 120 | // Ampersand is represented as &- in UTF-7. |
121 | 121 | $encoded = '&-'; |
122 | 122 | $decoded = '&'; |
123 | 123 |
|
124 | | - expect(Str::decodeUtf7Imap($encoded))->toBe($decoded); |
| 124 | + expect(Str::fromImapUtf7($encoded))->toBe($decoded); |
125 | 125 | }); |
126 | 126 |
|
127 | | -test('decodeUtf7Imap handles mixed content', function () { |
| 127 | +test('fromImapUtf7 handles mixed content', function () { |
128 | 128 | // Test that the function doesn't modify the non-encoded part. |
129 | 129 | $encoded = 'Hello &-'; |
130 | 130 | $decoded = 'Hello &'; |
131 | 131 |
|
132 | | - expect(Str::decodeUtf7Imap($encoded))->toBe($decoded); |
| 132 | + expect(Str::fromImapUtf7($encoded))->toBe($decoded); |
133 | 133 | }); |
134 | 134 |
|
135 | | -test('decodeUtf7Imap preserves existing UTF-8 characters', function () { |
| 135 | +test('fromImapUtf7 preserves existing UTF-8 characters', function () { |
136 | 136 | // Test with various UTF-8 characters that should remain unchanged. |
137 | 137 | $utf8String = 'Привет мир 你好 こんにちは ñáéíóú'; |
138 | 138 |
|
139 | 139 | // The function should return the string unchanged since it's already UTF-8. |
140 | | - expect(Str::decodeUtf7Imap($utf8String))->toBe($utf8String); |
| 140 | + expect(Str::fromImapUtf7($utf8String))->toBe($utf8String); |
141 | 141 |
|
142 | 142 | // Test with a mix of UTF-8 and regular ASCII. |
143 | 143 | $mixedString = 'Hello Привет 123'; |
144 | | - expect(Str::decodeUtf7Imap($mixedString))->toBe($mixedString); |
| 144 | + expect(Str::fromImapUtf7($mixedString))->toBe($mixedString); |
| 145 | +}); |
| 146 | + |
| 147 | +test('toImapUtf7 encodes plain ASCII as-is', function () { |
| 148 | + $input = 'Inbox'; |
| 149 | + $expected = 'Inbox'; |
| 150 | + |
| 151 | + expect(Str::toImapUtf7($input))->toBe($expected); |
| 152 | +}); |
| 153 | + |
| 154 | +test('toImapUtf7 encodes ampersand correctly', function () { |
| 155 | + $input = 'Inbox & Archive'; |
| 156 | + $expected = 'Inbox &- Archive'; |
| 157 | + |
| 158 | + expect(Str::toImapUtf7($input))->toBe($expected); |
| 159 | +}); |
| 160 | + |
| 161 | +test('toImapUtf7 encodes non-ASCII characters', function () { |
| 162 | + $input = 'Корзина'; // Russian for "Trash" |
| 163 | + $expected = '&BBoEPgRABDcEOAQ9BDA-'; |
| 164 | + |
| 165 | + expect(Str::toImapUtf7($input))->toBe($expected); |
| 166 | +}); |
| 167 | + |
| 168 | +test('toImapUtf7 encodes mixed content correctly', function () { |
| 169 | + $input = 'Work Корзина & Stuff'; |
| 170 | + $expected = 'Work &BBoEPgRABDcEOAQ9BDA- &- Stuff'; |
| 171 | + |
| 172 | + expect(Str::toImapUtf7($input))->toBe($expected); |
145 | 173 | }); |
0 commit comments