File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 33namespace DirectoryTree \ImapEngine \Laravel \Tests ;
44
55use DirectoryTree \ImapEngine \Laravel \Commands \WatchMailbox ;
6+ use DirectoryTree \ImapEngine \Laravel \Events \MailboxWatchAttemptsExceeded ;
67use DirectoryTree \ImapEngine \Laravel \Events \MessageReceived ;
78use DirectoryTree \ImapEngine \Laravel \Facades \Imap ;
89use DirectoryTree \ImapEngine \Laravel \Support \LoopFake ;
1314use Illuminate \Support \Facades \Config ;
1415use Illuminate \Support \Facades \Event ;
1516use InvalidArgumentException ;
17+ use RuntimeException ;
1618
1719use function Pest \Laravel \artisan ;
1820
4850 fn (MessageReceived $ event ) => $ event ->message ->is ($ message )
4951 );
5052});
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