Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to test mail() using PHPUnit

is there a way to test with PHPUnit (or maybe other testing framework for PHP) if mail is sent correctly? I have to test a code which uses PHP function mail() . With custom mailer class i could always make a mock, but for mail() ... ? Maybe there is some plugin which is capable to use IMAP and verify if mail is received? (and it should be OS-agnostic if it is possible...)

like image 726
ts. Avatar asked Jul 31 '10 20:07

ts.


1 Answers

The solution here would be to wrap mail in a class that could be mocked and use that instead.

I don't see the point in testing mail() itself, I'm sure it's been thoroughly tested already.

like image 164
Artefacto Avatar answered Oct 16 '22 04:10

Artefacto