mapper = new SendGridMapper(); $this->response = [ 'errors' => [ 'Some message', ] ]; } function testGetProperError() { $error = $this->mapper->getErrorFromResponse($this->response, '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 testGetSoftErrorForInvalidEmail() { $this->response['errors'][0] = 'Invalid email address ,,@'; $error = $this->mapper->getErrorFromResponse($this->response, ',,@'); expect($error->getLevel())->equals(MailerError::LEVEL_SOFT); } }