@@ -42,7 +42,7 @@ protected function setUp(): void {
4242 $ this ->mapper = new FolderMapper ();
4343 }
4444
45- public function testGetFoldersEmtpyAccount () {
45+ public function testGetFoldersEmtpyAccount (): void {
4646 $ account = $ this ->createMock (Account::class);
4747 $ client = $ this ->createMock (Horde_Imap_Client_Socket::class);
4848 $ client ->expects ($ this ->once ())
@@ -52,6 +52,7 @@ public function testGetFoldersEmtpyAccount() {
5252 'delimiter ' => true ,
5353 'attributes ' => true ,
5454 'special_use ' => true ,
55+ 'status ' => Horde_Imap_Client::STATUS_ALL ,
5556 ]))
5657 ->willReturn ([]);
5758
@@ -60,7 +61,7 @@ public function testGetFoldersEmtpyAccount() {
6061 $ this ->assertEquals ([], $ folders );
6162 }
6263
63- public function testGetFolders () {
64+ public function testGetFolders (): void {
6465 $ account = $ this ->createMock (Account::class);
6566 $ account ->method ('getId ' )->willReturn (27 );
6667 $ client = $ this ->createMock (Horde_Imap_Client_Socket::class);
@@ -71,32 +72,39 @@ public function testGetFolders() {
7172 'delimiter ' => true ,
7273 'attributes ' => true ,
7374 'special_use ' => true ,
75+ 'status ' => Horde_Imap_Client::STATUS_ALL ,
7476 ]))
7577 ->willReturn ([
7678 [
7779 'mailbox ' => new Horde_Imap_Client_Mailbox ('INBOX ' ),
7880 'attributes ' => [],
7981 'delimiter ' => '. ' ,
82+ 'status ' => [
83+ 'unseen ' => 0 ,
84+ ],
8085 ],
8186 [
8287 'mailbox ' => new Horde_Imap_Client_Mailbox ('Sent ' ),
8388 'attributes ' => [
8489 '\sent ' ,
8590 ],
8691 'delimiter ' => '. ' ,
92+ 'status ' => [
93+ 'unseen ' => 1 ,
94+ ],
8795 ],
8896 ]);
8997 $ expected = [
90- new Folder (27 , new Horde_Imap_Client_Mailbox ('INBOX ' ), [], '. ' ),
91- new Folder (27 , new Horde_Imap_Client_Mailbox ('Sent ' ), ['\sent ' ], '. ' ),
98+ new Folder (27 , new Horde_Imap_Client_Mailbox ('INBOX ' ), [], '. ' , [ ' unseen ' => 0 ] ),
99+ new Folder (27 , new Horde_Imap_Client_Mailbox ('Sent ' ), ['\sent ' ], '. ' , [ ' unseen ' => 1 ] ),
92100 ];
93101
94102 $ folders = $ this ->mapper ->getFolders ($ account , $ client );
95103
96104 $ this ->assertEquals ($ expected , $ folders );
97105 }
98106
99- public function testCreateFolder () {
107+ public function testCreateFolder (): void {
100108 $ account = $ this ->createMock (Account::class);
101109 $ account ->method ('getId ' )->willReturn (42 );
102110 $ client = $ this ->createMock (Horde_Imap_Client_Socket::class);
@@ -110,90 +118,25 @@ public function testCreateFolder() {
110118 'delimiter ' => true ,
111119 'attributes ' => true ,
112120 'special_use ' => true ,
121+ 'status ' => Horde_Imap_Client::STATUS_ALL ,
113122 ]))
114123 ->willReturn ([
115124 [
116125 'mailbox ' => new Horde_Imap_Client_Mailbox ('new ' ),
117126 'attributes ' => [],
118127 'delimiter ' => '. ' ,
128+ 'status ' => [
129+ 'unseen ' => 0 ,
130+ ],
119131 ],
120132 ]);
121133
122134 $ created = $ this ->mapper ->createFolder ($ client , $ account , 'new ' );
123135
124- $ expected = new Folder (42 , new Horde_Imap_Client_Mailbox ('new ' ), [], '. ' );
136+ $ expected = new Folder (42 , new Horde_Imap_Client_Mailbox ('new ' ), [], '. ' , [ ' unseen ' => 0 ] );
125137 $ this ->assertEquals ($ expected , $ created );
126138 }
127139
128- public function testGetFoldersStatus () {
129- $ folders = [
130- $ this ->createMock (Folder::class),
131- ];
132- $ client = $ this ->createMock (Horde_Imap_Client_Socket::class);
133- $ folders [0 ]->expects ($ this ->any ())
134- ->method ('getMailbox ' )
135- ->willReturn ('folder1 ' );
136- $ folders [0 ]->expects ($ this ->once ())
137- ->method ('getAttributes ' )
138- ->willReturn ([]);
139- $ client ->expects ($ this ->once ())
140- ->method ('status ' )
141- ->with ($ this ->equalTo (['folder1 ' ]))
142- ->willReturn ([
143- 'folder1 ' => [
144- 'total ' => 123
145- ],
146- ]);
147- $ folders [0 ]->expects ($ this ->once ())
148- ->method ('setStatus ' );
149-
150- $ this ->mapper ->getFoldersStatus ($ folders , $ client );
151- }
152-
153- public function testGetFoldersStatusNoStatusReported () {
154- $ folders = [
155- $ this ->createMock (Folder::class),
156- ];
157- $ client = $ this ->createMock (Horde_Imap_Client_Socket::class);
158- $ folders [0 ]->expects ($ this ->any ())
159- ->method ('getMailbox ' )
160- ->willReturn ('folder1 ' );
161- $ folders [0 ]->expects ($ this ->once ())
162- ->method ('getAttributes ' )
163- ->willReturn ([]);
164- $ client ->expects ($ this ->once ())
165- ->method ('status ' )
166- ->with ($ this ->equalTo (['folder1 ' ]))
167- ->willReturn ([
168- // Nothing reported for this folder
169- ]);
170- $ folders [0 ]->expects ($ this ->never ())
171- ->method ('setStatus ' );
172-
173- $ this ->mapper ->getFoldersStatus ($ folders , $ client );
174- }
175-
176- public function testGetFoldersStatusNotSearchable () {
177- $ folders = [
178- $ this ->createMock (Folder::class),
179- ];
180- $ client = $ this ->createMock (Horde_Imap_Client_Socket::class);
181- $ folders [0 ]->expects ($ this ->any ())
182- ->method ('getMailbox ' )
183- ->willReturn ('folder1 ' );
184- $ folders [0 ]->expects ($ this ->once ())
185- ->method ('getAttributes ' )
186- ->willReturn (['\\noselect ' ]);
187- $ client ->expects ($ this ->once ())
188- ->method ('status ' )
189- ->with ($ this ->equalTo ([]))
190- ->willReturn ([]);
191- $ folders [0 ]->expects ($ this ->never ())
192- ->method ('setStatus ' );
193-
194- $ this ->mapper ->getFoldersStatus ($ folders , $ client );
195- }
196-
197140 public function testGetFoldersStatusAsObject () {
198141 $ client = $ this ->createMock (Horde_Imap_Client_Socket::class);
199142 $ client ->expects ($ this ->once ())
0 commit comments