File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,6 +48,26 @@ public function inboxContainsNumberOfMails(int $numberOfMails): void
4848 $ this ->assertEquals ($ numberOfMails , $ this ->mailHogClient ->countAll ());
4949 }
5050
51+
52+ /**
53+ * @param int $numberOfMails
54+ * @param int $timeoutInSeconds
55+ * @throws \Exception
56+ */
57+ public function waitUntilInboxContainsNumberOfMails (int $ numberOfMails , int $ timeoutInSeconds = 10 ): void
58+ {
59+ for ($ i = 0 ; $ i < $ timeoutInSeconds ; $ i ++) {
60+ $ mailCount = $ this ->mailHogClient ->countAll ();
61+ if ($ mailCount === $ numberOfMails ) {
62+ $ this ->assertEquals ($ numberOfMails , $ mailCount );
63+ return ;
64+ }
65+ codecept_debug ('Waiting 1 second for MailHog to catch up ' );
66+ sleep (1 );
67+ }
68+ throw new \Exception ('Expected number of mails not present in MailHog after 10 seconds ' );
69+ }
70+
5171 public function clearInbox (): void
5272 {
5373 $ this ->mailHogClient ->deleteAllMessages ();
You can’t perform that action at this time.
0 commit comments