Skip to content

Commit 09eaf9f

Browse files
authored
Merge pull request #8299 from magento-l3/PR-L3-2023-05-11
PR-L3-2023-05-11
2 parents 2abc466 + 94133ec commit 09eaf9f

File tree

9 files changed

+199
-60
lines changed

9 files changed

+199
-60
lines changed

app/code/Magento/Backup/Model/ResourceModel/Db.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public function rollBackTransaction()
301301
*/
302302
public function runCommand($command)
303303
{
304-
$this->connection->query($command);
304+
$this->connection->multiQuery($command);
305305
return $this;
306306
}
307307
}

app/code/Magento/CatalogSearch/etc/search_request.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<queries>
6868
<query xsi:type="boolQuery" name="advanced_search_container" boost="1">
6969
<queryReference clause="should" ref="sku_query"/>
70-
<queryReference clause="should" ref="price_query"/>
70+
<queryReference clause="must" ref="price_query"/>
7171
<queryReference clause="should" ref="category_query"/>
7272
<queryReference clause="must" ref="visibility_query"/>
7373
</query>

app/code/Magento/GoogleAnalytics/Block/Ga.php

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public function getPageName()
8282
* @link https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference#set
8383
* @link https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference#gaObjectMethods
8484
* @deprecated 100.2.0 please use getPageTrackingData method
85+
* @see getPageTrackingData method
8586
*/
8687
public function getPageTrackingCode($accountId)
8788
{
@@ -103,6 +104,7 @@ public function getPageTrackingCode($accountId)
103104
*
104105
* @return string|void
105106
* @deprecated 100.2.0 please use getOrdersTrackingData method
107+
* @see getOrdersTrackingData method
106108
*/
107109
public function getOrdersTrackingCode()
108110
{
@@ -120,33 +122,35 @@ public function getOrdersTrackingCode()
120122
foreach ($collection as $order) {
121123
$result[] = "ga('set', 'currencyCode', '" . $order->getOrderCurrencyCode() . "');";
122124
foreach ($order->getAllVisibleItems() as $item) {
125+
$quantity = $item->getQtyOrdered() * 1;
126+
$format = fmod($quantity, 1) !== 0.00 ? '%.2f' : '%d';
123127
$result[] = sprintf(
124128
"ga('ec:addProduct', {
125129
'id': '%s',
126130
'name': '%s',
127-
'price': '%s',
128-
'quantity': %s
131+
'price': %.2f,
132+
'quantity': $format
129133
});",
130134
$this->escapeJsQuote($item->getSku()),
131135
$this->escapeJsQuote($item->getName()),
132-
$item->getPrice(),
133-
$item->getQtyOrdered()
136+
(float)$item->getPrice(),
137+
$quantity
134138
);
135139
}
136140

137141
$result[] = sprintf(
138142
"ga('ec:setAction', 'purchase', {
139143
'id': '%s',
140144
'affiliation': '%s',
141-
'revenue': '%s',
142-
'tax': '%s',
143-
'shipping': '%s'
145+
'revenue': %.2f,
146+
'tax': %.2f,
147+
'shipping': %.2f
144148
});",
145149
$order->getIncrementId(),
146150
$this->escapeJsQuote($this->_storeManager->getStore()->getFrontendName()),
147-
$order->getGrandTotal(),
148-
$order->getTaxAmount(),
149-
$order->getShippingAmount()
151+
(float)$order->getGrandTotal(),
152+
(float)$order->getTaxAmount(),
153+
(float)$order->getShippingAmount(),
150154
);
151155

152156
$result[] = "ga('send', 'pageview');";
@@ -232,19 +236,20 @@ public function getOrdersTrackingData()
232236

233237
foreach ($collection as $order) {
234238
foreach ($order->getAllVisibleItems() as $item) {
239+
$quantity = $item->getQtyOrdered() * 1;
235240
$result['products'][] = [
236241
'id' => $this->escapeJsQuote($item->getSku()),
237242
'name' => $this->escapeJsQuote($item->getName()),
238-
'price' => $item->getPrice(),
239-
'quantity' => $item->getQtyOrdered(),
243+
'price' => (float)$item->getPrice(),
244+
'quantity' => $quantity,
240245
];
241246
}
242247
$result['orders'][] = [
243248
'id' => $order->getIncrementId(),
244249
'affiliation' => $this->escapeJsQuote($this->_storeManager->getStore()->getFrontendName()),
245-
'revenue' => $order->getGrandTotal(),
246-
'tax' => $order->getTaxAmount(),
247-
'shipping' => $order->getShippingAmount(),
250+
'revenue' => (float)$order->getGrandTotal(),
251+
'tax' => (float)$order->getTaxAmount(),
252+
'shipping' => (float)$order->getShippingAmount(),
248253
];
249254
$result['currency'] = $order->getOrderCurrencyCode();
250255
}

app/code/Magento/GoogleAnalytics/Test/Unit/Block/GaTest.php

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,21 @@ public function testOrderTrackingCode()
115115
ga('ec:addProduct', {
116116
'id': 'sku0',
117117
'name': 'testName0',
118-
'price': '0.00',
118+
'price': 0.00,
119119
'quantity': 1
120120
});
121+
ga('ec:addProduct', {
122+
'id': 'sku1',
123+
'name': 'testName1',
124+
'price': 1.00,
125+
'quantity': 1.11
126+
});
121127
ga('ec:setAction', 'purchase', {
122128
'id': '100',
123129
'affiliation': 'test',
124-
'revenue': '10',
125-
'tax': '2',
126-
'shipping': '1'
130+
'revenue': 10.00,
131+
'tax': 2.00,
132+
'shipping': 2.00
127133
});
128134
ga('send', 'pageview');";
129135

@@ -163,9 +169,9 @@ public function testOrderTrackingData()
163169
[
164170
'id' => 100,
165171
'affiliation' => 'test',
166-
'revenue' => 10,
167-
'tax' => 2,
168-
'shipping' => 1
172+
'revenue' => 10.00,
173+
'tax' => 2.00,
174+
'shipping' => 2.0
169175
]
170176
],
171177
'products' => [
@@ -174,6 +180,12 @@ public function testOrderTrackingData()
174180
'name' => 'testName0',
175181
'price' => 0.00,
176182
'quantity' => 1
183+
],
184+
[
185+
'id' => 'sku1',
186+
'name' => 'testName1',
187+
'price' => 1.00,
188+
'quantity' => 1.11
177189
]
178190
],
179191
'currency' => 'USD'
@@ -204,7 +216,7 @@ public function testGetPageTrackingData()
204216
* @param int $orderItemCount
205217
* @return Order|MockObject
206218
*/
207-
protected function createOrderMock($orderItemCount = 1)
219+
protected function createOrderMock($orderItemCount = 2)
208220
{
209221
$orderItems = [];
210222
for ($i = 0; $i < $orderItemCount; $i++) {
@@ -213,8 +225,8 @@ protected function createOrderMock($orderItemCount = 1)
213225
->getMockForAbstractClass();
214226
$orderItemMock->expects($this->once())->method('getSku')->willReturn('sku' . $i);
215227
$orderItemMock->expects($this->once())->method('getName')->willReturn('testName' . $i);
216-
$orderItemMock->expects($this->once())->method('getPrice')->willReturn($i . '.00');
217-
$orderItemMock->expects($this->once())->method('getQtyOrdered')->willReturn($i + 1);
228+
$orderItemMock->expects($this->once())->method('getPrice')->willReturn((float)($i . '.0000'));
229+
$orderItemMock->expects($this->once())->method('getQtyOrdered')->willReturn($i == 1 ? 1.11 : $i + 1);
218230
$orderItems[] = $orderItemMock;
219231
}
220232

@@ -223,9 +235,9 @@ protected function createOrderMock($orderItemCount = 1)
223235
->getMock();
224236
$orderMock->expects($this->once())->method('getIncrementId')->willReturn(100);
225237
$orderMock->expects($this->once())->method('getAllVisibleItems')->willReturn($orderItems);
226-
$orderMock->expects($this->once())->method('getGrandTotal')->willReturn(10);
227-
$orderMock->expects($this->once())->method('getTaxAmount')->willReturn(2);
228-
$orderMock->expects($this->once())->method('getShippingAmount')->willReturn($orderItemCount);
238+
$orderMock->expects($this->once())->method('getGrandTotal')->willReturn(10.00);
239+
$orderMock->expects($this->once())->method('getTaxAmount')->willReturn(2.00);
240+
$orderMock->expects($this->once())->method('getShippingAmount')->willReturn(round((float)$orderItemCount, 2));
229241
$orderMock->expects($this->once())->method('getOrderCurrencyCode')->willReturn('USD');
230242
return $orderMock;
231243
}
@@ -241,7 +253,7 @@ protected function createCollectionMock()
241253

242254
$collectionMock->expects($this->any())
243255
->method('getIterator')
244-
->willReturn(new \ArrayIterator([$this->createOrderMock(1)]));
256+
->willReturn(new \ArrayIterator([$this->createOrderMock(2)]));
245257
return $collectionMock;
246258
}
247259

app/code/Magento/MediaGalleryRenditions/etc/media_content.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<search>
1010
<patterns>
1111
<pattern name="media_gallery_renditions">/{{media url=(?:"|&amp;quot;)(?:.renditions)?(.*?)(?:"|&amp;quot;)}}/</pattern>
12-
<pattern name="media_gallery">/{{media url="?(?:.*?\.renditions\/)(.*?)"?}}/</pattern>
12+
<pattern name="media_gallery">/{{media url="?(?:.*?\.renditions\/)?(.*?)"?}}/</pattern>
1313
<pattern name="wysiwyg">/src=".*\/media\/(?:.renditions\/)*(.*?)"/</pattern>
1414
<pattern name="catalog_image">/^\/?media\/(?:.renditions\/)?(.*)/</pattern>
1515
<pattern name="catalog_image_with_pub">/^\/pub\/?media\/(?:.renditions\/)?(.*)/</pattern>

dev/tests/integration/testsuite/Magento/CatalogSearch/Controller/Advanced/ResultTest.php

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,42 @@ public function testExecuteWithArrayInParam(array $searchParams): void
165165
);
166166
}
167167

168+
/**
169+
* Advanced search test by difference product attributes.
170+
*
171+
* @magentoAppArea frontend
172+
* @magentoDataFixture Magento/CatalogSearch/_files/product_for_search.php
173+
* @magentoDataFixture Magento/CatalogSearch/_files/full_reindex.php
174+
* @dataProvider testDataForAttributesCombination
175+
*
176+
* @param array $searchParams
177+
* @param bool $isProductShown
178+
* @return void
179+
*/
180+
public function testExecuteForAttributesCombination(array $searchParams, bool $isProductShown): void
181+
{
182+
$this->getRequest()->setQuery(
183+
$this->_objectManager->create(
184+
Parameters::class,
185+
[
186+
'values' => $searchParams
187+
]
188+
)
189+
);
190+
$this->dispatch('catalogsearch/advanced/result');
191+
$responseBody = $this->getResponse()->getBody();
192+
193+
if ($isProductShown) {
194+
$this->assertStringContainsString('Simple product name', $responseBody);
195+
} else {
196+
$this->assertStringContainsString(
197+
'We can&#039;t find any items matching these search criteria.',
198+
$responseBody
199+
);
200+
}
201+
$this->assertStringNotContainsString('Not visible simple product', $responseBody);
202+
}
203+
168204
/**
169205
* Data provider with array in params values
170206
*
@@ -339,4 +375,71 @@ private function getAttributeOptionValueByOptionLabel(string $attributeCode, str
339375

340376
return $attribute->getSource()->getOptionId($optionLabel);
341377
}
378+
379+
/**
380+
* Data provider with strings for quick search.
381+
*
382+
* @return array
383+
*/
384+
public function testDataForAttributesCombination(): array
385+
{
386+
return [
387+
'search_product_by_name_and_price' => [
388+
[
389+
'name' => 'Simple product name',
390+
'sku' => '',
391+
'description' => '',
392+
'short_description' => '',
393+
'price' => [
394+
'from' => 99,
395+
'to' => 101,
396+
],
397+
'test_searchable_attribute' => '',
398+
],
399+
true
400+
],
401+
'search_product_by_name_and_price_not_shown' => [
402+
[
403+
'name' => 'Simple product name',
404+
'sku' => '',
405+
'description' => '',
406+
'short_description' => '',
407+
'price' => [
408+
'from' => 101,
409+
'to' => 102,
410+
],
411+
'test_searchable_attribute' => '',
412+
],
413+
false
414+
],
415+
'search_product_by_sku' => [
416+
[
417+
'name' => '',
418+
'sku' => 'simple_for_search',
419+
'description' => '',
420+
'short_description' => '',
421+
'price' => [
422+
'from' => 99,
423+
'to' => 101,
424+
],
425+
'test_searchable_attribute' => '',
426+
],
427+
true
428+
],
429+
'search_product_by_sku_not_shown' => [
430+
[
431+
'name' => '',
432+
'sku' => 'simple_for_search',
433+
'description' => '',
434+
'short_description' => '',
435+
'price' => [
436+
'from' => 990,
437+
'to' => 1010,
438+
],
439+
'test_searchable_attribute' => '',
440+
],
441+
false
442+
],
443+
];
444+
}
342445
}

dev/tests/integration/testsuite/Magento/Framework/Backup/DbTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
namespace Magento\Framework\Backup;
88

99
use Magento\Backup\Helper\Data;
10+
use Magento\Backup\Model\ResourceModel\Db;
1011
use Magento\Framework\App\Filesystem\DirectoryList;
1112
use Magento\Framework\Filesystem;
1213
use Magento\Framework\Module\Setup;
1314
use Magento\TestFramework\Helper\Bootstrap;
14-
use PHPUnit\Framework\TestCase;
15+
use Magento\Framework\Backup\BackupInterface;
1516

1617
/**
1718
* Provide tests for \Magento\Framework\Backup\Db.
@@ -32,16 +33,17 @@ public static function setUpBeforeClass(): void
3233
}
3334

3435
/**
35-
* Test db backup includes triggers.
36+
* Test db backup and rollback including triggers.
3637
*
3738
* @magentoConfigFixture default/system/backup/functionality_enabled 1
3839
* @magentoDataFixture Magento/Framework/Backup/_files/trigger.php
3940
* @magentoDbIsolation disabled
4041
*/
41-
public function testBackupIncludesCustomTriggers()
42+
public function testBackupAndRollbackIncludesCustomTriggers()
4243
{
4344
$helper = Bootstrap::getObjectManager()->get(Data::class);
4445
$time = time();
46+
/** BackupInterface $backupManager */
4547
$backupManager = Bootstrap::getObjectManager()->get(Factory::class)->create(
4648
Factory::TYPE_DB
4749
)->setBackupExtension(
@@ -60,6 +62,12 @@ public function testBackupIncludesCustomTriggers()
6062
'/CREATE TRIGGER `?test_custom_trigger`? AFTER INSERT ON `?'. $tableName . '`? FOR EACH ROW/',
6163
$content
6264
);
65+
66+
// Test rollback
67+
$backupResourceModel = Bootstrap::getObjectManager()->get(Db::class);
68+
$backupManager->setResourceModel($backupResourceModel);
69+
$backupManager->rollback();
70+
6371
//Clean up.
6472
$write->delete('/backups/' . $time . '_db_testbackup.sql');
6573
}

dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ public function contentProvider()
7777
2020
7878
]
7979
],
80+
'Relevant paths in content without quotes' => [
81+
'content {{media url=testDirectory/path.jpg}} content',
82+
[
83+
2020
84+
]
85+
],
8086
'Relevant wysiwyg paths in content' => [
8187
'content <img src="https://domain.com/media/testDirectory/path.jpg"}} content',
8288
[

0 commit comments

Comments
 (0)