문제

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()
            ->setEmail('testdelete@test.com')
            ->setFirstname('Pasha')
            ->setLastname('Doe')
            ->setPhone(1236547);
 $this->contactRepository->save($contact); //exception is here 
도움이 되었습니까?

해결책

using php code, try:

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

or

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top