Skip to content

Commit eec3ff9

Browse files
committed
ACP2E-3842: [Mainline]After applying ACP2E-3769_2.4.6-p9 - Deprecated Functionality: Implicit conversion from float
1 parent bfb51d1 commit eec3ff9

File tree

2 files changed

+94
-2
lines changed
  • app/code/Magento/SalesRule/Model/Rule/Condition/Product
  • dev/tests/integration/testsuite/Magento/SalesRule/Model/Rule/Condition/Product

2 files changed

+94
-2
lines changed

app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ private function validateSubSelectConditions(mixed $item): bool
208208
* @param mixed $item
209209
* @param mixed $attr
210210
* @param float $total
211-
* @return float
211+
* @return float|mixed
212212
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
213213
*/
214-
private function getBaseRowTotalForChildrenProduct(mixed $item, mixed $attr, float $total): float
214+
private function getBaseRowTotalForChildrenProduct(mixed $item, mixed $attr, float $total): mixed
215215
{
216216
$hasValidChild = false;
217217
$useChildrenTotal = ($item->getProductType() == Type::TYPE_BUNDLE);
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
7+
namespace Magento\SalesRule\Model\Rule\Condition\Product;
8+
9+
use Magento\Framework\ObjectManagerInterface;
10+
use Magento\Quote\Model\Quote;
11+
use Magento\SalesRule\Model\Rule\Condition\Product as SalesRuleProduct;
12+
use Magento\TestFramework\Helper\Bootstrap;
13+
use PHPUnit\Framework\TestCase;
14+
15+
/**
16+
* Integration test for Subselect::validate() method returning true.
17+
*
18+
* @magentoAppArea frontend
19+
* @magentoDbIsolation enabled
20+
*/
21+
class SubselectTest extends TestCase
22+
{
23+
/**
24+
* @var ObjectManagerInterface
25+
*/
26+
private $objectManager;
27+
28+
/**
29+
* @var Subselect
30+
*/
31+
private $subselectCondition;
32+
33+
/**
34+
* @var SalesRuleProduct
35+
*/
36+
private $productCondition;
37+
38+
protected function setUp(): void
39+
{
40+
$this->objectManager = Bootstrap::getObjectManager();
41+
$this->productCondition = $this->objectManager->create(SalesRuleProduct::class);
42+
$this->subselectCondition = $this->objectManager->create(
43+
Subselect::class,
44+
[
45+
'context' => $this->objectManager->get(\Magento\Rule\Model\Condition\Context::class),
46+
'ruleConditionProduct' => $this->productCondition
47+
]
48+
);
49+
}
50+
51+
/**
52+
* Test validate() method returning true for total quantity >= 2 with single shipping.
53+
*
54+
* @magentoDataFixture Magento/Catalog/_files/products.php
55+
*/
56+
public function testValidateReturnsTrueForSufficientQuantity()
57+
{
58+
$this->subselectCondition->setData([
59+
'attribute' => 'qty',
60+
'operator' => '>=',
61+
'value' => 2,
62+
'aggregator' => 'all',
63+
]);
64+
$productCondition = $this->objectManager->create(SalesRuleProduct::class);
65+
$productCondition->setData([
66+
'attribute' => 'sku',
67+
'operator' => '==',
68+
'value' => 'simple',
69+
]);
70+
$this->subselectCondition->setConditions([$productCondition]);
71+
$productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
72+
$product = $productRepository->get('simple');
73+
$product->setPrice(100.50);
74+
$this->assertNotNull($product->getId());
75+
$quote = $this->objectManager->create(Quote::class);
76+
$quote->setStoreId(1)
77+
->setIsActive(true)
78+
->setIsMultiShipping(false)
79+
->setReservedOrderId('test_quote')
80+
->addProduct($product, 2);
81+
$quote->collectTotals()->save();
82+
$this->assertNotNull($quote->getId());
83+
$this->assertNotEmpty($quote->getAllVisibleItems());
84+
$quoteItem = $quote->getAllVisibleItems()[0];
85+
$this->assertNotNull($quoteItem);
86+
$this->assertNotNull($quoteItem->getProduct());
87+
$this->assertEquals(2, $quoteItem->getQty());
88+
$this->assertNotNull($quoteItem->getQuote());
89+
$result = $this->subselectCondition->validate($quoteItem);
90+
$this->assertTrue($result);
91+
}
92+
}

0 commit comments

Comments
 (0)