public function testExecuteException() { $agreement = ['test-data']; $quote = $this->getQuoteMock(); $quote->expects(self::once())->method('getItemsCount')->willReturn(0); $resultMock = $this->getResultMock(); $resultMock->expects(self::once())->method('setPath')->with('checkout/cart')->willReturnSelf(); $this->resultFactoryMock->expects(self::once())->method('create')->with(ResultFactory::TYPE_REDIRECT)->willReturn($resultMock); $this->requestMock->expects(self::once())->method('getPostValue')->with('agreement', [])->willReturn($agreement); $this->checkoutSessionMock->expects(self::once())->method('getQuote')->willReturn($quote); $this->orderPlaceMock->expects(self::never())->method('execute'); $this->messageManagerMock->expects(self::once())->method('addExceptionMessage')->with(self::isInstanceOf('\\InvalidArgumentException'), 'We can\'t initialize checkout.'); self::assertEquals($this->placeOrder->execute(), $resultMock); }