mapper = new PHPMailMapper(); WPFunctions::set(Stub::make(new WPFunctions, [ '__' => function ($value) { return $value; } ])); } function testGetProperErrorForSubscriber() { $error = $this->mapper->getErrorForSubscriber('john@rambo.com'); expect($error->getLevel())->equals(MailerError::LEVEL_HARD); expect($error->getMessage())->equals('PHPMail has returned an unknown error.'); expect($error->getSubscriberErrors()[0]->getEmail())->equals('john@rambo.com'); } function testGetProperErrorFromException() { $error = $this->mapper->getErrorFromException(new \Exception('Some message'), 'john@rambo.com'); expect($error->getLevel())->equals(MailerError::LEVEL_HARD); expect($error->getMessage())->equals('Some message'); expect($error->getSubscriberErrors()[0]->getEmail())->equals('john@rambo.com'); } function testGetSoftErrorFromExceptionForInvalidEmail() { $error = $this->mapper->getErrorFromException(new \Exception('Invalid address. (Add ...'), 'john@rambo.com'); expect($error->getLevel())->equals(MailerError::LEVEL_SOFT); } function _after() { WPFunctions::set(new WPFunctions); } }