7373
7474 expect ($ mailbox ->inbox ()->quota ())
7575 ->toBeArray ()
76- ->toHaveKeys (['STORAGE ' , 'MESSAGE ' , 'usage ' , 'limit ' ])
7776 ->toMatchArray ([
78- 'STORAGE ' => [
79- 'usage ' => 54 ,
80- 'limit ' => 512 ,
77+ 'INBOX ' => [
78+ 'STORAGE ' => [
79+ 'usage ' => 54 ,
80+ 'limit ' => 512 ,
81+ ],
82+ 'MESSAGE ' => [
83+ 'usage ' => 12 ,
84+ 'limit ' => 1024 ,
85+ ],
8186 ],
82- 'MESSAGE ' => [
83- 'usage ' => 12 ,
84- 'limit ' => 1024 ,
87+ ]);
88+ });
89+
90+ test ('it returns quota data for the mailbox when there are no quotas ' , function () {
91+ $ mailbox = Mailbox::make ([
92+ 'username ' => 'foo ' ,
93+ 'password ' => 'bar ' ,
94+ ]);
95+
96+ $ mailbox ->connect (ImapConnection::fake ([
97+ '* OK Welcome to IMAP ' ,
98+ 'TAG1 OK Logged in ' ,
99+ '* LIST ( \\HasNoChildren) "/" "INBOX" ' ,
100+ 'TAG2 OK LIST completed ' ,
101+ '* CAPABILITY IMAP4rev1 LITERAL+ UIDPLUS SORT IDLE MOVE QUOTA ' ,
102+ 'TAG3 OK CAPABILITY completed ' ,
103+ 'TAG4 OK GETQUOTAROOT completed ' ,
104+ ]));
105+
106+ expect ($ mailbox ->inbox ()->quota ())->toBe ([]);
107+ });
108+
109+ test ('it returns quota data for the mailbox when there are multiple resources ' , function () {
110+ $ mailbox = Mailbox::make ([
111+ 'username ' => 'foo ' ,
112+ 'password ' => 'bar ' ,
113+ ]);
114+
115+ $ mailbox ->connect (ImapConnection::fake ([
116+ '* OK Welcome to IMAP ' ,
117+ 'TAG1 OK Logged in ' ,
118+ '* LIST ( \\HasNoChildren) "/" "INBOX" ' ,
119+ 'TAG2 OK LIST completed ' ,
120+ '* CAPABILITY IMAP4rev1 LITERAL+ UIDPLUS SORT IDLE MOVE QUOTA ' ,
121+ 'TAG3 OK CAPABILITY completed ' ,
122+ '* QUOTA "FOO" (STORAGE 54 512) ' ,
123+ '* QUOTA "FOO" (MESSAGE 12 1024) ' ,
124+ '* QUOTA "BAR" (STORAGE 10 1024) ' ,
125+ '* QUOTA "BAR" (MESSAGE 5 1024) ' ,
126+ 'TAG4 OK GETQUOTAROOT completed ' ,
127+ ]));
128+
129+ expect ($ mailbox ->inbox ()->quota ())
130+ ->toBeArray ()
131+ ->toMatchArray ([
132+ 'FOO ' => [
133+ 'STORAGE ' => [
134+ 'usage ' => 54 ,
135+ 'limit ' => 512 ,
136+ ],
137+ 'MESSAGE ' => [
138+ 'usage ' => 12 ,
139+ 'limit ' => 1024 ,
140+ ],
141+ ],
142+ 'BAR ' => [
143+ 'STORAGE ' => [
144+ 'usage ' => 10 ,
145+ 'limit ' => 1024 ,
146+ ],
147+ 'MESSAGE ' => [
148+ 'usage ' => 5 ,
149+ 'limit ' => 1024 ,
150+ ],
151+ ],
152+ ]);
153+ });
154+
155+ test ('it returns quota data for the mailbox when there are multiple resources in the same list data ' , function () {
156+ $ mailbox = Mailbox::make ([
157+ 'username ' => 'foo ' ,
158+ 'password ' => 'bar ' ,
159+ ]);
160+
161+ $ mailbox ->connect (ImapConnection::fake ([
162+ '* OK Welcome to IMAP ' ,
163+ 'TAG1 OK Logged in ' ,
164+ '* LIST ( \\HasNoChildren) "/" "INBOX" ' ,
165+ 'TAG2 OK LIST completed ' ,
166+ '* CAPABILITY IMAP4rev1 LITERAL+ UIDPLUS SORT IDLE MOVE QUOTA ' ,
167+ 'TAG3 OK CAPABILITY completed ' ,
168+ '* QUOTA "FOO" (STORAGE 54 512 MESSAGE 12 1024) ' ,
169+ '* QUOTA "BAR" (STORAGE 10 1024 MESSAGE 5 1024) ' ,
170+ 'TAG4 OK GETQUOTAROOT completed ' ,
171+ ]));
172+
173+ expect ($ mailbox ->inbox ()->quota ())
174+ ->toBeArray ()
175+ ->toMatchArray ([
176+ 'FOO ' => [
177+ 'STORAGE ' => [
178+ 'usage ' => 54 ,
179+ 'limit ' => 512 ,
180+ ],
181+ 'MESSAGE ' => [
182+ 'usage ' => 12 ,
183+ 'limit ' => 1024 ,
184+ ],
185+ ],
186+ 'BAR ' => [
187+ 'STORAGE ' => [
188+ 'usage ' => 10 ,
189+ 'limit ' => 1024 ,
190+ ],
191+ 'MESSAGE ' => [
192+ 'usage ' => 5 ,
193+ 'limit ' => 1024 ,
194+ ],
85195 ],
86- 'usage ' => 54 ,
87- 'limit ' => 512 ,
88196 ]);
89197});
90198
101209 'TAG2 OK LIST completed ' ,
102210 '* CAPABILITY IMAP4rev1 LITERAL+ UIDPLUS SORT IDLE MOVE ' ,
103211 'TAG3 OK CAPABILITY completed ' ,
104- '* QUOTA "INBOX" (STORAGE 54 512) ' ,
105- '* QUOTA "INBOX" (MESSAGE 12 1024) ' ,
106- 'TAG4 OK GETQUOTAROOT completed ' ,
107212 ]));
108213
109214 $ mailbox ->inbox ()->quota ();
110- })->throws (ImapCapabilityException::class);
215+ })->throws (ImapCapabilityException::class);
0 commit comments