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

Commit 04f56f4

Browse files
author
Dmytro Yushkin
committed
MAGETWO-63855: Create functional automated for complete Signifyd flow
1 parent 8c6591d commit 04f56f4

20 files changed

+319
-127
lines changed

Test/Block/Sandbox/CaseSearch.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
namespace Magento\Signifyd\Test\Block\Sandbox;
77

88
use Magento\Mtf\Block\Form;
9-
use Magento\Mtf\Client\Locator;
109

1110
/**
1211
* Side block with case search and cases list.
@@ -28,11 +27,11 @@ class CaseSearch extends Form
2827
private $submitButton = '[type=submit]';
2928

3029
/**
31-
* XPath selector of first searched element in list.
30+
* Css selector of searched element in cases list.
3231
*
3332
* @var string
3433
*/
35-
private $selectCaseLink = '//ul//li[contains(@class, "app-sidebar-item")][1]//a';
34+
private $selectCaseLink = 'ul[case-list=cases] li[case-list-case=case] a';
3635

3736
/**
3837
* Fill search input with customer name and submit.
@@ -53,10 +52,9 @@ public function searchCaseByCustomerName($customerName)
5352
*/
5453
public function selectCase()
5554
{
56-
$this->_rootElement->find($this->selectCaseLink, Locator::SELECTOR_XPATH)->click();
55+
$this->_rootElement->find($this->selectCaseLink)->click();
5756
}
5857

59-
6058
/**
6159
* Waiting of case page loading.
6260
*

Test/Block/Sandbox/WebhookAdd.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class WebhookAdd extends Form
6767
* @param array $signifydData
6868
* @return void
6969
*/
70-
public function createWebhooks($signifydData)
70+
public function createWebhooks(array $signifydData)
7171
{
7272
foreach ($this->webhookEventOptionsMap as $webhookEventCode => $webhookEventName) {
7373
$this->setEvent($webhookEventCode);

Test/Constraint/AssertCaseInfoOnBackend.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function processAssert(
5858
}
5959

6060
/**
61-
* Checks that case status matches.
61+
* Checks case status is correct.
6262
*
6363
* @return void
6464
*/
@@ -72,7 +72,7 @@ private function checkCaseStatus()
7272
}
7373

7474
/**
75-
* Checks that case guarantee disposition matches.
75+
* Checks case guarantee disposition is correct.
7676
*
7777
* @return void
7878
*/
@@ -86,7 +86,7 @@ private function checkCaseGuaranteeDisposition()
8686
}
8787

8888
/**
89-
* Checks that case review disposition matches.
89+
* Checks case review disposition is correct.
9090
*
9191
* @return void
9292
*/
@@ -100,9 +100,7 @@ private function checkCaseReviewDisposition()
100100
}
101101

102102
/**
103-
* Returns a string representation of the object.
104-
*
105-
* @return string
103+
* @inheritdoc
106104
*/
107105
public function toString()
108106
{

Test/Constraint/AssertCaseInfoOnSignifydConsole.php

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

8-
use Magento\Customer\Test\Fixture\Address;
98
use Magento\Mtf\Constraint\AbstractConstraint;
9+
use Magento\Signifyd\Test\Fixture\SignifydAddress;
1010
use Magento\Signifyd\Test\Page\Sandbox\SignifydCases;
1111

1212
/**
@@ -23,7 +23,7 @@ class AssertCaseInfoOnSignifydConsole extends AbstractConstraint
2323

2424
/**
2525
* @param SignifydCases $signifydCases
26-
* @param Address $billingAddress
26+
* @param SignifydAddress $billingAddress
2727
* @param array $prices
2828
* @param string $orderId
2929
* @param string $customerFullName
@@ -32,11 +32,11 @@ class AssertCaseInfoOnSignifydConsole extends AbstractConstraint
3232
*/
3333
public function processAssert(
3434
SignifydCases $signifydCases,
35-
Address $billingAddress,
35+
SignifydAddress $billingAddress,
3636
array $prices,
3737
$orderId,
3838
$customerFullName,
39-
$signifydData
39+
array $signifydData
4040
) {
4141
$this->signifydCases = $signifydCases;
4242

@@ -50,7 +50,7 @@ public function processAssert(
5050
}
5151

5252
/**
53-
* Checks that guarantee disposition matches.
53+
* Checks guarantee disposition is correct.
5454
*
5555
* @param string $guaranteeDisposition
5656
* @return void
@@ -65,7 +65,7 @@ private function checkGuaranteeDisposition($guaranteeDisposition)
6565
}
6666

6767
/**
68-
* Checks that CVV response matches.
68+
* Checks CVV response is correct.
6969
*
7070
* @param string $cvvResponse
7171
* @return void
@@ -80,7 +80,7 @@ private function checkCvvResponse($cvvResponse)
8080
}
8181

8282
/**
83-
* Checks that AVS response matches.
83+
* Checks AVS response is correct.
8484
*
8585
* @param string $avsResponse
8686
* @return void
@@ -95,7 +95,7 @@ private function checkAvsResponse($avsResponse)
9595
}
9696

9797
/**
98-
* Checks that order id matches.
98+
* Checks order id is correct.
9999
*
100100
* @param string $orderId
101101
* @return void
@@ -110,7 +110,7 @@ private function checkOrderId($orderId)
110110
}
111111

112112
/**
113-
* Checks that order amount matches.
113+
* Checks order amount is correct.
114114
*
115115
* @param string $amount
116116
* @return void
@@ -125,7 +125,7 @@ private function checkOrderAmount($amount)
125125
}
126126

127127
/**
128-
* Checks that card holder matches.
128+
* Checks card holder is correct.
129129
*
130130
* @param string $customerFullName
131131
* @return void
@@ -140,12 +140,12 @@ private function checkCardHolder($customerFullName)
140140
}
141141

142142
/**
143-
* Checks that billing address matches.
143+
* Checks billing address is correct.
144144
*
145-
* @param Address $billingAddress
145+
* @param SignifydAddress $billingAddress
146146
* @return void
147147
*/
148-
private function checkBillingAddress(Address $billingAddress)
148+
private function checkBillingAddress(SignifydAddress $billingAddress)
149149
{
150150
\PHPUnit_Framework_Assert::assertContains(
151151
$billingAddress->getStreet(),
@@ -155,9 +155,7 @@ private function checkBillingAddress(Address $billingAddress)
155155
}
156156

157157
/**
158-
* Returns a string representation of the object.
159-
*
160-
* @return string
158+
* @inheritdoc
161159
*/
162160
public function toString()
163161
{

Test/Constraint/AssertSignifydCaseInCommentsHistory.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
namespace Magento\Signifyd\Test\Constraint;
87

98
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
109
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
1110
use Magento\Mtf\Constraint\AbstractConstraint;
1211

1312
/**
14-
* Assert that comment about created Signifyd Case exists in Comments History section on order page in Admin.
13+
* Assert that comment about created Signifyd Case
14+
* exists in Comments History section on order page in Admin.
1515
*/
1616
class AssertSignifydCaseInCommentsHistory extends AbstractConstraint
1717
{
@@ -21,8 +21,6 @@ class AssertSignifydCaseInCommentsHistory extends AbstractConstraint
2121
const CASE_CREATED_PATTERN = '/Signifyd Case (\d)+ has been created for order\./';
2222

2323
/**
24-
* Assert that comment about Signifyd Case exists in Comments History section on order page in Admin.
25-
*
2624
* @param SalesOrderView $salesOrderView
2725
* @param OrderIndex $salesOrder
2826
* @param string $orderId
@@ -49,9 +47,7 @@ public function processAssert(
4947
}
5048

5149
/**
52-
* Returns string representation of successful assertion.
53-
*
54-
* @return string
50+
* @inheritdoc
5551
*/
5652
public function toString()
5753
{

Test/Constraint/AssertSignifydCaseInOrdersGrid.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
namespace Magento\Signifyd\Test\Constraint;
87

98
use Magento\Signifyd\Test\Page\Adminhtml\OrdersGrid;
@@ -15,8 +14,6 @@
1514
class AssertSignifydCaseInOrdersGrid extends AbstractConstraint
1615
{
1716
/**
18-
* Assert that order with fixture data is present in Sales -> Orders Grid.
19-
*
2017
* @param string $orderId
2118
* @param string $status
2219
* @param OrdersGrid $ordersGrid
@@ -46,9 +43,7 @@ public function processAssert(
4643
}
4744

4845
/**
49-
* Returns a string representation of the object.
50-
*
51-
* @return string
46+
* @inheritdoc
5247
*/
5348
public function toString()
5449
{

Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
1111

1212
/**
13-
* Class AssertSignifydGuaranteeCancelInCommentsHistory
13+
* Assert that comment about created Signifyd Case guarantee
14+
* has been cancelled exists in Comments History section on order page in Admin.
1415
*/
1516
class AssertSignifydGuaranteeCancelInCommentsHistory extends AbstractConstraint
1617
{
@@ -47,9 +48,7 @@ public function processAssert(
4748
}
4849

4950
/**
50-
* Returns a string representation of the object.
51-
*
52-
* @return string
51+
* @inheritdoc
5352
*/
5453
public function toString()
5554
{

Test/Fixture/SignifydAddress.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd">
9+
<fixture name="signifydAddress"
10+
module="Magento_Signifyd"
11+
class="Magento\Signifyd\Test\Fixture\SignifydAddress"
12+
extends="\Magento\Customer\Test\Fixture\Address">
13+
<field name="firstname" source="Magento\Signifyd\Test\Fixture\SignifydAddress\Firstname" is_required="1" />
14+
</fixture>
15+
</config>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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\Fixture\SignifydAddress;
7+
8+
use Magento\Mtf\Fixture\DataSource;
9+
10+
/**
11+
* Source handler for `firstname` field in shipping address fixture.
12+
*/
13+
class Firstname extends DataSource
14+
{
15+
/**
16+
* @param string $data
17+
*/
18+
public function __construct($data = '')
19+
{
20+
$this->data = $data;
21+
}
22+
23+
/**
24+
* Add isolation for `firstname` field.
25+
*
26+
* @param null $key
27+
* @return string
28+
*/
29+
public function getData($key = null)
30+
{
31+
$this->data = str_replace('%signifyd_isolation%', $this->generateIsolation(), $this->data);
32+
33+
return parent::getData($key);
34+
}
35+
36+
/**
37+
* Generates character isolation.
38+
*
39+
* @param int $length
40+
* @return string
41+
*/
42+
private function generateIsolation($length = 10)
43+
{
44+
return substr(
45+
str_shuffle(
46+
str_repeat("abcdefghijklmnopqrstuvwxyz", $length)),
47+
0, $length
48+
);
49+
}
50+
}

Test/Repository/Address.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
99
<repository class="Magento\Customer\Test\Repository\Address">
1010
<dataset name="signifyd_approve_us_shipping_address">
11-
<field name="firstname" xsi:type="string">John</field>
11+
<field name="firstname" xsi:type="string">John%signifyd_isolation%</field>
1212
<field name="lastname" xsi:type="string">Doe</field>
1313
<field name="company" xsi:type="string">Magento</field>
1414
<field name="city" xsi:type="string">Culver City</field>

0 commit comments

Comments
 (0)