Skip to content

Commit

Permalink
Merge pull request #3 from amol2jcommerce/2.2-develop-PR-port-20170
Browse files Browse the repository at this point in the history
[Backport] Order API resources updated. magento#20169
  • Loading branch information
Amol Chaudhari authored Jan 23, 2019
2 parents e533389 + f8d67c7 commit abb6933
Show file tree
Hide file tree
Showing 41 changed files with 1,089 additions and 362 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ class TableBuilder
*/
private $tableBuilderFactory;

/**
* Check whether builder was executed
*
* @var bool
*/
protected $_isExecuted = false;

/**
* Constructor
*
Expand Down Expand Up @@ -70,9 +63,6 @@ public function __construct(
*/
public function build($storeId, $changedIds, $valueFieldSuffix)
{
if ($this->_isExecuted) {
return;
}
$entityTableName = $this->_productIndexerHelper->getTable('catalog_product_entity');
$attributes = $this->_productIndexerHelper->getAttributes();
$eavAttributes = $this->_productIndexerHelper->getTablesStructure($attributes);
Expand Down Expand Up @@ -117,7 +107,6 @@ public function build($storeId, $changedIds, $valueFieldSuffix)
//Fill temporary tables with attributes grouped by it type
$this->_fillTemporaryTable($tableName, $columns, $changedIds, $valueFieldSuffix, $storeId);
}
$this->_isExecuted = true;
}

/**
Expand Down
13 changes: 11 additions & 2 deletions app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
namespace Magento\Checkout\Block\Checkout;

use Magento\Customer\Api\CustomerRepositoryInterface as CustomerRepository;
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Helper\Address as AddressHelper;
use Magento\Customer\Model\Session;
use Magento\Directory\Helper\Data as DirectoryHelper;

/**
* Fields attribute merger.
*/
class AttributeMerger
{
/**
Expand Down Expand Up @@ -46,6 +50,7 @@ class AttributeMerger
'alpha' => 'validate-alpha',
'numeric' => 'validate-number',
'alphanumeric' => 'validate-alphanum',
'alphanum-with-spaces' => 'validate-alphanum-with-spaces',
'url' => 'validate-url',
'email' => 'email2',
'length' => 'validate-length',
Expand All @@ -67,7 +72,7 @@ class AttributeMerger
private $customerRepository;

/**
* @var \Magento\Customer\Api\Data\CustomerInterface
* @var CustomerInterface
*/
private $customer;

Expand Down Expand Up @@ -309,6 +314,8 @@ protected function getMultilineFieldConfig($attributeCode, array $attributeConfi
}

/**
* Returns default attribute value.
*
* @param string $attributeCode
* @return null|string
*/
Expand Down Expand Up @@ -346,7 +353,9 @@ protected function getDefaultValue($attributeCode)
}

/**
* @return \Magento\Customer\Api\Data\CustomerInterface|null
* Returns logged customer.
*
* @return CustomerInterface|null
*/
protected function getCustomer()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class ShippingInformationManagement implements \Magento\Checkout\Api\ShippingInf
* @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector
* @param CartExtensionFactory|null $cartExtensionFactory,
* @param ShippingAssignmentFactory|null $shippingAssignmentFactory,
* @param CartExtensionFactory|null $cartExtensionFactory
* @param ShippingAssignmentFactory|null $shippingAssignmentFactory
* @param ShippingFactory|null $shippingFactory
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
Expand Down Expand Up @@ -150,6 +150,10 @@ public function saveAddressInformation(
$address->setCustomerAddressId(null);
}

if ($billingAddress && !$billingAddress->getCustomerAddressId()) {
$billingAddress->setCustomerAddressId(null);
}

if (!$address->getCountryId()) {
throw new StateException(__('Shipping address is not set'));
}
Expand Down Expand Up @@ -203,6 +207,8 @@ protected function validateQuote(\Magento\Quote\Model\Quote $quote)
}

/**
* Prepare shipping assignment.
*
* @param CartInterface $quote
* @param AddressInterface $address
* @param string $method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,13 @@
<seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/>
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask1"/>
</actionGroup>

<actionGroup name="GuestCheckoutFillingShippingSectionWithoutPaymentsActionGroup" extends="GuestCheckoutFillingShippingSectionActionGroup">
<waitForElement selector="{{CheckoutPaymentSection.isPaymentSection}}" time="30" stepKey="waitForPaymentSectionLoaded"/>
</actionGroup>

<actionGroup name="GuestCheckoutFillingShippingSectionWithoutRegionActionGroup" extends="GuestCheckoutFillingShippingSectionActionGroup">
<selectOption selector="{{CheckoutShippingSection.country}}" userInput="{{customerAddressVar.country}}" after="enterPostcode" stepKey="selectCountry"/>
<remove keyForRemoval="selectRegion"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<!-- Logged in user checkout add new adress shipping section -->
<actionGroup name="LoggedInUserCheckoutAddNewAddressInShippingSectionActionGroup">
<arguments>
Expand All @@ -21,6 +21,14 @@
<fillField selector="{{CheckoutShippingSection.addTelephone}}" userInput="{{customerAddressVar.telephone}}" stepKey="enterTelephone"/>
<click selector="{{CheckoutShippingSection.addSaveButton}}" stepKey="clickSaveAdressAdd"/>
<waitForPageLoad stepKey="waitPageLoad"/>
<see stepKey="seeRegionSelected" selector="{{CheckoutShippingSection.selectedShippingAddress}}" userInput="{{customerAddressVar.state}}"/>
<see selector="{{CheckoutShippingSection.selectedShippingAddress}}" userInput="{{customerAddressVar.state}}" stepKey="seeRegionSelected"/>
</actionGroup>

<actionGroup name="LoggedInUserCheckoutAddNewShippingSectionWithoutRegionActionGroup"
extends="LoggedInUserCheckoutAddNewAddressInShippingSectionActionGroup">
<remove keyForRemoval="selectRegion"/>
<remove keyForRemoval="seeRegionSelected"/>
<selectOption selector="{{CheckoutShippingSection.addCountry}}" userInput="{{customerAddressVar.country}}" after="enterPostcode" stepKey="enterCountry"/>
<see selector="{{CheckoutShippingSection.selectedShippingAddress}}" userInput="{{customerAddressVar.city}}" after="waitPageLoad" stepKey="seeCitySelected"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@
<element name="billingAddressSameAsShipping" type="checkbox" selector=".payment-method._active [name='billing-address-same-as-shipping']"/>
<element name="orderSummaryTotal" type="text" selector="tr.grand.totals span.price" />
<element name="checkPaymentMethodByName" type="radio" selector="//div[@id='checkout-payment-method-load']//div[contains(., '{{paymentName}}')]/..//input[@type='radio']" parameterized="true"/>
<element name="noPaymentMethods" type="text" selector=".no-quotes-block"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<element name="addState" type="select" selector="#shipping-new-address-form select[name='region_id']"/>
<element name="addPostcode" type="input" selector="#shipping-new-address-form input[name='postcode']"/>
<element name="addTelephone" type="input" selector="#shipping-new-address-form input[name='telephone']"/>
<element name="addcCountry" type="select" selector="#shipping-new-address-form select[name='country_id']"/>
<element name="addCountry" type="select" selector="#shipping-new-address-form select[name='country_id']"/>
<element name="addSaveButton" type="button" selector=".action.primary.action-save-address"/>
<element name="editActiveAddress" type="button" selector="//div[@class='shipping-address-item selected-item']//span[text()='Edit']" timeout="30"/>
</section>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="StorefrontCustomerCheckoutTestWithRestrictedCountriesForPaymentTest"
extends="StorefrontGuestCheckoutTestWithRestrictedCountriesForPaymentTest">
<annotations>
<stories value="Checkout via the Storefront"/>
<title value="Checkout via Customer Checkout with restricted countries for payment"/>
<description value="Should be able to place an order as a Customer with restricted countries for payment."/>
<testCaseId value="MC-10831"/>
</annotations>
<before>
<createData entity="Simple_US_Customer" stepKey="createSimpleUsCustomer"/>
</before>
<after>
<actionGroup ref="CustomerLogoutStorefrontActionGroup" stepKey="customerLogoutStorefront"/>
<deleteData createDataKey="createSimpleUsCustomer" stepKey="deleteCustomer"/>
</after>

<remove keyForRemoval="guestCheckoutFillingShippingSection"/>
<remove keyForRemoval="guestCheckoutFillingShippingSectionUK"/>
<remove keyForRemoval="guestPlaceOrder"/>

<!-- Login as Customer -->
<actionGroup ref="CustomerLoginOnStorefront" before="goToProductPage" stepKey="customerLogin">
<argument name="customer" value="$$createSimpleUsCustomer$$" />
</actionGroup>

<!-- Select address and go to payments page-->
<see selector="{{CheckoutShippingSection.selectedShippingAddress}}" userInput="{{US_Address_TX.state}}" after="shippingStepIsOpened" stepKey="seeRegion" />
<waitForElement selector="{{CheckoutShippingMethodsSection.next}}" time="30" after="seeRegion" stepKey="waitNextButton"/>
<actionGroup ref="CheckoutSelectFlatRateShippingMethodActionGroup" after="waitNextButton" stepKey="selectShippingMethod"/>
<click selector="{{CheckoutShippingMethodsSection.next}}" after="selectShippingMethod" stepKey="clickNextButton" />
<waitForPageLoad after="clickNextButton" stepKey="waitBillingForm"/>
<seeElement selector="{{CheckoutPaymentSection.isPaymentSection}}" after="waitBillingForm" stepKey="checkoutPaymentStepIsOpened"/>

<!-- Fill UK Address and verify that payment available and checkout successful -->
<click selector="{{CheckoutShippingSection.newAdress}}" after="shippingStepIsOpened1" stepKey="fillNewAddress" />
<actionGroup ref="LoggedInUserCheckoutAddNewShippingSectionWithoutRegionActionGroup" after="fillNewAddress" stepKey="customerCheckoutFillingShippingSectionUK">
<argument name="customerVar" value="$$createSimpleUsCustomer$$" />
<argument name="customerAddressVar" value="UK_Default_Address" />
</actionGroup>
<waitForElement selector="{{CheckoutShippingMethodsSection.next}}" time="30" after="customerCheckoutFillingShippingSectionUK" stepKey="waitNextButton1"/>
<actionGroup ref="CheckoutSelectFlatRateShippingMethodActionGroup" after="waitNextButton1" stepKey="selectShippingMethod1"/>
<click selector="{{CheckoutShippingMethodsSection.next}}" after="selectShippingMethod1" stepKey="clickNextButton1" />

<actionGroup ref="CheckoutPlaceOrderActionGroup" after="selectCheckMoneyOrderPayment" stepKey="customerPlaceorder">
<argument name="orderNumberMessage" value="CONST.successCheckoutOrderNumberMessage" />
<argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage" />
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="StorefrontGuestCheckoutTestWithRestrictedCountriesForPaymentTest">
<annotations>
<features value="Checkout"/>
<stories value="Checkout via Guest Checkout"/>
<title value="Checkout via Guest Checkout with restricted countries for payment"/>
<description value="Should be able to place an order as a Guest with restricted countries for payment."/>
<severity value="MAJOR"/>
<testCaseId value="MC-8243"/>
<group value="checkout"/>
</annotations>
<before>
<createData entity="_defaultCategory" stepKey="createCategory"/>
<createData entity="ApiSimpleProduct" stepKey="createProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<magentoCLI command="config:set payment/checkmo/allowspecific" arguments="1" stepKey="setAllowSpecificCountiesValue" />
<magentoCLI command="config:set payment/checkmo/specificcountry" arguments="GB" stepKey="setSpecificCountryValue" />
</before>
<after>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
<magentoCLI command="config:set payment/checkmo/allowspecific" arguments="0" stepKey="unsetAllowSpecificCountiesValue"/>
<magentoCLI command="config:set payment/checkmo/specificcountry" arguments="''" stepKey="unsetSpecificCountryValue" />
</after>

<!-- Add product to cart -->
<amOnPage url="{{StorefrontProductPage.url($$createProduct.sku$$)}}" stepKey="goToProductPage"/>
<actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addProductToCart">
<argument name="productName" value="$$createProduct.name$$"/>
</actionGroup>
<!-- Go to checkout page -->
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart" />

<!-- Fill US Address and verify that no payment available -->
<seeElement selector="{{CheckoutShippingSection.isShippingStep}}" stepKey="shippingStepIsOpened"/>
<actionGroup ref="GuestCheckoutFillingShippingSectionWithoutPaymentsActionGroup" stepKey="guestCheckoutFillingShippingSection">
<argument name="customerVar" value="Simple_US_Customer"/>
<argument name="customerAddressVar" value="US_Address_TX"/>
<argument name="shippingMethod" value="Flat Rate" type="string"/>
</actionGroup>

<waitForElementVisible selector="{{CheckoutPaymentSection.noPaymentMethods}}" stepKey="waitMessage"/>
<see userInput="No Payment method available." stepKey="checkMessage"/>

<!-- Fill UK Address and verify that payment available and checkout successful -->
<click selector="{{CheckoutHeaderSection.shippingMethodStep}}" stepKey="goToShipping" />
<waitForElementVisible selector="{{CheckoutShippingSection.isShippingStep}}" stepKey="shippingStepIsOpened1"/>

<actionGroup ref="GuestCheckoutFillingShippingSectionWithoutRegionActionGroup" stepKey="guestCheckoutFillingShippingSectionUK">
<argument name="customerVar" value="Simple_US_Customer" />
<argument name="customerAddressVar" value="UK_Default_Address" />
<argument name="shippingMethod" value="Flat Rate" type="string"/>
</actionGroup>
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyOrderPayment" />
<actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="guestPlaceOrder">
<argument name="orderNumberMessage" value="CONST.successGuestCheckoutOrderNumberMessage" />
<argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage" />
</actionGroup>
</test>
</tests>
Loading

0 comments on commit abb6933

Please sign in to comment.