I have a model class, that throw exception if some value is null. How I can test, that it condition is ok.

 $contact = $this->contactFactory->create()
 $this->contactRepository->save($contact); //exception is here 

using php code, try:

if(isset($contact)) $this->contactRepository->save($contact);


try { $this->contactRepository->save($contact); } catch

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.