Skip to content

Commit

Permalink
Merge branch '2.3-tests-pr' of github.com:magento-pangolin/magento2ce…
Browse files Browse the repository at this point in the history
… into MC-6484
  • Loading branch information
mKovdrysh committed Jul 23, 2019
2 parents e9eed2d + dd85619 commit 5ccd0f6
Show file tree
Hide file tree
Showing 145 changed files with 10,036 additions and 746 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminSystemMessagesSection">
<element name="systemMessagesDropdown" type="button" selector="#system_messages .message-system-action-dropdown"/>
<element name="actionMessageLog" type="button" selector="//*[contains(@class, 'message-system-summary')]/a[contains(text(), '{{textMessage}}')]" parameterized="true"/>
</section>
</sections>
17 changes: 16 additions & 1 deletion app/code/Magento/Braintree/Model/LocaleResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Magento\Framework\Locale\ResolverInterface;
use Magento\Braintree\Gateway\Config\PayPal\Config;

/**
* Resolves locale for PayPal Express.
*/
class LocaleResolver implements ResolverInterface
{
/**
Expand All @@ -20,6 +23,17 @@ class LocaleResolver implements ResolverInterface
*/
private $config;

/**
* Mapping Magento locales on PayPal locales.
*
* @var array
*/
private $localeMap = [
'zh_Hans_CN' => 'zh_CN',
'zh_Hant_HK' => 'zh_HK',
'zh_Hant_TW' => 'zh_TW'
];

/**
* @param ResolverInterface $resolver
* @param Config $config
Expand Down Expand Up @@ -66,10 +80,11 @@ public function setLocale($locale = null)
* Gets store's locale or the `en_US` locale if store's locale does not supported by PayPal.
*
* @return string
* @see https://braintree.github.io/braintree-web/current/PayPalCheckout.html#createPayment
*/
public function getLocale()
{
$locale = $this->resolver->getLocale();
$locale = $this->localeMap[$this->resolver->getLocale()] ?? $this->resolver->getLocale();
$allowedLocales = $this->config->getValue('supported_locales');

return strpos($allowedLocales, $locale) !== false ? $locale : 'en_US';
Expand Down
34 changes: 25 additions & 9 deletions app/code/Magento/Braintree/Test/Unit/Model/LocaleResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,35 @@ public function testSetLocale()
/**
* Test getLocale method
*
* @return void
* @param string $locale
* @param string $expectedLocale
* @dataProvider getLocaleDataProvider
*/
public function testGetLocale()
public function testGetLocale(string $locale, string $expectedLocale)
{
$locale = 'en_TEST';
$allowedLocales = 'en_US,en_GB,en_AU,da_DK,fr_FR,fr_CA,de_DE,zh_HK,it_IT,nl_NL';
$this->resolverMock->expects($this->once())->method('getLocale')->willReturn($locale);
$this->configMock->expects($this->once())->method('getValue')->with('supported_locales')
$allowedLocales = 'en_US,en_GB,en_AU,da_DK,fr_FR,fr_CA,de_DE,zh_HK,it_IT,zh_CN,zh_TW,nl_NL';
$this->resolverMock->method('getLocale')
->willReturn($locale);
$this->configMock->method('getValue')
->with('supported_locales')
->willReturn($allowedLocales);

$expected = 'en_US';
$actual = $this->localeResolver->getLocale();
self::assertEquals($expected, $actual);

self::assertEquals($expectedLocale, $actual);
}

/**
* @return array
*/
public function getLocaleDataProvider(): array
{
return [
['locale' => 'zh_Hans_CN', 'expectedLocale' => 'zh_CN'],
['locale' => 'zh_Hant_HK', 'expectedLocale' => 'zh_HK'],
['locale' => 'zh_Hant_TW', 'expectedLocale' => 'zh_TW'],
['locale' => 'fr_FR', 'expectedLocale' => 'fr_FR'],
['locale' => 'unknown', 'expectedLocale' => 'en_US'],
];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<!--Category Selection-->
<element name="categoryByName" type="multiselect" selector="//div[@data-index='category_ids']//span[contains(text(), '{{category}}')]" parameterized="true"/>
<element name="searchForCategory" type="input" selector="div.action-menu._active > div.admin__action-multiselect-search-wrap input" timeout="30"/>
<element name="selectCategory" type="multiselect" selector="//div[@class='action-menu _active']//label[@class='admin__action-multiselect-label']"/>
<element name="selectCategory" type="multiselect" selector="//div[@class='action-menu _active']//label[@class='admin__action-multiselect-label']" timeout="30"/>
<element name="categoriesLabel" type="text" selector="//div[@class='action-menu _active']//button[@data-action='close-advanced-select']"/>
<element name="userDefinedQuantity" type="checkbox" selector="[name='bundle_options[bundle_options][{{option}}][bundle_selections][{{product}}][selection_can_change_qty]'][type='checkbox']" parameterized="true"/>
</section>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<?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="AdminCreateAndEditBundleProductSettingsTest">
<annotations>
<features value="Bundle"/>
<stories value="Create/Edit bundle product in Admin"/>
<title value="Admin should be able to set/edit other product information when creating/editing a bundle product"/>
<description value="Admin should be able to set/edit other product information when creating/editing a bundle product"/>
<severity value="CRITICAL"/>
<testCaseId value="MC-224"/>
<group value="Catalog"/>
</annotations>
<before>
<!-- Create a Website -->
<createData entity="customWebsite" stepKey="createWebsite"/>

<!-- Create a simple product for a bundle option -->
<createData entity="SimpleProduct2" stepKey="createSimpleProduct"/>

<!-- Login as admin -->
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
</before>
<after>
<!-- Delete the simple product -->
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>

<!-- Log out -->
<actionGroup ref="logout" stepKey="logout"/>
</after>

<!-- Create new bundle product -->
<actionGroup ref="GoToSpecifiedCreateProductPage" stepKey="createBundleProduct">
<argument name="productType" value="bundle"/>
</actionGroup>

<!-- Fill all main fields -->
<actionGroup ref="fillMainBundleProductForm" stepKey="fillMainProductFields"/>

<!-- Add the bundle option to the product -->
<actionGroup ref="addBundleOptionWithOneProduct" stepKey="addBundleOption">
<argument name="x" value="0"/>
<argument name="n" value="1"/>
<argument name="prodOneSku" value="$$createSimpleProduct.sku$$"/>
<argument name="prodTwoSku" value=""/>
<argument name="optionTitle" value="{{RadioButtonsOption.title}}"/>
<argument name="inputType" value="{{RadioButtonsOption.type}}"/>
</actionGroup>

<!-- Set product in created Website -->
<actionGroup ref="AdminAssignProductInWebsiteActionGroup" stepKey="selectProductInWebsites">
<argument name="website" value="$createWebsite.website[name]$"/>
</actionGroup>

<!-- Set Design settings for the product -->
<actionGroup ref="AdminSetProductDesignSettingsActionGroup" stepKey="setProductDesignSettings">
<argument name="designSettings" value="simpleLumaDesignThreeColumns"/>
</actionGroup>

<!-- Set Gift Options settings for the product -->
<actionGroup ref="AdminSwitchProductGiftMessageStatusActionGroup" stepKey="enableGiftMessageSettings">
<argument name="status" value="1"/>
</actionGroup>

<!-- Save product form -->
<actionGroup ref="saveProductForm" stepKey="clickSaveButton"/>

<!-- Open product page -->
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openStorefrontProductPage">
<argument name="productUrl" value="{{BundleProduct.name}}"/>
</actionGroup>

<!-- Assert product Design settings "layout 3 columns" -->
<seeElement selector="{{StorefrontProductPageDesignSection.layoutThreeColumns}}" stepKey="seeDesignChanges"/>

<!-- Assert Gift Option product settings is present -->
<actionGroup ref="StorefrontAddBundleProductFromProductToCartActionGroup" stepKey="addProductToCart">
<argument name="productName" value="{{BundleProduct.name}}"/>
</actionGroup>
<actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="openShoppingCart"/>
<actionGroup ref="StorefrontAssertGiftMessageFieldsActionGroup" stepKey="assertGiftMessageFieldsArePresent"/>

<!-- Open created product -->
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct">
<argument name="product" value="BundleProduct"/>
</actionGroup>
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct">
<argument name="product" value="BundleProduct"/>
</actionGroup>

<!-- Assert product in assigned to Website -->
<actionGroup ref="AssertProductIsAssignedToWebsite" stepKey="seeCustomWebsiteIsChecked">
<argument name="website" value="$createWebsite.website[name]$"/>
</actionGroup>

<!-- Edit product in Websites -->
<actionGroup ref="AdminUnassignProductInWebsiteActionGroup" stepKey="uncheckProductInWebsites">
<argument name="website" value="$createWebsite.website[name]$"/>
</actionGroup>

<!-- Edit product Search Engine Optimization settings -->
<actionGroup ref="AdminChangeProductSEOSettingsActionGroup" stepKey="editProductSEOSettings">
<argument name="productName" value="ApiBundleProduct.name"/>
</actionGroup>

<!-- Edit Design settings for the product -->
<actionGroup ref="AdminSetProductDesignSettingsActionGroup" stepKey="editProductDesignSettings"/>

<!-- Edit Gift Option product settings -->
<actionGroup ref="AdminSwitchProductGiftMessageStatusActionGroup" stepKey="disableGiftMessageSettings"/>

<!-- Save product form -->
<actionGroup ref="saveProductForm" stepKey="clickSaveProduct"/>

<!-- Verify Url Key after changing -->
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openProductPage">
<argument name="productUrl" value="{{ApiBundleProduct.name}}"/>
</actionGroup>

<!-- Assert product design settings "Layout empty" -->
<seeElement selector="{{StorefrontProductPageDesignSection.layoutTwoColumnsLeft}}" stepKey="seeNewDesignChanges"/>

<!-- Assert Gift Option product settings -->
<actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="openCart"/>
<dontSeeElement selector="{{StorefrontProductCartGiftOptionSection.giftOptions}}" stepKey="dontSeeGiftOptionBtn"/>

<!-- Delete created bundle product -->
<actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteProduct">
<argument name="product" value="BundleProduct"/>
</actionGroup>

<!-- Delete created Website -->
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite">
<argument name="websiteName" value="$createWebsite.website[name]$"/>
</actionGroup>
</test>
</tests>

Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
</td>
<td class="col-discont">
<?php if ($block->canShowPriceInfo($_item)) : ?>
<?= $block->escapeHtml($block->displayPriceAttribute('discount_amount')) ?>
<?= /* @noEscape */ $block->displayPriceAttribute('discount_amount') ?>
<?php else : ?>
&nbsp;
<?php endif; ?>
Expand Down
64 changes: 64 additions & 0 deletions app/code/Magento/Catalog/Model/Category/StoreCategories.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Model\Category;

use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\Catalog\Model\Category;
use Magento\Store\Api\GroupRepositoryInterface;

/**
* Fetcher for associated with store group categories.
*/
class StoreCategories
{
/**
* @var CategoryRepositoryInterface
*/
private $categoryRepository;

/**
* @var GroupRepositoryInterface
*/
private $groupRepository;

/**
* @param CategoryRepositoryInterface $categoryRepository
* @param GroupRepositoryInterface $groupRepository
*/
public function __construct(
CategoryRepositoryInterface $categoryRepository,
GroupRepositoryInterface $groupRepository
) {
$this->categoryRepository = $categoryRepository;
$this->groupRepository = $groupRepository;
}

/**
* Get all category ids for store.
*
* @param int|null $storeGroupId
* @return int[]
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function getCategoryIds(?int $storeGroupId = null): array
{
$rootCategoryId = $storeGroupId
? $this->groupRepository->get($storeGroupId)->getRootCategoryId()
: Category::TREE_ROOT_ID;
/** @var Category $rootCategory */
$rootCategory = $this->categoryRepository->get($rootCategoryId);
$categoriesIds = array_map(
function ($value) {
return (int) $value;
},
(array) $rootCategory->getAllChildren(true)
);

return $categoriesIds;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminAssignProductInWebsiteActionGroup">
<arguments>
<argument name="website" type="string"/>
</arguments>
<scrollTo selector="{{ProductInWebsitesSection.sectionHeader}}" stepKey="scrollToWebsitesSection"/>
<click selector="{{ProductInWebsitesSection.sectionHeader}}" stepKey="expandSection"/>
<waitForPageLoad stepKey="waitForPageOpened"/>
<checkOption selector="{{ProductInWebsitesSection.website(website)}}" stepKey="selectWebsite"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminChangeProductSEOSettingsActionGroup">
<arguments>
<argument name="productName" defaultValue="_defaultProduct.name"/>
</arguments>
<click selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="clickSearchEngineOptimizationTab"/>
<waitForPageLoad stepKey="waitForTabOpen"/>
<fillField selector="{{AdminProductSEOSection.urlKeyInput}}" userInput="{{productName}}" stepKey="setUrlKeyInput"/>
<fillField selector="{{AdminProductSEOSection.metaTitleInput}}" userInput="{{productName}}" stepKey="setMetaTitleInput"/>
<fillField selector="{{AdminProductSEOSection.metaKeywordsInput}}" userInput="{{productName}}" stepKey="setMetaKeywordsInput"/>
<fillField selector="{{AdminProductSEOSection.metaDescriptionInput}}" userInput="{{productName}}" stepKey="setMetaDescriptionInput"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminSetProductDesignSettingsActionGroup">
<arguments>
<argument name="designSettings" defaultValue="simpleBlankDesignTwoColumnsLeft"/>
</arguments>
<click selector="{{ProductDesignSection.DesignTab}}" stepKey="clickDesignTab"/>
<waitForPageLoad stepKey="waitForTabOpen"/>
<selectOption selector="{{ProductDesignSection.LayoutDropdown}}" userInput="{{designSettings.page_layout}}" stepKey="setLayout"/>
<selectOption selector="{{ProductDesignSection.productOptionsContainer}}" userInput="{{designSettings.options_container}}" stepKey="setDisplayProductOptions"/>
</actionGroup>
</actionGroups>
Loading

0 comments on commit 5ccd0f6

Please sign in to comment.