File tree 1 file changed +38
-0
lines changed 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 3
3
namespace DirectoryTree \ImapEngine \Laravel \Tests ;
4
4
5
5
use DirectoryTree \ImapEngine \Laravel \Commands \WatchMailbox ;
6
+ use DirectoryTree \ImapEngine \Laravel \Events \MailboxWatchAttemptsExceeded ;
6
7
use DirectoryTree \ImapEngine \Laravel \Events \MessageReceived ;
7
8
use DirectoryTree \ImapEngine \Laravel \Facades \Imap ;
8
9
use DirectoryTree \ImapEngine \Laravel \Support \LoopFake ;
13
14
use Illuminate \Support \Facades \Config ;
14
15
use Illuminate \Support \Facades \Event ;
15
16
use InvalidArgumentException ;
17
+ use RuntimeException ;
16
18
17
19
use function Pest \Laravel \artisan ;
18
20
48
50
fn (MessageReceived $ event ) => $ event ->message ->is ($ message )
49
51
);
50
52
});
53
+
54
+ it ('dispatches event when failure attempts have been reached ' , function () {
55
+ Config::set ('imap.mailboxes.test ' , [
56
+ 'host ' => 'localhost ' ,
57
+ 'port ' => 993 ,
58
+ 'encryption ' => 'ssl ' ,
59
+ 'username ' => '' ,
60
+ 'password ' => '' ,
61
+ ]);
62
+
63
+ Imap::fake ('test ' , folders: [
64
+ new class ('inbox ' ) extends FakeFolder
65
+ {
66
+ public function idle (
67
+ callable $ callback ,
68
+ ?callable $ query = null ,
69
+ int $ timeout = 300
70
+ ): void {
71
+ throw new RuntimeException ('Simulated exception ' );
72
+ }
73
+ },
74
+ ]);
75
+
76
+ Event::fake ();
77
+
78
+ try {
79
+ artisan (WatchMailbox::class, [
80
+ 'mailbox ' => 'test ' ,
81
+ '--attempts ' => 5 ,
82
+ ]);
83
+ } catch (RuntimeException ) {
84
+ // Do nothing.
85
+ }
86
+
87
+ Event::assertDispatched (MailboxWatchAttemptsExceeded::class);
88
+ });
You can’t perform that action at this time.
0 commit comments