Skip to content

Commit

Permalink
Merge branch '2.4-develop' into PWA-1326
Browse files Browse the repository at this point in the history
  • Loading branch information
cpartica authored Mar 10, 2021
2 parents 7dc54dc + 3a814d9 commit 98db093
Show file tree
Hide file tree
Showing 8 changed files with 297 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</createData>

<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex">
<argument name="indices" value="cataloginventory_stock catalog_product_price"/>
<argument name="indices" value=""/>
</actionGroup>
</before>
<after>
Expand Down
25 changes: 25 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1392,9 +1392,34 @@
<entity name="SimpleProductUpdatePrice16" type="product2">
<data key="price">16.00</data>
</entity>
<entity name="SimpleProductUpdatePrice90" type="product2">
<data key="price">90.00</data>
</entity>
<entity name="SimpleProductUpdatePrice95" type="product2">
<data key="price">95.00</data>
</entity>
<entity name="SimpleProductUpdatePrice80" type="product2">
<data key="price">80.00</data>
</entity>
<entity name="ProductWithTwoTextFieldOptions" type="product">
<var key="sku" entityType="product" entityKey="sku" />
<requiredEntity type="product_option">ProductOptionField</requiredEntity>
<requiredEntity type="product_option">ProductOptionField2</requiredEntity>
</entity>
<entity name="SimpleProductWithCustomSku24MB01" type="product" extends="SimpleProduct2">
<data key="name" unique="suffix">ProductWithSku24MB01-</data>
<data key="sku" unique="suffix">24 MB01</data>
</entity>
<entity name="SimpleProductWithCustomSku24MB02" type="product" extends="SimpleProduct2">
<data key="name" unique="suffix">ProductWithSku24MB02-</data>
<data key="sku" unique="suffix">24 MB02 </data>
</entity>
<entity name="SimpleProductWithCustomSku24MB04" type="product" extends="SimpleProduct2">
<data key="name" unique="suffix">ProductWithSku24MB04-</data>
<data key="sku" unique="suffix">24 MB04 </data>
</entity>
<entity name="SimpleProductWithCustomSku24MB06" type="product" extends="SimpleProduct2">
<data key="name" unique="suffix">ProductWithSku24MB06-</data>
<data key="sku" unique="suffix">24 MB06 </data>
</entity>
</entities>
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,25 @@
<test name="CheckingCountryDropDownWithOneAllowedCountryTest">
<annotations>
<features value="Config"/>
<stories value="MAGETWO-96107: Additional blank option in country dropdown"/>
<stories value="Additional blank option in country dropdown"/>
<title value="Checking country drop-down with one allowed country"/>
<description value="Check country drop-down with one allowed country"/>
<severity value="MAJOR"/>
<testCaseId value="MAGETWO-96133"/>
<testCaseId value="MAGETWO-28511"/>
<group value="configuration"/>
</annotations>
<before>
<createData entity="EnableAdminAccountAllowCountry" stepKey="setAllowedCountries"/>
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanCache">
<argument name="tags" value="config full_page"/>
</actionGroup>
</before>
<after>
<comment userInput="Adding the comment to replace CliCacheFlushActionGroup action group ('cache:flush' command) for preserving Backward Compatibility" stepKey="flushCache"/>
<createData entity="DisableAdminAccountAllowCountry" stepKey="setDefaultValueForAllowCountries"/>
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanCache">
<argument name="tags" value="config full_page"/>
</actionGroup>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<actionGroup ref="AdminDeleteCustomerActionGroup" stepKey="deleteCustomer">
<argument name="customerEmail" value="CustomerEntityOne.email"/>
Expand All @@ -47,5 +53,12 @@
<click selector="{{StorefrontCustomerAddressSection.country}}" stepKey="clickToExpandCountryDropDown"/>
<see selector="{{StorefrontCustomerAddressSection.country}}" userInput="United States" stepKey="seeSelectedCountry"/>
<dontSee selector="{{StorefrontCustomerAddressSection.country}}" userInput="Brazil" stepKey="canNotSeeSelectedCountry"/>
<createData entity="DisableAdminAccountAllowCountry" stepKey="setDefaultValueForAllowCountries"/>
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanCache">
<argument name="tags" value="config full_page"/>
</actionGroup>
<reloadPage stepKey="realoadPageAfterConfigChanged"/>
<see selector="{{StorefrontCustomerAddressSection.country}}" userInput="United States" stepKey="seeUnitedStatesCountry"/>
<see selector="{{StorefrontCustomerAddressSection.country}}" userInput="Brazil" stepKey="seeBrazilCountry"/>
</test>
</tests>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?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="StorefrontQuickSearchUsingElasticSearchByProductSkuTest">
<annotations>
<features value="Elasticsearch7"/>
<stories value="Storefront Search"/>
<title value="Check that AND query is performed when searching using ElasticSearch 7"/>
<description value="Check that AND query is performed when searching using ElasticSearch 7"/>
<severity value="CRITICAL"/>
<testCaseId value="MC-31114"/>
<useCaseId value="MC-29788"/>
<group value="SearchEngineElasticsearch"/>
</annotations>
<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<actionGroup ref="DeleteAllProductsUsingProductGridActionGroup" stepKey="deleteAllProducts"/>

<createData entity="VirtualProduct" stepKey="createFirtsSimpleProduct"/>
<createData entity="SimpleProductWithCustomSku24MB06" stepKey="createSecondSimpleProduct"/>
<createData entity="SimpleProductWithCustomSku24MB04" stepKey="createThirdSimpleProduct"/>
<createData entity="SimpleProductWithCustomSku24MB02" stepKey="createFourthSimpleProduct"/>
<createData entity="SimpleProductWithCustomSku24MB01" stepKey="createFifthSimpleProduct"/>

<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanCache">
<argument name="tags" value=""/>
</actionGroup>
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex">
<argument name="indices" value=""/>
</actionGroup>
</before>
<after>
<deleteData createDataKey="createFirtsSimpleProduct" stepKey="deleteProductOne"/>

<actionGroup ref="DeleteAllProductsUsingProductGridActionGroup" stepKey="deleteAllProductsAfterTest"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdminPanel"/>
</after>
<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="openStoreFrontHomePage"/>
<actionGroup ref="StorefrontCheckQuickSearchStringActionGroup" stepKey="quickSearchByProductSku">
<argument name="phrase" value="24 MB04"/>
</actionGroup>

<see userInput="4" selector="{{StorefrontCatalogSearchMainSection.productCount}}" stepKey="assertSearchResultCount"/>

<actionGroup ref="StorefrontQuickSearchSeeProductByNameActionGroup" stepKey="assertSecondProductName">
<argument name="productName" value="$createSecondSimpleProduct.name$"/>
</actionGroup>
<actionGroup ref="StorefrontQuickSearchSeeProductByNameActionGroup" stepKey="assertThirdProductName">
<argument name="productName" value="$createThirdSimpleProduct.name$"/>
</actionGroup>
<actionGroup ref="StorefrontQuickSearchSeeProductByNameActionGroup" stepKey="assertFourthProductName">
<argument name="productName" value="$createFourthSimpleProduct.name$"/>
</actionGroup>
<actionGroup ref="StorefrontQuickSearchSeeProductByNameActionGroup" stepKey="assertFifthProductName">
<argument name="productName" value="$createFifthSimpleProduct.name$"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@
use Magento\Framework\View\Result\PageFactory;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\Helper\Xpath;
use Magento\TestFramework\Store\ExecuteInStoreContext;
use PHPUnit\Framework\TestCase;

/**
* Tests Address Edit Block
*
* @see \Magento\Customer\Block\Address\Edit
*
* @magentoAppArea frontend
* @magentoAppIsolation enabled
*
* @magentoDataFixture Magento/Customer/_files/customer.php
*/
class EditTest extends TestCase
{
Expand All @@ -41,9 +46,12 @@ class EditTest extends TestCase
/** @var CustomerRegistry */
private $customerRegistry;

/** @var RequestInterface */
/** @var RequestInterface */
private $request;

/** @var ExecuteInStoreContext */
private $executeInStoreContext;

/**
* @inheritdoc
*/
Expand All @@ -62,6 +70,7 @@ protected function setUp(): void
$this->block = $page->getLayout()->getBlock('customer_address_edit');
$this->addressRegistry = $this->objectManager->get(AddressRegistry::class);
$this->customerRegistry = $this->objectManager->get(CustomerRegistry::class);
$this->executeInStoreContext = $this->objectManager->get(ExecuteInStoreContext::class);
}

/**
Expand Down Expand Up @@ -174,4 +183,25 @@ public function testVatIdFieldNotVisible(): void
$inputXpath = "//div[contains(@class, 'taxvat')]//div/input[contains(@id,'vat_id') and @type='text']";
$this->assertEquals(0, Xpath::getElementsCountForXpath($inputXpath, $html));
}

/**
* @magentoDataFixture Magento/Customer/_files/customer.php
* @magentoDataFixture Magento/Customer/_files/attribute_postcode_store_label_address.php
*
* @return void
*/
public function testCheckPostCodeLabels(): void
{
$html = $this->executeInStoreContext->execute('default', [$this->block, 'toHtml']);
$this->assertEquals(
1,
Xpath::getElementsCountForXpath(
sprintf(
"//form[contains(@class, 'form-address-edit')]//label[@for='zip']/span[contains(text(), '%s')]",
'default store postcode label'
),
$html
)
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

use Magento\Customer\Api\AddressMetadataInterface;
use Magento\Customer\Api\Data\AddressInterface;
use Magento\Eav\Api\AttributeRepositoryInterface;
use Magento\Store\Model\StoreManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;

$objectManager = Bootstrap::getObjectManager();
/** @var AttributeRepositoryInterface $attributeRepository */
$attributeRepository = $objectManager->get(AttributeRepositoryInterface::class);
/** @var StoreManagerInterface $storeManager */
$storeManager = $objectManager->get(StoreManagerInterface::class);
$attribute = $attributeRepository->get(AddressMetadataInterface::ENTITY_TYPE_ADDRESS, AddressInterface::POSTCODE);
$storeLabels = $attribute->getStoreLabels();
$stores = $storeManager->getStores();
foreach ($stores as $store) {
$storeLabels[$store->getId()] = $store->getCode() . ' store postcode label';
}
$attribute->setStoreLabels($storeLabels);
$attributeRepository->save($attribute);
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

use Magento\Customer\Api\AddressMetadataInterface;
use Magento\Customer\Api\Data\AddressInterface;
use Magento\Eav\Api\AttributeRepositoryInterface;
use Magento\Framework\Registry;
use Magento\Store\Model\StoreManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;

$objectManager = Bootstrap::getObjectManager();
$registry = $objectManager->get(Registry::class);
/** @var AttributeRepositoryInterface $attributeRepository */
$attributeRepository = $objectManager->get(AttributeRepositoryInterface::class);
/** @var StoreManagerInterface $storeManager */
$storeManager = $objectManager->get(StoreManagerInterface::class);

$registry->unregister('isSecureArea');
$registry->register('isSecureArea', true);

$attribute = $attributeRepository->get(AddressMetadataInterface::ENTITY_TYPE_ADDRESS, AddressInterface::POSTCODE);
$attribute->setStoreLabels([]);
$attributeRepository->save($attribute);

$registry->unregister('isSecureArea');
$registry->register('isSecureArea', false);
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Eav\Model\Entity\Attribute\Frontend;

use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Stdlib\DateTime\DateTime;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\Store\ExecuteInStoreContext;
use PHPUnit\Framework\TestCase;

/**
* Checks Datetime attribute's frontend model
*
* @magentoAppArea frontend
*
* @see \Magento\Eav\Model\Entity\Attribute\Frontend\Datetime
*/
class DatetimeTest extends TestCase
{
/**
* @var int
*/
private const ONE_HOUR_IN_MILLISECONDS = 3600;

/**
* @var ObjectManagerInterface
*/
private $objectManager;

/**
* @var ProductAttributeRepositoryInterface
*/
private $attributeRepository;

/**
* @var ProductRepositoryInterface
*/
private $productRepository;

/**
* @var DateTime
*/
private $dateTime;

/**
* @var ExecuteInStoreContext
*/
private $executeInStoreContext;

/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();

$this->objectManager = Bootstrap::getObjectManager();
$this->attributeRepository = $this->objectManager->get(ProductAttributeRepositoryInterface::class);
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
$this->productRepository->cleanCache();
$this->dateTime = $this->objectManager->create(DateTime::class);
$this->executeInStoreContext = $this->objectManager->get(ExecuteInStoreContext::class);
}

/**
* @magentoDbIsolation disabled
*
* @magentoDataFixture Magento/Catalog/_files/product_two_websites.php
* @magentoDataFixture Magento/Catalog/_files/product_datetime_attribute.php
*
* @magentoConfigFixture default_store general/locale/timezone Europe/Moscow
* @magentoConfigFixture fixture_second_store_store general/locale/timezone Europe/Kiev
*
* @return void
*/
public function testFrontendValueOnDifferentWebsites(): void
{
$attribute = $this->attributeRepository->get('datetime_attribute');
$product = $this->productRepository->get('simple-on-two-websites');
$product->setDatetimeAttribute($this->dateTime->date('Y-m-d H:i:s'));
$firstWebsiteValue = $this->executeInStoreContext->execute(
'default',
[$attribute->getFrontend(), 'getValue'],
$product
);
$secondWebsiteValue = $this->executeInStoreContext->execute(
'fixture_second_store',
[$attribute->getFrontend(), 'getValue'],
$product
);
$this->assertEquals(
self::ONE_HOUR_IN_MILLISECONDS,
$this->dateTime->gmtTimestamp($firstWebsiteValue) - $this->dateTime->gmtTimestamp($secondWebsiteValue),
'The difference between values per different timezones is incorrect'
);
}
}

0 comments on commit 98db093

Please sign in to comment.