25 private $orderRepository;
30 private $quoteRepository;
40 protected function setUp()
45 $filterBuilder = $this->_objectManager->get(FilterBuilder::class);
48 ->setValue(
'100000001')
57 $this->orderRepository = $this->_objectManager->get(OrderRepositoryInterface::class);
62 $this->order = array_pop(
$orders);
66 $quote = $this->_objectManager->create(Quote::class)->setStoreid($this->order->getStoreId());
68 $this->quoteRepository = $this->_objectManager->get(CartRepositoryInterface::class);
69 $this->quoteRepository->save(
$quote);
71 $this->order->setQuoteId(
$quote->getId());
72 $this->orderRepository->save($this->order);
74 $session = $this->_objectManager->get(Session::class);
75 $session->setLastRealOrderId($this->order->getRealOrderId())->setLastQuoteId($this->order->getQuoteId());
80 $this->dispatch(
'paypal/payflow/cancelpayment');
81 $this->assertContains(
"goToSuccessPage = ''", $this->
getResponse()->getBody());
86 $checkoutHelper = $this->_objectManager->create(\
Magento\Paypal\Helper\Checkout::class);
87 $checkoutHelper->cancelCurrentOrder(
'test');
88 $this->dispatch(
'paypal/payflow/returnurl');
89 $this->assertContains(
"goToSuccessPage = ''", $this->
getResponse()->getBody());
94 $this->dispatch(
'paypal/payflow/form');
95 $this->assertContains(
96 '<form id="token_form" method="GET" action="https://payflowlink.paypal.com">',
100 $headerConstraints = [];
101 foreach ($this->
getResponse()->getHeaders() as $header) {
102 $headerConstraints[] = new \PHPUnit\Framework\Constraint\IsEqual($header->getFieldName());
104 $constraint = new \PHPUnit\Framework\Constraint\LogicalOr();
114 public function testCancelAction(): void
116 $orderId = $this->order->getEntityId();
118 $order = $this->orderRepository->get($orderId);
120 $quote = $this->quoteRepository->get($order->getQuoteId());
122 $session = $this->_objectManager->get(Session::class);
124 $session->setPaypalStandardQuoteId(
$quote->getId())->setLastRealOrderId(
'100000001');
125 $this->dispatch(
'paypal/payflow/cancelpayment');
127 $order = $this->_objectManager->create(OrderRepositoryInterface::class)->get($orderId);
128 $this->assertEquals(
'canceled', $order->getState());
129 $this->assertEquals(
$session->getQuote()->getGrandTotal(),
$quote->getGrandTotal());
130 $this->assertEquals(
$session->getQuote()->getItemsCount(),
$quote->getItemsCount());
testCancelPaymentActionIsContentGenerated()
testReturnurlActionIsContentGenerated()
testFormActionIsContentGenerated()