public function testExecute() { $this->customerSession->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); $this->checkoutSession->expects($this->once())->method('getLastOrderId')->will($this->returnValue(100)); $customer = $this->getMock('\\Magento\\Customer\\Api\\Data\\CustomerInterface'); $this->orderCustomerService->expects($this->once())->method('create')->with(100)->will($this->returnValue($customer)); $this->action->execute(); }
public function testExecute() { $jsonFactoryMock = $this->getMock(\Magento\Framework\Controller\Result\JsonFactory::class, [], [], '', false); $this->objectManagerMock->expects($this->once())->method('get')->with(\Magento\Framework\Controller\Result\JsonFactory::class)->willReturn($jsonFactoryMock); $jsonMock = $this->getMock(\Magento\Framework\Controller\Result\Json::class, [], [], '', false); $jsonFactoryMock->expects($this->once())->method('create')->willReturn($jsonMock); $this->customerSession->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); $this->checkoutSession->expects($this->once())->method('getLastOrderId')->will($this->returnValue(100)); $customer = $this->getMock('\\Magento\\Customer\\Api\\Data\\CustomerInterface'); $this->orderCustomerService->expects($this->once())->method('create')->with(100)->will($this->returnValue($customer)); $jsonMock->expects($this->once())->method('setData')->with(['errors' => false, 'message' => __('A letter with further instructions will be sent to your email.')])->willReturnSelf(); $this->action->execute(); }