markTestIncomplete(); $this->messageManager = $this->getMockForAbstractClass(\Magento\Framework\Message\ManagerInterface::class); $this->config = $this->createMock(\Magento\Paypal\Model\Config::class); $this->request = $this->createMock(\Magento\Framework\App\Request\Http::class); $this->quote = $this->createMock(\Magento\Quote\Model\Quote::class); $this->quote->expects($this->any()) ->method('hasItems') ->will($this->returnValue(true)); $this->redirect = $this->getMockForAbstractClass(\Magento\Framework\App\Response\RedirectInterface::class); $this->response = $this->createMock(\Magento\Framework\App\Response\Http::class); $this->customerData = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); $this->checkout = $this->createMock(\Magento\Paypal\Model\Express\Checkout::class); $this->customerSession = $this->createMock(\Magento\Customer\Model\Session::class); $this->customerSession->expects($this->any()) ->method('getCustomerDataObject') ->will($this->returnValue($this->customerData)); $this->checkoutSession = $this->createMock(\Magento\Checkout\Model\Session::class); $this->checkoutFactory = $this->createMock(\Magento\Paypal\Model\Express\Checkout\Factory::class); $this->checkoutFactory->expects($this->any()) ->method('create') ->will($this->returnValue($this->checkout)); $this->checkoutSession->expects($this->any()) ->method('getQuote') ->will($this->returnValue($this->quote)); $this->session = $this->createMock(\Magento\Framework\Session\Generic::class); $objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $this->objectManagerCallback = function ($className) { if ($className == \Magento\Paypal\Model\Config::class) { return $this->config; } return $this->createMock($className); }; $objectManager->expects($this->any()) ->method('get') ->will($this->returnCallback(function ($className) { return call_user_func($this->objectManagerCallback, $className); })); $objectManager->expects($this->any()) ->method('create') ->will($this->returnCallback(function ($className) { return call_user_func($this->objectManagerCallback, $className); })); $helper = new ObjectManagerHelper($this); $this->model = $helper->getObject( '\\Magento\\Paypal\\Controller\\Express\\' . $this->name, [ 'messageManager' => $this->messageManager, 'response' => $this->response, 'redirect' => $this->redirect, 'request' => $this->request, 'customerSession' => $this->customerSession, 'checkoutSession' => $this->checkoutSession, 'checkoutFactory' => $this->checkoutFactory, 'paypalSession' => $this->session, 'objectManager' => $objectManager, ] ); } }