Skip to content

Commit 2f74e09

Browse files
committed
Merge pull request #233 from magento-mpi/MAGETWO-45682
[MPI] Sprint 73 Functional tests and Bugfix
2 parents 4876b4f + f39b555 commit 2f74e09

File tree

36 files changed

+772
-208
lines changed

36 files changed

+772
-208
lines changed

app/code/Magento/Paypal/Model/Hostedpro/Request.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,11 @@ protected function getAmountData(Order $order)
181181
*/
182182
private function getNonTaxableAmount(Order $order)
183183
{
184+
// PayPal denied transaction with 0 amount
185+
$subtotal = $order->getBaseSubtotal() ? : $order->getPayment()->getBaseAmountAuthorized();
186+
184187
return [
185-
'subtotal' => $this->formatPrice($order->getBaseSubtotal()),
188+
'subtotal' => $this->formatPrice($subtotal),
186189
'total' => $this->formatPrice($order->getPayment()->getBaseAmountAuthorized()),
187190
'tax' => $this->formatPrice($order->getBaseTaxAmount()),
188191
'shipping' => $this->formatPrice($order->getBaseShippingAmount()),
@@ -198,6 +201,7 @@ private function getNonTaxableAmount(Order $order)
198201
private function getTaxableAmount(Order $order)
199202
{
200203
$amount = $this->formatPrice($order->getPayment()->getBaseAmountAuthorized());
204+
201205
return [
202206
'amount' => $amount,
203207
'subtotal' => $amount // subtotal always is required

app/code/Magento/Paypal/Test/Unit/Model/Hostedpro/RequestTest.php

+64
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,63 @@ public function testSetAmountWithoutTax($total, $subtotal, $tax, $shipping, $dis
248248
static::assertEquals($expectation, $this->_model->getData());
249249
}
250250

251+
/**
252+
* @covers \Magento\Paypal\Model\Hostedpro\Request::setAmount()
253+
* @param $total
254+
* @param $subtotal
255+
* @param $tax
256+
* @param $shipping
257+
* @param $discount
258+
* @dataProvider amountWithoutTaxZeroSubtotalDataProvider
259+
*/
260+
public function testSetAmountWithoutTaxZeroSubtotal($total, $subtotal, $tax, $shipping, $discount)
261+
{
262+
$expectation = [
263+
'subtotal' => $total,
264+
'total' => $total,
265+
'tax' => $tax,
266+
'shipping' => $shipping,
267+
'discount' => abs($discount)
268+
];
269+
270+
static::assertFalse($this->taxData->priceIncludesTax());
271+
272+
$payment = $this->getMockBuilder(Payment::class)
273+
->disableOriginalConstructor()
274+
->getMock();
275+
276+
$order = $this->getMockBuilder(Order::class)
277+
->disableOriginalConstructor()
278+
->getMock();
279+
280+
$payment->expects(static::exactly(2))
281+
->method('getBaseAmountAuthorized')
282+
->willReturn($total);
283+
284+
$order->expects(static::exactly(2))
285+
->method('getPayment')
286+
->willReturn($payment);
287+
288+
$order->expects(static::once())
289+
->method('getBaseDiscountAmount')
290+
->willReturn($discount);
291+
292+
$order->expects(static::once())
293+
->method('getBaseTaxAmount')
294+
->willReturn($tax);
295+
296+
$order->expects(static::once())
297+
->method('getBaseShippingAmount')
298+
->willReturn($shipping);
299+
300+
$order->expects(static::once())
301+
->method('getBaseSubtotal')
302+
->willReturn($subtotal);
303+
$this->_model->setAmount($order);
304+
305+
static::assertEquals($expectation, $this->_model->getData());
306+
}
307+
251308
/**
252309
* @covers \Magento\Paypal\Model\Hostedpro\Request::setAmount()
253310
*/
@@ -313,4 +370,11 @@ public function amountWithoutTaxDataProvider()
313370
['total' => 5.00, 'subtotal' => 10.00, 'tax' => 0.00, 'shipping' => 20.00, 'discount' => -25.00],
314371
];
315372
}
373+
374+
public function amountWithoutTaxZeroSubtotalDataProvider()
375+
{
376+
return [
377+
['total' => 10.00, 'subtotal' => 0.00, 'tax' => 0.00, 'shipping' => 20.00, 'discount' => 0.00],
378+
];
379+
}
316380
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\Authorizenet\Test\Block\Authorizenet\Form;
7+
namespace Magento\Authorizenet\Test\Block\Form;
88

99
use Magento\Payment\Test\Block\Form\Cc as CreditCard;
1010

-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
<mapping strict="1">
99
<wrapper>payment</wrapper>
1010
<fields>
11-
<cc_type>
12-
<input>select</input>
13-
</cc_type>
1411
<cc_number />
1512
<cc_exp_month>
1613
<input>select</input>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. 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="credit_card_authorizenet"
10+
module="Magento_Authorizenet"
11+
type="virtual"
12+
entity_type="credit_card_authorizenet"
13+
repository_class="Magento\Authorizenet\Test\Repository\CreditCard"
14+
class="Magento\Authorizenet\Test\Fixture\CreditCardAuthorizenet">
15+
<field name="cc_number" />
16+
<field name="cc_exp_month" />
17+
<field name="cc_exp_year" />
18+
<field name="cc_cid" />
19+
</fixture>
20+
</config>

dev/tests/functional/tests/app/Magento/Authorizenet/Test/Repository/ConfigData.xml

+20-8
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,63 @@
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\Config\Test\Repository\ConfigData">
1010
<dataset name="authorizenet">
11-
<field name="payment/authorizenet/active" xsi:type="array">
11+
<field name="payment/authorizenet_directpost/active" xsi:type="array">
1212
<item name="scope" xsi:type="string">payment</item>
1313
<item name="scope_id" xsi:type="number">1</item>
1414
<item name="label" xsi:type="string">Yes</item>
1515
<item name="value" xsi:type="number">1</item>
1616
</field>
17-
<field name="payment/authorizenet/login" xsi:type="array">
17+
<field name="payment/authorizenet_directpost/login" xsi:type="array">
1818
<item name="scope" xsi:type="string">payment</item>
1919
<item name="scope_id" xsi:type="number">1</item>
2020
<item name="label" xsi:type="string"/>
2121
<item name="value" xsi:type="string">PAYMENT_AUTHORIZENET_LOGIN</item>
2222
</field>
23-
<field name="payment/authorizenet/trans_key" xsi:type="array">
23+
<field name="payment/authorizenet_directpost/trans_key" xsi:type="array">
2424
<item name="scope" xsi:type="string">payment</item>
2525
<item name="scope_id" xsi:type="number">1</item>
2626
<item name="label" xsi:type="string"/>
2727
<item name="value" xsi:type="string">PAYMENT_AUTHORIZENET_TRANS_KEY</item>
2828
</field>
29-
<field name="payment/authorizenet/test" xsi:type="array">
29+
<field name="payment/authorizenet_directpost/trans_md5" xsi:type="array">
30+
<item name="scope" xsi:type="string">payment</item>
31+
<item name="scope_id" xsi:type="number">1</item>
32+
<item name="label" xsi:type="string"/>
33+
<item name="value" xsi:type="string">PAYMENT_AUTHORIZENET_TRANS_MD5</item>
34+
</field>
35+
<field name="payment/authorizenet_directpost/test" xsi:type="array">
3036
<item name="scope" xsi:type="string">payment</item>
3137
<item name="scope_id" xsi:type="number">1</item>
3238
<item name="label" xsi:type="string">No</item>
3339
<item name="value" xsi:type="number">0</item>
3440
</field>
35-
<field name="payment/authorizenet/cgi_url" xsi:type="array">
41+
<field name="payment/authorizenet_directpost/cgi_url" xsi:type="array">
3642
<item name="scope" xsi:type="string">payment</item>
3743
<item name="scope_id" xsi:type="number">1</item>
3844
<item name="label" xsi:type="string"/>
3945
<item name="value" xsi:type="string">https://test.authorize.net/gateway/transact.dll</item>
4046
</field>
41-
<field name="payment/authorizenet/debug" xsi:type="array">
47+
<field name="payment/authorizenet_directpost/cgi_url_td" xsi:type="array">
48+
<item name="scope" xsi:type="string">payment</item>
49+
<item name="scope_id" xsi:type="number">1</item>
50+
<item name="label" xsi:type="string"/>
51+
<item name="value" xsi:type="string">https://apitest.authorize.net/xml/v1/request.api</item>
52+
</field>
53+
<field name="payment/authorizenet_directpost/debug" xsi:type="array">
4254
<item name="scope" xsi:type="string">payment</item>
4355
<item name="scope_id" xsi:type="number">1</item>
4456
<item name="label" xsi:type="string">Yes</item>
4557
<item name="value" xsi:type="number">1</item>
4658
</field>
47-
<field name="payment/authorizenet/useccv" xsi:type="array">
59+
<field name="payment/authorizenet_directpost/useccv" xsi:type="array">
4860
<item name="scope" xsi:type="string">payment</item>
4961
<item name="scope_id" xsi:type="number">1</item>
5062
<item name="label" xsi:type="string">Yes</item>
5163
<item name="value" xsi:type="number">1</item>
5264
</field>
5365
</dataset>
5466
<dataset name="authorizenet_rollback">
55-
<field name="payment/authorizenet/active" xsi:type="array">
67+
<field name="payment/authorizenet_directpost/active" xsi:type="array">
5668
<item name="scope" xsi:type="string">payment</item>
5769
<item name="scope_id" xsi:type="number">1</item>
5870
<item name="label" xsi:type="string">No</item>

dev/tests/functional/tests/app/Magento/Authorizenet/Test/Repository/CreditCard.xml

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
9-
<repository class="Magento\Payment\Test\Repository\CreditCard">
9+
<repository class="Magento\Authorizenet\Test\Repository\CreditCard">
1010
<dataset name="visa_authorizenet">
11-
<field name="cc_type" xsi:type="string">Visa</field>
12-
<field name="cc_number" xsi:type="string">4007000000027</field>
11+
<field name="cc_number" xsi:type="string">4111111111111111</field>
1312
<field name="cc_exp_month" xsi:type="string">01 - January</field>
14-
<field name="cc_exp_year" xsi:type="string">2016</field>
13+
<field name="cc_exp_year" xsi:type="string">2020</field>
1514
<field name="cc_cid" xsi:type="string">123</field>
1615
</dataset>
1716
</repository>

dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutTest.xml

+8-5
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,19 @@
1616
<data name="shipping/shipping_service" xsi:type="string">Flat Rate</data>
1717
<data name="shipping/shipping_method" xsi:type="string">Fixed</data>
1818
<data name="prices" xsi:type="array">
19-
<item name="grandTotal" xsi:type="string">156.81</item>
19+
<item name="grandTotal" xsi:type="string">145.98</item>
2020
</data>
21-
<data name="payment/method" xsi:type="string">authorizenet</data>
22-
<data name="creditCard/dataset" xsi:type="string">visa_default</data>
21+
<data name="creditCardClass" xsi:type="string">credit_card_authorizenet</data>
22+
<data name="payment/method" xsi:type="string">authorizenet_directpost</data>
23+
<data name="creditCard/dataset" xsi:type="string">visa_authorizenet</data>
2324
<data name="configData" xsi:type="string">authorizenet</data>
24-
<data name="tag" xsi:type="string">test_type:3rd_party_test</data>
25+
<data name="status" xsi:type="string">Processing</data>
26+
<data name="tag" xsi:type="string">test_type:3rd_party_test_deprecated</data>
2527
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
2628
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
2729
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
28-
<constraint name="Magento\Sales\Test\Constraint\AssertOrderCommentsHistory" />
30+
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
31+
<constraint name="Magento\Sales\Test\Constraint\AssertAuthorizationInCommentsHistory" />
2932
</variation>
3033
</testCase>
3134
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Braintree\Test\Block\Form;
8+
9+
10+
use Magento\Mtf\Block\Mapper;
11+
use Magento\Mtf\Client\Locator;
12+
use Magento\Mtf\Block\BlockFactory;
13+
use Magento\Mtf\Client\BrowserInterface;
14+
use Magento\Mtf\Client\Element\SimpleElement;
15+
use Magento\Mtf\Fixture\FixtureInterface;
16+
use Magento\Payment\Test\Block\Form\Cc as CreditCard;
17+
18+
/**
19+
* Class Cc
20+
* Form for filling credit card data for Braintree payment method
21+
*/
22+
class Cc extends CreditCard
23+
{
24+
/**
25+
* Braintree iFrame locator
26+
*
27+
* @var array
28+
*/
29+
protected $braintreeForm = [
30+
"credit_card_number" => "#braintree-hosted-field-number",
31+
"credit_card_exp_month" => "#braintree-hosted-field-expirationMonth",
32+
"credit_card_exp_year" => "#braintree-hosted-field-expirationYear",
33+
"cvv" => "#braintree-hosted-field-cvv",
34+
];
35+
36+
public function fill(FixtureInterface $fixture, SimpleElement $element = null)
37+
{
38+
$mapping = $this->dataMapping($fixture->getData());
39+
foreach ($this->braintreeForm as $field => $iframe) {
40+
$this->browser->switchToFrame(new Locator($iframe));
41+
$element = $this->browser->find('body');
42+
$this->_fill([$mapping[$field]], $element);
43+
$this->browser->switchToFrame();
44+
}
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" ?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<mapping strict="0">
9+
<fields>
10+
<credit_card_number>
11+
<selector>#credit-card-number</selector>
12+
</credit_card_number>
13+
<credit_card_exp_month>
14+
<selector>#expiration-month</selector>
15+
</credit_card_exp_month>
16+
<credit_card_exp_year>
17+
<selector>#expiration-year</selector>
18+
</credit_card_exp_year>
19+
<cvv>
20+
<selector>#cvv</selector>
21+
</cvv>
22+
</fields>
23+
</mapping>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. 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="credit_card_braintree"
10+
module="Magento_Braintree"
11+
type="virtual"
12+
entity_type="credit_card_braintree"
13+
repository_class="Magento\Braintree\Test\Repository\CreditCard"
14+
class="Magento\Braintree\Test\Fixture\CreditCardBraintree">
15+
<field name="credit_card_number" />
16+
<field name="credit_card_exp_month" />
17+
<field name="credit_card_exp_year" />
18+
<field name="cvv" />
19+
</fixture>
20+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. 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/pages.xsd">
9+
<page name="CheckoutOnepage" mca="checkout/index">
10+
<block name="braintreeBlock" class="\Magento\Braintree\Test\Block\Form\Сс" locator="body" strategy="xpath"/>
11+
</page>
12+
</config>

0 commit comments

Comments
 (0)