Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 28577b6

Browse files
committed
MAGETWO-65119: Create/update automated functional tests
- Add "Accept order placed within PayPal Payments Pro Hosted Solution with Fraud filters triggered and Signifyd Guarantee Declined" FAT - Add "Deny order placed within PayPal Payments Pro Hosted Solution with Fraud filters triggered and Signifyd Guarantee Declined" FAT
1 parent 26a2cc7 commit 28577b6

19 files changed

+784
-187
lines changed

Test/Block/SignifydConsole/CaseInfo.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ class CaseInfo extends Block
7575
*/
7676
private $orderAmount = '[ng-bind*="currentCase.orderAmount"]';
7777

78+
/**
79+
* Locator value for order amount currency.
80+
*
81+
* @var string
82+
*/
83+
private $orderAmountCurrency = '[ng-bind*="currentCase.currency"]';
84+
7885
/**
7986
* Css selector of displayed card holder name.
8087
*
@@ -89,6 +96,40 @@ class CaseInfo extends Block
8996
*/
9097
private $billingAddress = '[data-dropdown="streetLinks0"]';
9198

99+
/**
100+
* Locator value for "No analysis available" block in "Device" container.
101+
*
102+
* @var string
103+
*/
104+
private $noDeviceAnalysisAvailable = '[ng-hide^="caseAnalysis.deviceAnalysis.details.length"]';
105+
106+
/**
107+
* Locator value for "Shipping Price" block.
108+
*
109+
* @var string
110+
*/
111+
private $shippingPrice = '[ng-if$="caseOrderSummary.shipments[0].shippingPrice"]';
112+
113+
/**
114+
* Check if device data are present.
115+
*
116+
* @return bool
117+
*/
118+
public function isAvailableDeviceData()
119+
{
120+
return !$this->_rootElement->find($this->noDeviceAnalysisAvailable)->isVisible();
121+
}
122+
123+
/**
124+
* Returns shipping price.
125+
*
126+
* @return string
127+
*/
128+
public function getShippingPrice()
129+
{
130+
return $this->_rootElement->find($this->shippingPrice)->getText();
131+
}
132+
92133
/**
93134
* Flags case as good or bad.
94135
*
@@ -172,6 +213,16 @@ public function getOrderAmount()
172213
return $this->_rootElement->find($this->orderAmount)->getText();
173214
}
174215

216+
/**
217+
* Returns displayed order amount currency.
218+
*
219+
* @return string
220+
*/
221+
public function getOrderAmountCurrency()
222+
{
223+
return $this->_rootElement->find($this->orderAmountCurrency)->getText();
224+
}
225+
175226
/**
176227
* Gets displayed card holder name.
177228
*
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Signifyd\Test\Constraint;
7+
8+
use Magento\Mtf\Constraint\AbstractConstraint;
9+
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
10+
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
11+
12+
/**
13+
* Assert that comment about awaiting the Signifyd guarantee disposition
14+
* exists in Comments History section on order page in Admin.
15+
*/
16+
class AssertAwaitingSignifydGuaranteeInCommentsHistory extends AbstractConstraint
17+
{
18+
/**
19+
* Expected history comment.
20+
*/
21+
private $historyComment = 'Awaiting the Signifyd guarantee disposition.';
22+
23+
/**
24+
* Expected history status.
25+
*/
26+
private $historyCommentStatus = 'On Hold';
27+
28+
/**
29+
* @param SalesOrderView $salesOrderView
30+
* @param OrderIndex $salesOrder
31+
* @param string $orderId
32+
* @return void
33+
*/
34+
public function processAssert(
35+
SalesOrderView $salesOrderView,
36+
OrderIndex $salesOrder,
37+
$orderId
38+
) {
39+
$salesOrder->open();
40+
$salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
41+
42+
/** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */
43+
$infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info');
44+
$orderComments = $infoTab->getCommentsHistoryBlock()->getComments();
45+
46+
$key = array_search(
47+
$this->historyComment,
48+
array_column($orderComments, 'comment')
49+
);
50+
51+
\PHPUnit_Framework_Assert::assertNotFalse(
52+
$key,
53+
'There is no message about awaiting the Signifyd guarantee disposition' .
54+
' in Comments History section for the order #' . $orderId
55+
);
56+
57+
\PHPUnit_Framework_Assert::assertEquals(
58+
$this->historyCommentStatus,
59+
$orderComments[$key]['status'],
60+
'Message about awaiting the Signifyd guarantee disposition' .
61+
' doesn\'t have status "'. $this->historyCommentStatus.'"' .
62+
' in Comments History section for the order #' . $orderId
63+
);
64+
}
65+
66+
/**
67+
* @inheritdoc
68+
*/
69+
public function toString()
70+
{
71+
return "Message about awaiting the Signifyd guarantee disposition is available in Comments History section.";
72+
}
73+
}

Test/Constraint/AssertCaseInfoOnAdmin.php

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
*/
66
namespace Magento\Signifyd\Test\Constraint;
77

8+
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
89
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
910
use Magento\Mtf\Constraint\AbstractConstraint;
11+
use Magento\Signifyd\Test\Fixture\SignifydData;
1012

1113
/**
1214
* Assert that Order Case Entity is correct on order page in Admin.
@@ -21,36 +23,40 @@ class AssertCaseInfoOnAdmin extends AbstractConstraint
2123
private $orderView;
2224

2325
/**
24-
* Order id.
26+
* Signifyd data fixture.
2527
*
26-
* @var string
28+
* @var SignifydData
2729
*/
28-
private $orderId;
30+
private $signifydData;
2931

3032
/**
31-
* Array of Signifyd config data.
33+
* Order id.
3234
*
33-
* @var array
35+
* @var string
3436
*/
35-
private $signifydData;
37+
private $orderId;
3638

3739
/**
3840
* Assert that Signifyd Case information is correct in Admin.
3941
*
4042
* @param SalesOrderView $orderView
43+
* @param OrderIndex $salesOrder
44+
* @param SignifydData $signifydData
4145
* @param string $orderId
42-
* @param array $signifydData
4346
* @return void
4447
*/
4548
public function processAssert(
4649
SalesOrderView $orderView,
47-
$orderId,
48-
array $signifydData
50+
OrderIndex $salesOrder,
51+
SignifydData $signifydData,
52+
$orderId
4953
) {
54+
$salesOrder->open();
55+
$salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
56+
5057
$this->orderView = $orderView;
51-
$this->orderView->open(['order_id' => $orderId]);
52-
$this->orderId = $orderId;
5358
$this->signifydData = $signifydData;
59+
$this->orderId = $orderId;
5460

5561
$this->checkCaseStatus();
5662
$this->checkCaseGuaranteeDisposition();
@@ -65,7 +71,7 @@ public function processAssert(
6571
private function checkCaseStatus()
6672
{
6773
\PHPUnit_Framework_Assert::assertEquals(
68-
$this->signifydData['caseStatus'],
74+
$this->signifydData->getCaseStatus(),
6975
$this->orderView->getFraudProtectionBlock()->getCaseStatus(),
7076
'Case status is wrong for order #' . $this->orderId
7177
);
@@ -79,7 +85,7 @@ private function checkCaseStatus()
7985
private function checkCaseGuaranteeDisposition()
8086
{
8187
\PHPUnit_Framework_Assert::assertEquals(
82-
$this->signifydData['guaranteeDisposition'],
88+
$this->signifydData->getGuaranteeDisposition(),
8389
$this->orderView->getFraudProtectionBlock()->getCaseGuaranteeDisposition(),
8490
'Case Guarantee Disposition status is wrong for order #' . $this->orderId
8591
);
@@ -93,7 +99,7 @@ private function checkCaseGuaranteeDisposition()
9399
private function checkCaseReviewDisposition()
94100
{
95101
\PHPUnit_Framework_Assert::assertEquals(
96-
$this->signifydData['reviewDisposition'],
102+
$this->signifydData->getReviewDisposition(),
97103
$this->orderView->getFraudProtectionBlock()->getCaseReviewDisposition(),
98104
'Case Review Disposition status is wrong for order #' . $this->orderId
99105
);

0 commit comments

Comments
 (0)