|
| 1 | +<?php |
| 2 | + |
| 3 | +use DirectoryTree\ImapEngine\Connection\Responses\TaggedResponse; |
| 4 | +use DirectoryTree\ImapEngine\Connection\Tokens\Atom; |
| 5 | + |
| 6 | +test('tag', function () { |
| 7 | + $response = new TaggedResponse([ |
| 8 | + new Atom('a'), |
| 9 | + new Atom('b'), |
| 10 | + new Atom('c'), |
| 11 | + ]); |
| 12 | + |
| 13 | + expect($response->tag())->toEqual( |
| 14 | + new Atom('a') |
| 15 | + ); |
| 16 | +}); |
| 17 | + |
| 18 | +test('status', function () { |
| 19 | + $response = new TaggedResponse([ |
| 20 | + new Atom('a'), |
| 21 | + new Atom('b'), |
| 22 | + new Atom('c'), |
| 23 | + ]); |
| 24 | + |
| 25 | + expect($response->status())->toEqual([ |
| 26 | + new Atom('b'), |
| 27 | + ]); |
| 28 | +}); |
| 29 | + |
| 30 | +test('data', function () { |
| 31 | + $response = new TaggedResponse([ |
| 32 | + new Atom('a'), |
| 33 | + new Atom('b'), |
| 34 | + new Atom('c'), |
| 35 | + ]); |
| 36 | + |
| 37 | + expect($response->data())->toEqual([ |
| 38 | + new Atom('c'), |
| 39 | + ]); |
| 40 | +}); |
| 41 | + |
| 42 | +test('successful', function () { |
| 43 | + $response = new TaggedResponse([ |
| 44 | + new Atom('a'), |
| 45 | + new Atom('OK'), |
| 46 | + ]); |
| 47 | + |
| 48 | + expect($response->successful())->toBeTrue(); |
| 49 | + |
| 50 | + $response = new TaggedResponse([ |
| 51 | + new Atom('a'), |
| 52 | + new Atom('NO'), |
| 53 | + ]); |
| 54 | + |
| 55 | + expect($response->successful())->toBeFalse(); |
| 56 | + |
| 57 | + $response = new TaggedResponse([ |
| 58 | + new Atom('a'), |
| 59 | + new Atom('BAD'), |
| 60 | + ]); |
| 61 | + |
| 62 | + expect($response->successful())->toBeFalse(); |
| 63 | +}); |
| 64 | + |
| 65 | +test('failed', function () { |
| 66 | + $response = new TaggedResponse([ |
| 67 | + new Atom('a'), |
| 68 | + new Atom('OK'), |
| 69 | + ]); |
| 70 | + |
| 71 | + expect($response->failed())->toBeFalse(); |
| 72 | + |
| 73 | + $response = new TaggedResponse([ |
| 74 | + new Atom('a'), |
| 75 | + new Atom('NO'), |
| 76 | + ]); |
| 77 | + |
| 78 | + expect($response->failed())->toBeTrue(); |
| 79 | + |
| 80 | + $response = new TaggedResponse([ |
| 81 | + new Atom('a'), |
| 82 | + new Atom('BAD'), |
| 83 | + ]); |
| 84 | + |
| 85 | + expect($response->failed())->toBeTrue(); |
| 86 | +}); |
0 commit comments