objectManager = new ObjectManager($this); $this->checkoutSession = $this->createMock(\Magento\Checkout\Model\Session::class); $this->object = $this->objectManager->getObject( \Magento\Checkout\Observer\UnsetAllObserver::class, ['checkoutSession' => $this->checkoutSession] ); } public function testUnsetAll() { $this->checkoutSession->expects($this->once())->method('clearQuote')->will($this->returnSelf()); $this->checkoutSession->expects($this->once())->method('clearStorage')->will($this->returnSelf()); $observerMock = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); $this->object->execute($observerMock); } }