Skip to content

Commit

Permalink
Merge remote-tracking branch 'mpi/MAGETWO-48211' into pr-mpi-200416
Browse files Browse the repository at this point in the history
  • Loading branch information
oshmyheliuk committed Apr 21, 2016
2 parents 6f6ae38 + b3ae6cb commit 0260b1e
Show file tree
Hide file tree
Showing 10 changed files with 459 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Braintree\Test\TestCase;

use Magento\Mtf\TestCase\Scenario;

/**
* Preconditions:
* 1. PLace order via Briantree PayPal.
*
* Steps:
* 1. Log in to Admin.
* 2. Open created order.
* 3. Create credit memo.
* 4. Perform assertions.
*
* @group Braintree_(CS)
* @ZephyrId MAGETWO-48689, MAGETWO-48698
*/
class CreateOnlineCreditMemoBraintreePaypalTest extends Scenario
{
/* tags */
const MVP = 'yes';
const DOMAIN = 'CS';
const TEST_TYPE = '3rd_party_test';
/* end tags */

/**
* Runs test for online credit memo creation for order placed via Braintree PayPal.
*
* @return void
*/
public function test()
{
$this->executeScenario();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
<testCase name="Magento\Braintree\Test\TestCase\CreateOnlineCreditMemoBraintreePaypalTest" summary="Create online credit memo for Braintree credit card" ticketId="MAGETWO-38324">
<variation name="CreateCreditMemoBraintreePaypalTestVariation1" summary="Full refund of order placed within Braintree PayPal" ticketId="MAGETWO-48689">
<data name="products" xsi:type="string">catalogProductSimple::product_10_dollar, bundleProduct::bundle_fixed_100_dollar_product</data>
<data name="customer/dataset" xsi:type="string">default</data>
<data name="checkoutMethod" xsi:type="string">login</data>
<data name="taxRule" xsi:type="string">us_ca_ny_rule</data>
<data name="refundedPrices" xsi:type="array">
<item name="0" xsi:type="string">139.9</item>
</data>
<data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data>
<data name="shipping/shipping_service" xsi:type="string">Flat Rate</data>
<data name="shipping/shipping_method" xsi:type="string">Fixed</data>
<data name="payment/method" xsi:type="string">braintree_paypal</data>
<data name="configData" xsi:type="string">braintree, braintree_paypal_sale</data>
<data name="paymentAction" xsi:type="string">sale</data>
<data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Credit Memo, Hold, Ship, Reorder</data>
<data name="data/items_data/0/qty" xsi:type="string">-</data>
<data name="tag" xsi:type="string">test_type:3rd_party_test</data>
<constraint name="Magento\Sales\Test\Constraint\AssertRefundSuccessCreateMessage" />
<constraint name="Magento\Sales\Test\Constraint\AssertRefundInCreditMemoTab" />
<constraint name="Magento\Sales\Test\Constraint\AssertRefundInCommentsHistory" />
</variation>
<variation name="CreateOnlineCreditMemoBraintreePaypalTestVariation2" summary="Partial refund of order placed within Braintree PayPal" ticketId="MAGETWO-48698">
<data name="products" xsi:type="string">catalogProductSimple::simple_for_sales</data>
<data name="customer/dataset" xsi:type="string">default</data>
<data name="checkoutMethod" xsi:type="string">login</data>
<data name="taxRule" xsi:type="string">us_ca_ny_rule</data>
<data name="refundedPrices" xsi:type="array">
<item name="0" xsi:type="string">621.2</item>
</data>
<data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data>
<data name="shipping/shipping_service" xsi:type="string">Flat Rate</data>
<data name="shipping/shipping_method" xsi:type="string">Fixed</data>
<data name="payment/method" xsi:type="string">braintree_paypal</data>
<data name="configData" xsi:type="string">braintree, braintree_paypal</data>
<data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Credit Memo, Hold, Ship, Reorder</data>
<data name="data/items_data/0/qty" xsi:type="string">2</data>
<data name="refundData/items_data/0/qty" xsi:type="string">1</data>
<data name="order/dataset" xsi:type="string">default</data>
<data name="isCreditMemoPartial" xsi:type="string">Yes</data>
<data name="tag" xsi:type="string">test_type:3rd_party_test</data>
<constraint name="Magento\Sales\Test\Constraint\AssertRefundSuccessCreateMessage" />
<constraint name="Magento\Sales\Test\Constraint\AssertRefundInCreditMemoTab" />
<constraint name="Magento\Sales\Test\Constraint\AssertRefundInCommentsHistory" />
</variation>
</testCase>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Braintree\Test\TestStep;

use Magento\Config\Test\Fixture\ConfigData;
use Magento\Mtf\ObjectManager;
use Magento\Sales\Test\Fixture\OrderInjectable;
use Magento\Sales\Test\Page\Adminhtml\OrderCreditMemoNew;
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
use Magento\Sales\Test\Page\Adminhtml\OrderInvoiceView;
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
use Magento\Mtf\TestStep\TestStepInterface;
use Braintree\Gateway;

/**
* Create credit memo for order placed via Braintree credit card payment method.
*/
class CreateBraintreeCreditMemoStep implements TestStepInterface
{
/**
* Orders Page.
*
* @var OrderIndex
*/
private $orderIndex;

/**
* Order View Page.
*
* @var SalesOrderView
*/
private $salesOrderView;

/**
* OrderCreditMemoNew Page.
*
* @var OrderCreditMemoNew
*/
private $orderCreditMemoNew;

/**
* OrderInjectable fixture.
*
* @var OrderInjectable
*/
private $order;

/**
* Credit memo data.
*
* @var array|null
*/
private $refundData;

/**
* Order invoice view page.
*
* @var OrderInvoiceView
*/
private $orderInvoiceView;

/**
* @construct
* @param OrderIndex $orderIndex
* @param SalesOrderView $salesOrderView
* @param OrderInjectable $order
* @param OrderInvoiceView $orderInvoiceView
* @param OrderCreditMemoNew $orderCreditMemoNew
* @param array|null refundData [optional]
*/
public function __construct(
OrderIndex $orderIndex,
SalesOrderView $salesOrderView,
OrderInjectable $order,
OrderInvoiceView $orderInvoiceView,
OrderCreditMemoNew $orderCreditMemoNew,
$refundData = null
) {
$this->orderIndex = $orderIndex;
$this->salesOrderView = $salesOrderView;
$this->order = $order;
$this->orderCreditMemoNew = $orderCreditMemoNew;
$this->refundData = $refundData;
$this->orderInvoiceView = $orderInvoiceView;
}

/**
* Create credit memo.
*
* @return array
*/
public function run()
{
$this->orderIndex->open();
$this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->order->getId()]);
/** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Invoices\Grid $invoicesGrid */
$invoicesGrid = $this->salesOrderView->getOrderForm()->getTab('invoices')->getGridBlock();
$this->salesOrderView->getOrderForm()->openTab('invoices');
$invoicesGrid->viewInvoice();
$this->salesOrderView->getPageActions()->orderInvoiceCreditMemo();
if (!empty($this->refundData)) {
$this->orderCreditMemoNew->getFormBlock()->fillProductData(
$this->refundData,
$this->order->getEntityId()['products']
);
$this->orderCreditMemoNew->getFormBlock()->updateQty();
}
$this->orderCreditMemoNew->getFormBlock()->submit();

return ['ids' => ['creditMemoIds' => $this->getCreditMemoIds()]];
}

/**
* Get credit memo ids.
*
* @return array
*/
private function getCreditMemoIds()
{
$this->salesOrderView->getOrderForm()->openTab('creditmemos');
return $this->salesOrderView->getOrderForm()->getTab('creditmemos')->getGridBlock()->getIds();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Magento\Checkout\Test\Constraint\AssertGrandTotalOrderReview;
use Magento\Checkout\Test\Page\CheckoutOnepage;
use Magento\Checkout\Test\Page\CheckoutOnepageSuccess;
use Magento\Mtf\Fixture\FixtureFactory;
use Magento\Mtf\TestStep\TestStepInterface;

/**
Expand Down Expand Up @@ -35,21 +36,37 @@ class PlaceOrderWithPaypalStep implements TestStepInterface
*/
private $prices;

/**
* @var FixtureFactory
*/
private $fixtureFactory;

/**
* @var array
*/
private $products;

/**
* @param CheckoutOnepage $checkoutOnepage
* @param AssertGrandTotalOrderReview $assertGrandTotalOrderReview
* @param CheckoutOnepageSuccess $checkoutOnepageSuccess
* @param FixtureFactory $fixtureFactory
* @param array $products
* @param array $prices
*/
public function __construct(
CheckoutOnepage $checkoutOnepage,
AssertGrandTotalOrderReview $assertGrandTotalOrderReview,
CheckoutOnepageSuccess $checkoutOnepageSuccess,
FixtureFactory $fixtureFactory,
array $products,
array $prices = []
) {
$this->checkoutOnepage = $checkoutOnepage;
$this->assertGrandTotalOrderReview = $assertGrandTotalOrderReview;
$this->checkoutOnepageSuccess = $checkoutOnepageSuccess;
$this->fixtureFactory = $fixtureFactory;
$this->products = $products;
$this->prices = $prices;
}

Expand All @@ -63,6 +80,17 @@ public function run()
}
$this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->clickPlaceOrder();
$this->checkoutOnepage->getBraintreePaypalBlock()->process();
return ['orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId()];
$order = $this->fixtureFactory->createByCode(
'orderInjectable',
[
'data' => [
'entity_id' => ['products' => $this->products]
]
]
);
return [
'orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(),
'order' => $order
];
}
}
Loading

0 comments on commit 0260b1e

Please sign in to comment.