11<?php
22
3+ use DirectoryTree \ImapEngine \Connection \ImapConnection ;
4+ use DirectoryTree \ImapEngine \Exceptions \ImapCapabilityException ;
35use DirectoryTree \ImapEngine \Folder ;
46use DirectoryTree \ImapEngine \Mailbox ;
57
5052 // The name should remain unchanged.
5153 expect ($ mixedFolder ->name ())->toBe ($ mixedUtf8FolderName );
5254});
55+
56+ test ('it returns quota data for the mailbox ' , function () {
57+ $ mailbox = Mailbox::make ([
58+ 'username ' => 'foo ' ,
59+ 'password ' => 'bar ' ,
60+ ]);
61+
62+ $ mailbox ->connect (ImapConnection::fake ([
63+ '* OK Welcome to IMAP ' ,
64+ 'TAG1 OK Logged in ' ,
65+ '* LIST ( \\HasNoChildren) "/" "INBOX" ' ,
66+ 'TAG2 OK LIST completed ' ,
67+ '* CAPABILITY IMAP4rev1 LITERAL+ UIDPLUS SORT IDLE MOVE QUOTA ' ,
68+ 'TAG3 OK CAPABILITY completed ' ,
69+ '* QUOTA "INBOX" (STORAGE 54 512) ' ,
70+ '* QUOTA "INBOX" (MESSAGE 12 1024) ' ,
71+ 'TAG4 OK GETQUOTAROOT completed ' ,
72+ ]));
73+
74+ expect ($ mailbox ->inbox ()->quota ())
75+ ->toBeArray ()
76+ ->toHaveKeys (['STORAGE ' , 'MESSAGE ' , 'usage ' , 'limit ' ])
77+ ->toMatchArray ([
78+ 'STORAGE ' => [
79+ 'usage ' => 54 ,
80+ 'limit ' => 512 ,
81+ ],
82+ 'MESSAGE ' => [
83+ 'usage ' => 12 ,
84+ 'limit ' => 1024 ,
85+ ],
86+ 'usage ' => 54 ,
87+ 'limit ' => 512 ,
88+ ]);
89+ });
90+
91+ test ('it throws an imap capability exception when inspecting quotas when the imap server does not support quotas ' , function () {
92+ $ mailbox = Mailbox::make ([
93+ 'username ' => 'foo ' ,
94+ 'password ' => 'bar ' ,
95+ ]);
96+
97+ $ mailbox ->connect (ImapConnection::fake ([
98+ '* OK Welcome to IMAP ' ,
99+ 'TAG1 OK Logged in ' ,
100+ '* LIST ( \\HasNoChildren) "/" "INBOX" ' ,
101+ 'TAG2 OK LIST completed ' ,
102+ '* CAPABILITY IMAP4rev1 LITERAL+ UIDPLUS SORT IDLE MOVE ' ,
103+ 'TAG3 OK CAPABILITY completed ' ,
104+ '* QUOTA "INBOX" (STORAGE 54 512) ' ,
105+ '* QUOTA "INBOX" (MESSAGE 12 1024) ' ,
106+ 'TAG4 OK GETQUOTAROOT completed ' ,
107+ ]));
108+
109+ $ mailbox ->inbox ()->quota ();
110+ })->throws (ImapCapabilityException::class);
0 commit comments