11 use Magento\Framework\HTTP\Adapter\CurlFactory;
13 use Magento\Paypal\Model\CartFactory;
18 use PHPUnit\Framework\MockObject_MockObject as MockObject;
33 private $objectManager;
43 protected function setUp()
48 $httpFactory = $this->getMockBuilder(CurlFactory::class)
49 ->disableOriginalConstructor()
52 $this->httpClient = $this->getMockBuilder(Curl::class)
53 ->disableOriginalConstructor()
55 $httpFactory->method(
'create')
56 ->willReturn($this->httpClient);
58 $this->nvpApi = $this->objectManager->create(PayflowNvp::class, [
59 'curlFactory' => $httpFactory
63 $productMetadata = $this->getMockBuilder(ProductMetadataInterface::class)
65 $productMetadata->method(
'getEdition')
69 $config = $this->objectManager->get(Config::class);
72 $refObject = new \ReflectionObject(
$config);
73 $refProperty = $refObject->getProperty(
'productMetadata');
74 $refProperty->setAccessible(
true);
75 $refProperty->setValue(
$config, $productMetadata);
77 $this->nvpApi->setConfigObject(
$config);
86 public function testRequestLineItems()
88 $quote = $this->getQuote(
'100000015');
90 $cartFactory = $this->objectManager->get(CartFactory::class);
91 $cart = $cartFactory->create([
'salesModel' =>
$quote]);
93 $request =
'TENDER=P&AMT=52.14&FREIGHTAMT=0.00&TAXAMT=0.00&' 94 .
'L_NAME0=Simple 1&L_QTY0=1&L_COST0=7.69&' 95 .
'L_NAME1=Simple 2&L_QTY1=2&L_COST1=9.69&' 96 .
'L_NAME2=Simple 3&L_QTY2=3&L_COST2=11.69&' 97 .
'L_NAME3=Discount&L_QTY3=1&L_COST3=-10.00&' 98 .
'TRXTYPE=A&ACTION=S&BUTTONSOURCE=Magento_Cart_';
100 $this->httpClient->method(
'write')
103 'https://payflowpro.paypal.com/transaction',
109 $this->httpClient->method(
'read')
110 ->willReturn(
"HTTP/1.1 200 OK\r\nConnection: close\r\n\r\nRESULT=0&RESPMSG=Approved");
112 $this->nvpApi->setAmount(
$quote->getBaseGrandTotal());
113 $this->nvpApi->setPaypalCart(
$cart);
114 $this->nvpApi->setQuote(
$quote);
115 $this->nvpApi->setIsLineItemsEnabled(
true);
116 $this->nvpApi->callSetExpressCheckout();
125 private function getQuote($reservedOrderId)
const METHOD_WPP_PE_EXPRESS
static getObjectManager()