Skip to content

Commit a192377

Browse files
committed
Unit test & static test cases issues fixed
1 parent eea8ae5 commit a192377

File tree

7 files changed

+40
-25
lines changed

7 files changed

+40
-25
lines changed

app/code/Magento/CatalogInventory/Block/Plugin/ProductView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright 2011 Adobe
3+
* Copyright 2015 Adobe
44
* All Rights Reserved.
55
*/
66
namespace Magento\CatalogInventory\Block\Plugin;

app/code/Magento/CatalogInventory/Model/Product/QuantityValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright 2011 Adobe
3+
* Copyright 2024 Adobe
44
* All Rights Reserved.
55
*/
66
declare(strict_types=1);

app/code/Magento/CatalogInventory/Test/Unit/Block/Plugin/ProductViewTest.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -12,6 +12,7 @@
1212
use Magento\CatalogInventory\Api\Data\StockItemInterface;
1313
use Magento\CatalogInventory\Api\StockRegistryInterface;
1414
use Magento\CatalogInventory\Block\Plugin\ProductView;
15+
use Magento\CatalogInventory\Model\Product\QuantityValidator;
1516
use Magento\CatalogInventory\Model\Stock\Item;
1617
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1718
use Magento\Store\Model\Store;
@@ -35,6 +36,11 @@ class ProductViewTest extends TestCase
3536
*/
3637
protected $stockRegistry;
3738

39+
/**
40+
* @var QuantityValidator|MockObject
41+
*/
42+
protected $productQuantityValidator;
43+
3844
protected function setUp(): void
3945
{
4046
$objectManager = new ObjectManager($this);
@@ -47,10 +53,18 @@ protected function setUp(): void
4753
$this->stockRegistry = $this->getMockBuilder(StockRegistryInterface::class)
4854
->getMock();
4955

56+
57+
$this->productQuantityValidator = $objectManager->getObject(
58+
QuantityValidator::class,
59+
[
60+
'stockRegistry' => $this->stockRegistry
61+
]
62+
);
63+
5064
$this->block = $objectManager->getObject(
5165
ProductView::class,
5266
[
53-
'stockRegistry' => $this->stockRegistry
67+
'productQuantityValidator' => $this->productQuantityValidator
5468
]
5569
);
5670
}
@@ -59,6 +73,7 @@ public function testAfterGetQuantityValidators()
5973
{
6074
$result = [
6175
'validate-item-quantity' => [
76+
'minAllowed' => 1.0,
6277
'maxAllowed' => 5.0,
6378
'qtyIncrements' => 3.0
6479
]
@@ -86,9 +101,9 @@ public function testAfterGetQuantityValidators()
86101
->method('getStockItem')
87102
->with('productId', 'websiteId')
88103
->willReturn($this->stockItem);
104+
$this->stockItem->expects($this->any())->method('getMinSaleQty')->willReturn(1);
89105
$this->stockItem->expects($this->any())->method('getMaxSaleQty')->willReturn(5);
90106
$this->stockItem->expects($this->any())->method('getQtyIncrements')->willReturn(3);
91-
92107
$this->assertEquals($result, $this->block->afterGetQuantityValidators($productViewBlock, $validators));
93108
}
94109
}

app/code/Magento/GroupedProduct/ViewModel/ValidateQuantity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright 2011 Adobe
3+
* Copyright 2024 Adobe
44
* All Rights Reserved.
55
*/
66
declare(strict_types=1);

app/code/Magento/GroupedProduct/view/frontend/layout/catalog_product_view_type_grouped.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<!--
33
/**
4-
* Copyright 2011 Adobe
4+
* Copyright 2015 Adobe
55
* All Rights Reserved.
66
*/
77
-->

app/code/Magento/GroupedProduct/view/frontend/templates/product/view/type/grouped.phtml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22
/**
3-
* Copyright 2011 Adobe
3+
* Copyright 2015 Adobe
44
* All Rights Reserved.
55
*/
66

77
/**
88
* Grouped product data template
99
*
10-
* @var $block \Magento\Catalog\Block\Product\View\BaseImage
1110
* @var $block \Magento\GroupedProduct\Block\Product\View\Type\Grouped
11+
* @var $escaper \Magento\Framework\Escaper
1212
*/
1313
?>
1414
<?php
@@ -23,12 +23,12 @@
2323
<table class="table data grouped"
2424
id="super-product-table"
2525
data-mage-init='{ "Magento_GroupedProduct/js/product-ids-resolver": {} }'>
26-
<caption class="table-caption"><?= $block->escapeHtml(__('Grouped product items')) ?></caption>
26+
<caption class="table-caption"><?= $escaper->escapeHtml(__('Grouped product items')) ?></caption>
2727
<thead>
2828
<tr>
29-
<th class="col item" scope="col"><?= $block->escapeHtml(__('Product Name')) ?></th>
29+
<th class="col item" scope="col"><?= $escaper->escapeHtml(__('Product Name')) ?></th>
3030
<?php if ($_product->isSaleable()): ?>
31-
<th class="col qty" scope="col"><?= $block->escapeHtml(__('Qty')) ?></th>
31+
<th class="col qty" scope="col"><?= $escaper->escapeHtml(__('Qty')) ?></th>
3232
<?php endif; ?>
3333
</tr>
3434
</thead>
@@ -37,31 +37,31 @@
3737
<tbody>
3838
<?php foreach ($_associatedProducts as $_item): ?>
3939
<tr>
40-
<td data-th="<?= $block->escapeHtml(__('Product Name')) ?>" class="col item">
41-
<strong class="product-item-name"><?= $block->escapeHtml($_item->getName()) ?></strong>
40+
<td data-th="<?= $escaper->escapeHtml(__('Product Name')) ?>" class="col item">
41+
<strong class="product-item-name"><?= $escaper->escapeHtml($_item->getName()) ?></strong>
4242
<?php if ($block->getCanShowProductPrice($_product)): ?>
4343
<?php if ($block->getCanShowProductPrice($_item)): ?>
4444
<?= /* @noEscape */ $block->getProductPrice($_item) ?>
4545
<?php endif; ?>
4646
<?php endif; ?>
4747
</td>
4848
<?php if ($_product->isSaleable()): ?>
49-
<td data-th="<?= $block->escapeHtml(__('Qty')) ?>" class="col qty">
49+
<td data-th="<?= $escaper->escapeHtml(__('Qty')) ?>" class="col qty">
5050
<?php if ($_item->isSaleable()): ?>
5151
<div class="control qty">
5252
<input type="number"
53-
name="super_group[<?= $block->escapeHtmlAttr($_item->getId()) ?>]"
54-
data-selector="super_group[<?= $block->escapeHtmlAttr($_item->getId()) ?>]"
55-
value="<?= $block->escapeHtmlAttr($_item->getQty() * 1) ?>"
56-
title="<?= $block->escapeHtmlAttr(__('Qty')) ?>"
53+
name="super_group[<?= $escaper->escapeHtmlAttr($_item->getId()) ?>]"
54+
data-selector="super_group[<?= $escaper->escapeHtmlAttr($_item->getId()) ?>]"
55+
value="<?= $escaper->escapeHtmlAttr($_item->getQty() * 1) ?>"
56+
title="<?= $escaper->escapeHtmlAttr(__('Qty')) ?>"
5757
class="input-text qty"
58-
data-validate="<?= $block->escapeHtmlAttr($viewModel->getQuantityValidators($_item->getId(), $_item->getWebsiteId())) ?>"
58+
data-validate="<?= $escaper->escapeHtmlAttr($viewModel->getQuantityValidators($_item->getId(), $_item->getWebsiteId())) ?>"
5959
data-no-validation-for-zero-qty="true"
6060
data-errors-message-box="#validation-message-box"/>
6161
</div>
6262
<?php else: ?>
63-
<div class="stock unavailable" title="<?= $block->escapeHtmlAttr(__('Availability')) ?>">
64-
<span><?= $block->escapeHtml(__('Out of stock')) ?></span>
63+
<div class="stock unavailable" title="<?= $escaper->escapeHtmlAttr(__('Availability')) ?>">
64+
<span><?= $escaper->escapeHtml(__('Out of stock')) ?></span>
6565
</div>
6666
<?php endif; ?>
6767
</td>
@@ -89,7 +89,7 @@
8989
<tr>
9090
<td class="unavailable"
9191
colspan="<?php if ($_product->isSaleable()): ?>4<?php else: ?>3<?php endif; ?>">
92-
<?= $block->escapeHtml(__('No options of this product are available.')) ?>
92+
<?= $escaper->escapeHtml(__('No options of this product are available.')) ?>
9393
</td>
9494
</tr>
9595
</tbody>

app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_configure_type_grouped.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<!--
33
/**
4-
* Copyright 2011 Adobe
4+
* Copyright 2015 Adobe
55
* All Rights Reserved.
66
*/
77
-->

0 commit comments

Comments
 (0)