|
151 | 151 |
|
152 | 152 | test('parses quota response', function () { |
153 | 153 | $stream = new FakeStream; |
154 | | - |
155 | 154 | $stream->open(); |
156 | 155 |
|
157 | 156 | $stream->feed([ |
|
173 | 172 | expect($response2->tokens())->toHaveCount(4); |
174 | 173 | expect((string) $response2)->toBe('TAG1 OK GETQUOTA completed'); |
175 | 174 | }); |
| 175 | + |
| 176 | +test('parses response tokens', function (array|string $feed, string $type, string $value) { |
| 177 | + $stream = new FakeStream; |
| 178 | + $stream->open(); |
| 179 | + |
| 180 | + $stream->feed($feed); |
| 181 | + |
| 182 | + $tokenizer = new ImapTokenizer($stream); |
| 183 | + $parser = new ImapParser($tokenizer); |
| 184 | + $response = $parser->next(); |
| 185 | + |
| 186 | + expect($response)->toBeInstanceOf($type); |
| 187 | + expect((string) $response)->toBe($value); |
| 188 | +})->with([ |
| 189 | + ['()', ListData::class, '()'], |
| 190 | + ['(A B C)', ListData::class, '(A B C)'], |
| 191 | + [['{0}', ''], Literal::class, "{0}\r\n"], |
| 192 | + ['(A (B C) D)', ListData::class, '(A (B C) D)'], |
| 193 | + [['{5}', 'Hello'], Literal::class, "{5}\r\nHello"], |
| 194 | + ['((A) (B (C)))', ListData::class, '((A) (B (C)))'], |
| 195 | + ['"Hello, world!"', QuotedString::class, '"Hello, world!"'], |
| 196 | + [['{12}', 'Hello', 'Bye'], Literal::class, "{12}\r\nHello\r\nBye\r\n"], |
| 197 | + ['* OK Dovecot ready.', UntaggedResponse::class, '* OK Dovecot ready.'], |
| 198 | + ['* 2 FETCH (UID 102)', UntaggedResponse::class, '* 2 FETCH (UID 102)'], |
| 199 | + ['TAG1 OK FETCH completed', TaggedResponse::class, 'TAG1 OK FETCH completed'], |
| 200 | + [ |
| 201 | + '* QUOTA "#user/testuser" (STORAGE 512 1024)', |
| 202 | + UntaggedResponse::class, '* QUOTA "#user/testuser" (STORAGE 512 1024)', |
| 203 | + ], |
| 204 | + ['* SEARCH 1 2 3', UntaggedResponse::class, '* SEARCH 1 2 3'], |
| 205 | + ['A007 NO [ALERT] System busy', TaggedResponse::class, 'A007 NO [ALERT] System busy'], |
| 206 | + [ |
| 207 | + [ |
| 208 | + '* 1 FETCH (BODY {14}', |
| 209 | + 'Hello World!', |
| 210 | + ')', |
| 211 | + ], |
| 212 | + UntaggedResponse::class, |
| 213 | + "* 1 FETCH (BODY {14}\r\nHello World!\r\n)", |
| 214 | + ], |
| 215 | +]); |
0 commit comments