protected function setUp() { $this->customerAddressHelper = $this->getMock('Magento\\Customer\\Helper\\Address', [], [], '', false); $this->logger = $this->getMock('Psr\\Log\\LoggerInterface'); $this->customLoggerMock = $this->getMockBuilder('\\Magento\\Payment\\Model\\Method\\Logger')->setConstructorArgs([$this->getMockForAbstractClass('Psr\\Log\\LoggerInterface')])->setMethods(['debug'])->getMock(); $this->resolver = $this->getMock('Magento\\Framework\\Locale\\ResolverInterface'); $this->regionFactory = $this->getMock('Magento\\Directory\\Model\\RegionFactory', [], [], '', false); $this->countryFactory = $this->getMock('Magento\\Directory\\Model\\CountryFactory', [], [], '', false); $processableExceptionFactory = $this->getMock('Magento\\Paypal\\Model\\Api\\ProcessableExceptionFactory', ['create'], [], '', false); $processableExceptionFactory->expects($this->any())->method('create')->will($this->returnCallback(function ($arguments) { $this->processableException = $this->getMock('Magento\\Paypal\\Model\\Api\\ProcessableException', null, [$arguments['phrase'], null, $arguments['code']]); return $this->processableException; })); $exceptionFactory = $this->getMock('Magento\\Framework\\Exception\\LocalizedExceptionFactory', ['create'], [], '', false); $exceptionFactory->expects($this->any())->method('create')->will($this->returnCallback(function ($arguments) { $this->exception = $this->getMock('Magento\\Framework\\Exception\\LocalizedException', null, [$arguments['phrase']]); return $this->exception; })); $this->curl = $this->getMock('Magento\\Framework\\HTTP\\Adapter\\Curl', [], [], '', false); $curlFactory = $this->getMock('Magento\\Framework\\HTTP\\Adapter\\CurlFactory', ['create'], [], '', false); $curlFactory->expects($this->any())->method('create')->will($this->returnValue($this->curl)); $this->config = $this->getMock('Magento\\Paypal\\Model\\Config', [], [], '', false); $helper = new ObjectManagerHelper($this); $this->model = $helper->getObject('Magento\\Paypal\\Model\\Api\\Nvp', ['customerAddress' => $this->customerAddressHelper, 'logger' => $this->logger, 'customLogger' => $this->customLoggerMock, 'localeResolver' => $this->resolver, 'regionFactory' => $this->regionFactory, 'countryFactory' => $this->countryFactory, 'processableExceptionFactory' => $processableExceptionFactory, 'frameworkExceptionFactory' => $exceptionFactory, 'curlFactory' => $curlFactory]); $this->model->setConfigObject($this->config); }
/** * API instance getter * Sets current store id to current config instance and passes it to API * * @return \Magento\Paypal\Model\Api\Nvp */ public function getApi() { if (null === $this->_api) { $this->_api = $this->_apiFactory->create($this->_apiType); } $this->_api->setConfigObject($this->_config); return $this->_api; }