Skip to content

Commit 0329fd3

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-97239' into 2.2-develop-mftf-pr14
# Conflicts: # app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml
2 parents 02b3750 + d470766 commit 0329fd3

File tree

89 files changed

+2541
-322
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+2541
-322
lines changed

app/code/Magento/Bundle/Test/Mftf/ActionGroup/BundleProductsOnAdminActionGroup.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,14 @@
5151
<actionGroup name="CreateBundleProductForTwoSimpleProductsWithRadioTypeOptions" extends="CreateBundleProductForTwoSimpleProducts">
5252
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="Radio Buttons" after="fillOptionTitle" stepKey="selectInputType"/>
5353
</actionGroup>
54+
55+
<actionGroup name="CreateBundleProductForOneSimpleProductsWithRadioTypeOption" extends="CreateBundleProductForTwoSimpleProducts">
56+
<remove keyForRemoval="clickOnFiltersButton2"/>
57+
<remove keyForRemoval="clearFilters2"/>
58+
<remove keyForRemoval="fillNameFilter2"/>
59+
<remove keyForRemoval="applyFilters2"/>
60+
<remove keyForRemoval="selectSecondSimple"/>
61+
<remove keyForRemoval="fillDefaultQuantityForSecondProduct"/>
62+
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="Radio Buttons" after="fillOptionTitle" stepKey="selectInputType"/>
63+
</actionGroup>
5464
</actionGroups>

app/code/Magento/Bundle/Test/Mftf/Section/AdminProductFormBundleSection.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@
1616
<element name="addProductsToOption" type="button" selector="[data-index='modal_set']" timeout="30"/>
1717
<element name="bundleOptionXProductYQuantity" type="input" selector="[name='bundle_options[bundle_options][{{x}}][bundle_selections][{{y}}][selection_qty]']" parameterized="true"/>
1818
<element name="bundledItems" type="block" selector="[data-index=bundle-items]"/>
19+
<element name="priceTypeSwitcher" type="button" selector="div[data-index='price_type'] div[data-role='switcher']" timeout="30"/>
20+
<element name="bundleSelectionPriceType" type="select" selector="bundle_options[bundle_options][0][bundle_selections][0][selection_price_type]"/>
21+
<element name="bundleSelectionPriceValue" type="input" selector="bundle_options[bundle_options][0][bundle_selections][0][selection_price_value]"/>
1922
</section>
2023
</sections>

app/code/Magento/CacheInvalidate/Model/PurgeCache.php

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
use Magento\Framework\Cache\InvalidateLogger;
99

10+
/**
11+
* Purge cache action.
12+
*/
1013
class PurgeCache
1114
{
1215
const HEADER_X_MAGENTO_TAGS_PATTERN = 'X-Magento-Tags-Pattern';
@@ -26,6 +29,18 @@ class PurgeCache
2629
*/
2730
private $logger;
2831

32+
/**
33+
* Batch size of the purge request.
34+
*
35+
* Based on default Varnish 4 http_req_hdr_len size minus a 512 bytes margin for method,
36+
* header name, line feeds etc.
37+
*
38+
* @see https://varnish-cache.org/docs/4.1/reference/varnishd.html
39+
*
40+
* @var int
41+
*/
42+
private $requestSize = 7680;
43+
2944
/**
3045
* Constructor
3146
*
@@ -44,18 +59,68 @@ public function __construct(
4459
}
4560

4661
/**
47-
* Send curl purge request
48-
* to invalidate cache by tags pattern
62+
* Send curl purge request to invalidate cache by tags pattern.
4963
*
5064
* @param string $tagsPattern
5165
* @return bool Return true if successful; otherwise return false
5266
*/
5367
public function sendPurgeRequest($tagsPattern)
5468
{
69+
$successful = true;
5570
$socketAdapter = $this->socketAdapterFactory->create();
5671
$servers = $this->cacheServer->getUris();
57-
$headers = [self::HEADER_X_MAGENTO_TAGS_PATTERN => $tagsPattern];
5872
$socketAdapter->setOptions(['timeout' => 10]);
73+
74+
$formattedTagsChunks = $this->splitTags($tagsPattern);
75+
foreach ($formattedTagsChunks as $formattedTagsChunk) {
76+
if (!$this->sendPurgeRequestToServers($socketAdapter, $servers, $formattedTagsChunk)) {
77+
$successful = false;
78+
}
79+
}
80+
81+
return $successful;
82+
}
83+
84+
/**
85+
* Split tags by batches
86+
*
87+
* @param string $tagsPattern
88+
* @return \Generator
89+
*/
90+
private function splitTags(string $tagsPattern) : \Generator
91+
{
92+
$tagsBatchSize = 0;
93+
$formattedTagsChunk = [];
94+
$formattedTags = explode('|', $tagsPattern);
95+
foreach ($formattedTags as $formattedTag) {
96+
if ($tagsBatchSize + strlen($formattedTag) > $this->requestSize - count($formattedTagsChunk) - 1) {
97+
yield implode('|', $formattedTagsChunk);
98+
$formattedTagsChunk = [];
99+
$tagsBatchSize = 0;
100+
}
101+
102+
$tagsBatchSize += strlen($formattedTag);
103+
$formattedTagsChunk[] = $formattedTag;
104+
}
105+
if (!empty($formattedTagsChunk)) {
106+
yield implode('|', $formattedTagsChunk);
107+
}
108+
}
109+
110+
/**
111+
* Send curl purge request to servers to invalidate cache by tags pattern.
112+
*
113+
* @param \Zend\Http\Client\Adapter\Socket $socketAdapter
114+
* @param \Zend\Uri\Uri[] $servers
115+
* @param string $formattedTagsChunk
116+
* @return bool Return true if successful; otherwise return false
117+
*/
118+
private function sendPurgeRequestToServers(
119+
\Zend\Http\Client\Adapter\Socket $socketAdapter,
120+
array $servers,
121+
string $formattedTagsChunk
122+
): bool {
123+
$headers = [self::HEADER_X_MAGENTO_TAGS_PATTERN => $formattedTagsChunk];
59124
foreach ($servers as $server) {
60125
$headers['Host'] = $server->getHost();
61126
try {
@@ -69,12 +134,13 @@ public function sendPurgeRequest($tagsPattern)
69134
$socketAdapter->read();
70135
$socketAdapter->close();
71136
} catch (\Exception $e) {
72-
$this->logger->critical($e->getMessage(), compact('server', 'tagsPattern'));
137+
$this->logger->critical($e->getMessage(), compact('server', 'formattedTagsChunk'));
138+
73139
return false;
74140
}
75141
}
142+
$this->logger->execute(compact('servers', 'formattedTagsChunk'));
76143

77-
$this->logger->execute(compact('servers', 'tagsPattern'));
78144
return true;
79145
}
80146
}

app/code/Magento/Catalog/Model/ResourceModel/Product/Image.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Magento\Framework\App\ResourceConnection;
1414

1515
/**
16-
* Class for fast retrieval of all product images
16+
* Class for retrieval of all product images
1717
*/
1818
class Image
1919
{
@@ -76,15 +76,24 @@ public function getAllProductImages(): \Generator
7676

7777
/**
7878
* Get the number of unique pictures of products
79+
*
7980
* @return int
8081
*/
8182
public function getCountAllProductImages(): int
8283
{
83-
$select = $this->getVisibleImagesSelect()->reset('columns')->columns('count(*)');
84+
$select = $this->getVisibleImagesSelect()
85+
->reset('columns')
86+
->reset('distinct')
87+
->columns(
88+
new \Zend_Db_Expr('count(distinct value)')
89+
);
90+
8491
return (int) $this->connection->fetchOne($select);
8592
}
8693

8794
/**
95+
* Return Select to fetch all products images
96+
*
8897
* @return Select
8998
*/
9099
private function getVisibleImagesSelect(): Select

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,15 @@
246246
<waitForPageLoad stepKey="waitForProductPageSave"/>
247247
<see selector="{{AdminMessagesSection.success}}" userInput="You saved the product." stepKey="seeSaveConfirmation"/>
248248
</actionGroup>
249+
250+
<actionGroup name="AdminAssignProductToCategory">
251+
<arguments>
252+
<argument name="productId" type="string"/>
253+
<argument name="categoryName" type="string"/>
254+
</arguments>
255+
<amOnPage url="{{AdminProductEditPage.url(productId)}}" stepKey="amOnPage"/>
256+
<searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}" parameterArray="[{{categoryName}}]" stepKey="selectCategory"/>
257+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickOnSaveButton"/>
258+
<see selector="{{AdminMessagesSection.success}}" userInput="You saved the product." stepKey="seeSaveProductMessage"/>
259+
</actionGroup>
249260
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductGridActionGroup.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
1111
<!--Filter the product grid by new from date filter-->
1212
<actionGroup name="filterProductGridBySetNewFromDate">
1313
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
@@ -33,6 +33,7 @@
3333
<actionGroup name="deleteProductUsingProductGrid">
3434
<arguments>
3535
<argument name="product"/>
36+
<argument name="productCount" type="string" defaultValue="1"/>
3637
</arguments>
3738
<!--TODO use other action group for filtering grid when MQE-539 is implemented -->
3839
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="visitAdminProductPage"/>
@@ -48,7 +49,7 @@
4849
<click selector="{{AdminProductGridSection.bulkActionOption('Delete')}}" stepKey="clickDeleteAction"/>
4950
<waitForElementVisible selector="{{AdminProductGridConfirmActionSection.title}}" stepKey="waitForConfirmModal"/>
5051
<click selector="{{AdminProductGridConfirmActionSection.ok}}" stepKey="confirmProductDelete"/>
51-
<see selector="{{AdminMessagesSection.success}}" userInput="A total of 1 record(s) have been deleted." stepKey="seeSuccessMessage"/>
52+
<see selector="{{AdminMessagesSection.success}}" userInput="A total of {{productCount}} record(s) have been deleted." stepKey="seeSuccessMessage"/>
5253
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial2"/>
5354
</actionGroup>
5455

app/code/Magento/Catalog/Test/Mftf/Data/ProductConfigurableAttributeData.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
-->
88

99
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/dataProfileSchema.xsd">
1111
<entity name="colorProductAttribute" type="product_attribute">
1212
<data key="default_label" unique="suffix">Color</data>
1313
<data key="attribute_quantity">1</data>
14+
<data key="input_type">Dropdown</data>
1415
</entity>
1516
<entity name="colorProductAttribute1" type="product_attribute">
1617
<data key="name" unique="suffix">White</data>

app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,19 @@
260260
<requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity>
261261
<requiredEntity type="custom_attribute">CustomAttributeProductAttribute</requiredEntity>
262262
</entity>
263+
<entity name="ApiSimpleTwoHidden" type="product2">
264+
<data key="sku" unique="suffix">api-simple-product-two</data>
265+
<data key="type_id">simple</data>
266+
<data key="attribute_set_id">4</data>
267+
<data key="visibility">1</data>
268+
<data key="name" unique="suffix">Api Simple Product Two</data>
269+
<data key="price">234.00</data>
270+
<data key="urlKey" unique="suffix">api-simple-product-two</data>
271+
<data key="status">1</data>
272+
<data key="quantity">100</data>
273+
<requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity>
274+
<requiredEntity type="custom_attribute">CustomAttributeProductAttribute</requiredEntity>
275+
</entity>
263276
<entity name="ProductWithOptions2" type="product">
264277
<var key="sku" entityType="product" entityKey="sku" />
265278
<requiredEntity type="product_option">ProductOptionDropDownWithLongValuesTitle</requiredEntity>

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,5 +188,6 @@
188188
</section>
189189
<section name="AdminChooseAffectedAttributeSetPopup">
190190
<element name="confirm" type="button" selector="button[data-index='confirm_button']" timeout="30"/>
191+
<element name="closePopUp" type="button" selector=".modal-popup._show [data-role='closeBtn']" timeout="30"/>
191192
</section>
192193
</sections>

0 commit comments

Comments
 (0)