Skip to content

Commit 8d08e94

Browse files
committed
Merge branch '2.4-develop' into Refactoring-AdminConfigurableProductCreateTest
2 parents e762b52 + 592c792 commit 8d08e94

File tree

58 files changed

+1321
-178
lines changed

Some content is hidden

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

58 files changed

+1321
-178
lines changed

app/code/Magento/AwsS3/Test/Mftf/Helper/S3FileAssertions.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,21 @@ public function assertFileExists($filePath, $message = ''): void
149149
$this->assertTrue($this->driver->isExists($filePath), $message);
150150
}
151151

152+
/**
153+
* Asserts that a file with the given glob pattern exists in the given path on the remote storage system
154+
*
155+
* @param string $path
156+
* @param string $pattern
157+
* @param string $message
158+
*
159+
* @throws \Magento\Framework\Exception\FileSystemException
160+
*/
161+
public function assertGlobbedFileExists($path, $pattern, $message = ""): void
162+
{
163+
$files = $this->driver->search($pattern, $path);
164+
$this->assertNotEmpty($files, $message);
165+
}
166+
152167
/**
153168
* Assert a file does not exist on the remote storage system
154169
*
@@ -206,6 +221,24 @@ public function assertFileContainsString($filePath, $text, $message = ""): void
206221
$this->assertStringContainsString($text, $this->driver->fileGetContents($filePath), $message);
207222
}
208223

224+
/**
225+
* Asserts that a file with the given glob pattern at the given path on the remote storage system contains a given string
226+
*
227+
* @param string $path
228+
* @param string $pattern
229+
* @param string $text
230+
* @param int $fileIndex
231+
* @param string $message
232+
* @return void
233+
*
234+
* @throws \Magento\Framework\Exception\FileSystemException
235+
*/
236+
public function assertGlobbedFileContainsString($path, $pattern, $text, $fileIndex = 0, $message = ""): void
237+
{
238+
$files = $this->driver->search($pattern, $path);
239+
$this->assertStringContainsString($text, $this->driver->fileGetContents($files[$fileIndex] ?? ''), $message);
240+
}
241+
209242
/**
210243
* Assert a file on the remote storage system does not contain a given string
211244
*

app/code/Magento/Catalog/Block/Ui/ProductViewCounter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public function getCurrentProductData()
153153
$this->productRenderCollectorComposite
154154
->collect($product, $productRender);
155155
$data = $this->hydrator->extract($productRender);
156+
$data['is_available'] = $product->isAvailable();
156157

157158
$currentProductData = [
158159
'items' => [

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
<data key="name">TestFooBar</data>
4040
<data key="sku" unique="suffix">foobar</data>
4141
</entity>
42+
<entity name="ApiSimpleProductWithDoubleSpaces" type="product" extends="ApiSimpleProduct">
43+
<data key="name">Simple Product Double Space</data>
44+
<data key="sku" unique="suffix">simple-product double-space</data>
45+
</entity>
4246
<entity name="ApiSimpleProductWithSpecCharInName" type="product" extends="ApiSimpleProduct">
4347
<data key="name">Pursuit Lumaflex&#38;trade; Tone Band</data>
4448
<data key="sku" unique="suffix">x&#38;trade;</data>

app/code/Magento/Catalog/Test/Mftf/Helper/LocalFileAssertions.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,22 @@ public function assertFileExists($filePath, $message = ''): void
134134
$this->assertTrue($this->driver->isExists($realPath), $message);
135135
}
136136

137+
/**
138+
* Asserts that a file with the given glob pattern exists in the given path
139+
*
140+
* @param string $path
141+
* @param string $pattern
142+
* @param string $message
143+
*
144+
* @throws \Magento\Framework\Exception\FileSystemException
145+
*/
146+
public function assertGlobbedFileExists($path, $pattern, $message = ""): void
147+
{
148+
$realPath = $this->expandPath($path);
149+
$files = $this->driver->search($pattern, $realPath);
150+
$this->assertNotEmpty($files, $message);
151+
}
152+
137153
/**
138154
* Assert a file does not exist
139155
*
@@ -195,6 +211,25 @@ public function assertFileContainsString($filePath, $text, $message = ""): void
195211
$this->assertStringContainsString($text, $this->driver->fileGetContents($realPath), $message);
196212
}
197213

214+
/**
215+
* Asserts that a file with the given glob pattern at the given path contains a given string
216+
*
217+
* @param string $path
218+
* @param string $pattern
219+
* @param string $text
220+
* @param int $fileIndex
221+
* @param string $message
222+
* @return void
223+
*
224+
* @throws \Magento\Framework\Exception\FileSystemException
225+
*/
226+
public function assertGlobbedFileContainsString($path, $pattern, $text, $fileIndex = 0, $message = ""): void
227+
{
228+
$realPath = $this->expandPath($path);
229+
$files = $this->driver->search($pattern, $realPath);
230+
$this->assertStringContainsString($text, $this->driver->fileGetContents($files[$fileIndex] ?? ''), $message);
231+
}
232+
198233
/**
199234
* Assert a file does not contain a given string
200235
*
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminShowDoubleSpacesInProductGrid">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Edit products"/>
14+
<title value="Show double spaces in the product grid"/>
15+
<description value="Admin should be able to see double spaces in the Name and Sku fields in the product grid"/>
16+
<testCaseId value="MC-40725"/>
17+
<useCaseId value="MC-40122"/>
18+
<severity value="AVERAGE"/>
19+
<group value="Catalog"/>
20+
</annotations>
21+
22+
<before>
23+
<createData entity="ApiCategory" stepKey="createCategory"/>
24+
<createData entity="ApiSimpleProductWithDoubleSpaces" stepKey="createProduct">
25+
<requiredEntity createDataKey="createCategory"/>
26+
</createData>
27+
<magentoCLI command="cron:run --group=index" stepKey="cronRun"/>
28+
<magentoCLI command="cron:run --group=index" stepKey="cronRunSecondTime"/>
29+
</before>
30+
31+
<after>
32+
<actionGroup ref="AdminDeleteAllProductsFromGridActionGroup" stepKey="deleteProduct"/>
33+
<actionGroup ref="ClearFiltersAdminProductGridActionGroup" stepKey="clearGridFilters"/>
34+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
35+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
36+
</after>
37+
38+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
39+
<actionGroup ref="AdminOpenCatalogProductPageActionGroup" stepKey="goToProductCatalogPage"/>
40+
<actionGroup ref="FilterProductGridBySkuActionGroup" stepKey="searchForProduct">
41+
<argument name="product" value="$createProduct$"/>
42+
</actionGroup>
43+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="assertProductName">
44+
<argument name="column" value="Name"/>
45+
<argument name="value" value="$createProduct.name$"/>
46+
</actionGroup>
47+
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="assertProductSku">
48+
<argument name="column" value="SKU"/>
49+
<argument name="value" value="$createProduct.sku$"/>
50+
</actionGroup>
51+
</test>
52+
</tests>

app/code/Magento/Catalog/Test/Unit/Block/Ui/ProductViewCounterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,14 @@ public function testGetCurrentProductDataWithNonEmptyProduct()
166166
{
167167
$productMock = $this->getMockBuilder(ProductInterface::class)
168168
->disableOriginalConstructor()
169+
->addMethods(['isAvailable'])
169170
->getMockForAbstractClass();
170171
$productRendererMock = $this->getMockBuilder(ProductRenderInterface::class)
171172
->disableOriginalConstructor()
172173
->getMockForAbstractClass();
173174
$storeMock = $this->getMockBuilder(Store::class)
174175
->disableOriginalConstructor()
175176
->getMock();
176-
177177
$this->registryMock->expects($this->once())
178178
->method('registry')
179179
->with('product')

app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
<settings>
133133
<addField>true</addField>
134134
<filter>text</filter>
135-
<bodyTmpl>ui/grid/cells/html</bodyTmpl>
135+
<bodyTmpl>Magento_Catalog/grid/cells/preserved</bodyTmpl>
136136
<label translate="true">Name</label>
137137
</settings>
138138
</column>
@@ -155,7 +155,7 @@
155155
<column name="sku" sortOrder="60">
156156
<settings>
157157
<filter>text</filter>
158-
<bodyTmpl>ui/grid/cells/html</bodyTmpl>
158+
<bodyTmpl>Magento_Catalog/grid/cells/preserved</bodyTmpl>
159159
<label translate="true">SKU</label>
160160
</settings>
161161
</column>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!--
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<div class="data-grid-cell-content white-space-preserved" html="$col.getLabel($row())"/>

app/code/Magento/Catalog/view/base/web/js/product/addtocart-button.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ define([
5555
return row['is_salable'];
5656
},
5757

58+
/**
59+
* Depends on this option, stock status text can be "In stock" or "Out Of Stock"
60+
*
61+
* @param {Object} row
62+
* @returns {Boolean}
63+
*/
64+
isAvailable: function (row) {
65+
return row['is_available'];
66+
},
67+
5868
/**
5969
* Depends on this option, "Add to cart" button can be shown or hide. Depends on backend configuration
6070
*

app/code/Magento/Catalog/view/frontend/templates/product/compare/list.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
</button>
7979
</form>
8080
<?php else :?>
81-
<?php if ($item->getIsSalable()) :?>
81+
<?php if ($item->isAvailable()) :?>
8282
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
8383
<?php else :?>
8484
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>

app/code/Magento/Catalog/view/frontend/templates/product/list.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ $_helper = $block->getData('outputHelper');
153153
<?php endforeach; ?>
154154
</ol>
155155
</div>
156-
<?= $block->getToolbarHtml() ?>
156+
<?= $block->getChildBlock('toolbar')->setIsBottom(true)->toHtml() ?>
157157
<script type="text/x-magento-init">
158158
{
159159
"[data-role=tocart-form], .form.map.checkout": {

app/code/Magento/Catalog/view/frontend/templates/product/list/items.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ $_item = null;
287287
</form>
288288
<?php endif; ?>
289289
<?php else:?>
290-
<?php if ($_item->getIsSalable()):?>
290+
<?php if ($_item->isAvailable()):?>
291291
<div class="stock available">
292292
<span><?= $block->escapeHtml(__('In stock')) ?></span>
293293
</div>

app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar.phtml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,23 @@
1010
*
1111
* @var $block \Magento\Catalog\Block\Product\ProductList\Toolbar
1212
*/
13-
14-
// phpcs:disable Magento2.Security.IncludeFile.FoundIncludeFile
15-
// phpcs:disable PSR2.Methods.FunctionCallSignature.SpaceBeforeOpenBracket
1613
?>
1714
<?php if ($block->getCollection()->getSize()) :?>
1815
<?php $widget = $this->helper(\Magento\Framework\Json\Helper\Data::class)->jsonDecode($block->getWidgetOptionsJson());
1916
$widgetOptions = $this->helper(\Magento\Framework\Json\Helper\Data::class)->jsonEncode($widget['productListToolbarForm']);
2017
?>
2118
<div class="toolbar toolbar-products" data-mage-init='{"productListToolbarForm":<?= /* @noEscape */ $widgetOptions ?>}'>
22-
<?php if ($block->isExpanded()) :?>
23-
<?php include ($block->getTemplateFile('Magento_Catalog::product/list/toolbar/viewmode.phtml')) ?>
24-
<?php endif; ?>
25-
26-
<?php include ($block->getTemplateFile('Magento_Catalog::product/list/toolbar/amount.phtml')) ?>
27-
28-
<?= $block->getPagerHtml() ?>
29-
30-
<?php include ($block->getTemplateFile('Magento_Catalog::product/list/toolbar/limiter.phtml')) ?>
31-
32-
<?php if ($block->isExpanded()) :?>
33-
<?php include ($block->getTemplateFile('Magento_Catalog::product/list/toolbar/sorter.phtml')) ?>
34-
<?php endif; ?>
19+
<?php if ($block->getIsBottom()): ?>
20+
<?= $block->getPagerHtml() ?>
21+
<?= $block->fetchView($block->getTemplateFile('Magento_Catalog::product/list/toolbar/limiter.phtml')) ?>
22+
<?php else: ?>
23+
<?php if ($block->isExpanded()): ?>
24+
<?= $block->fetchView($block->getTemplateFile('Magento_Catalog::product/list/toolbar/viewmode.phtml')) ?>
25+
<?php endif ?>
26+
<?= $block->fetchView($block->getTemplateFile('Magento_Catalog::product/list/toolbar/amount.phtml')) ?>
27+
<?php if ($block->isExpanded()): ?>
28+
<?= $block->fetchView($block->getTemplateFile('Magento_Catalog::product/list/toolbar/sorter.phtml')) ?>
29+
<?php endif ?>
30+
<?php endif ?>
3531
</div>
3632
<?php endif ?>

app/code/Magento/Catalog/view/frontend/templates/product/listing.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ $_helper = $this->helper(Magento\Catalog\Helper\Output::class);
6363
. ' data-mage-init=\'{ "redirectUrl": { "event": "click", url: "' . $block->escapeUrl($block->getAddToCartUrl($_product)) . '"} }\'>'
6464
. '<span>' . $block->escapeHtml(__('Add to Cart')) . '</span></button>';
6565
} else {
66-
$info['button'] = $_product->getIsSalable() ? '<div class="stock available"><span>' . $block->escapeHtml(__('In stock')) . '</span></div>' :
66+
$info['button'] = $_product->isAvailable() ? '<div class="stock available"><span>' . $block->escapeHtml(__('In stock')) . '</span></div>' :
6767
'<div class="stock unavailable"><span>' . $block->escapeHtml(__('Out of stock')) . '</span></div>';
6868
}
6969

app/code/Magento/Catalog/view/frontend/templates/product/widget/new/column/new_default_list.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
</button>
5353
<?php endif; ?>
5454
<?php else :?>
55-
<?php if ($_product->getIsSalable()) :?>
55+
<?php if ($_product->isAvailable()) :?>
5656
<div class="stock available" title="<?= $block->escapeHtmlAttr(__('Availability')) ?>">
5757
<span><?= $block->escapeHtml(__('In stock')) ?></span>
5858
</div>

app/code/Magento/Catalog/view/frontend/templates/product/widget/new/content/new_grid.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if ($exist = ($block->getProductCollection() && $block->getProductCollection()->
8989
</button>
9090
<?php endif; ?>
9191
<?php else :?>
92-
<?php if ($_item->getIsSalable()) :?>
92+
<?php if ($_item->isAvailable()) :?>
9393
<div class="stock available">
9494
<span><?= $block->escapeHtml(__('In stock')) ?></span>
9595
</div>

app/code/Magento/Catalog/view/frontend/templates/product/widget/new/content/new_list.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ if ($exist = ($block->getProductCollection() && $block->getProductCollection()->
8888
</button>
8989
<?php endif; ?>
9090
<?php else :?>
91-
<?php if ($_item->getIsSalable()) :?>
91+
<?php if ($_item->isAvailable()) :?>
9292
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
9393
<?php else :?>
9494
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>

app/code/Magento/Catalog/view/frontend/web/template/product/addtocart-button.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
</button>
1616
</if>
1717

18-
<ifnot args="isSalable($row())">
18+
<if args="isAvailable($row()) === false">
1919
<div class="stock unavailable">
2020
<text args="$t('Availability')"/>
2121
<span translate="'Out of stock'"/>
2222
</div>
23-
</ifnot>
23+
</if>
2424
</if>

app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ use Magento\Framework\App\Action\Action;
7777
</button>
7878
</form>
7979
<?php else: ?>
80-
<?php if ($_item->getIsSalable()): ?>
80+
<?php if ($_item->isAvailable()): ?>
8181
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
8282
<?php else: ?>
8383
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>

0 commit comments

Comments
 (0)