27 $this->checkoutSession = $this->createMock(\
Magento\Checkout\Model\Session::class);
28 $this->messageManager = $this->createMock(\
Magento\Framework\Message\ManagerInterface::class);
29 $this->
object = $this->objectManager->getObject(
30 \
Magento\Checkout\Observer\LoadCustomerQuoteObserver::class,
32 'checkoutSession' => $this->checkoutSession,
33 'messageManager' => $this->messageManager
40 $this->checkoutSession->expects($this->once())->method(
'loadCustomerQuote')->willThrowException(
43 $this->messageManager->expects($this->once())->method(
'addErrorMessage')->with(
'Message');
45 $observerMock = $this->getMockBuilder(\
Magento\Framework\Event\Observer::class)
46 ->disableOriginalConstructor()
49 $this->
object->execute($observerMock);
54 $exception = new \Exception(
'Message');
55 $this->checkoutSession->expects($this->once())->method(
'loadCustomerQuote')->will(
56 $this->throwException($exception)
58 $this->messageManager->expects($this->once())->method(
'addExceptionMessage')
59 ->with($exception,
'Load customer quote error');
61 $observerMock = $this->getMockBuilder(\
Magento\Framework\Event\Observer::class)
62 ->disableOriginalConstructor()
65 $this->
object->execute($observerMock);
testLoadCustomerQuoteThrowingCoreException()
testLoadCustomerQuoteThrowingException()