Skip to content

Commit 7f993de

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

File tree

2 files changed

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

2 files changed

+27
-26
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|mixed
211+
* @return float
212212
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
213213
*/
214-
private function getBaseRowTotalForChildrenProduct(mixed $item, mixed $attr, float $total): mixed
214+
private function getBaseRowTotalForChildrenProduct(mixed $item, mixed $attr, float $total): float
215215
{
216216
$hasValidChild = false;
217217
$useChildrenTotal = ($item->getProductType() == Type::TYPE_BUNDLE);

dev/tests/integration/testsuite/Magento/SalesRule/Model/Rule/Condition/Product/SubselectTest.php

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,22 @@
77

88
namespace Magento\SalesRule\Model\Rule\Condition\Product;
99

10+
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
11+
use Magento\Customer\Test\Fixture\Customer;
1012
use Magento\Framework\ObjectManagerInterface;
11-
use Magento\Quote\Model\Quote;
13+
use Magento\Quote\Test\Fixture\AddProductToCart;
14+
use Magento\Quote\Test\Fixture\CustomerCart;
15+
use Magento\TestFramework\Fixture\DataFixture;
16+
use Magento\Catalog\Api\ProductRepositoryInterface;
1217
use Magento\SalesRule\Model\Rule\Condition\Product as SalesRuleProduct;
18+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
1319
use Magento\TestFramework\Helper\Bootstrap;
1420
use PHPUnit\Framework\TestCase;
1521

1622
/**
1723
* Integration test for Subselect::validate() method returning true.
1824
*
1925
* @magentoAppArea frontend
20-
* @magentoDbIsolation enabled
2126
*/
2227
class SubselectTest extends TestCase
2328
{
@@ -32,28 +37,31 @@ class SubselectTest extends TestCase
3237
private $subselectCondition;
3338

3439
/**
35-
* @var SalesRuleProduct
40+
* @var \Magento\Catalog\Api\ProductRepositoryInterface
3641
*/
37-
private $productCondition;
42+
protected $productRepository;
3843

3944
protected function setUp(): void
4045
{
4146
$this->objectManager = Bootstrap::getObjectManager();
42-
$this->productCondition = $this->objectManager->create(SalesRuleProduct::class);
43-
$this->subselectCondition = $this->objectManager->create(
44-
Subselect::class,
45-
[
46-
'context' => $this->objectManager->get(\Magento\Rule\Model\Condition\Context::class),
47-
'ruleConditionProduct' => $this->productCondition
48-
]
49-
);
47+
$this->subselectCondition = $this->objectManager->create(Subselect::class);
48+
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
5049
}
5150

5251
/**
5352
* Test validate() method returning true for total quantity >= 2 with single shipping.
5453
*
55-
* @magentoDataFixture Magento/Catalog/_files/products.php
5654
*/
55+
#[
56+
DataFixture(Customer::class, as: 'customer'),
57+
DataFixture(CustomerCart::class, ['customer_id' => '$customer.id$'], 'quote'),
58+
DataFixture(ProductFixture::class, ['sku' => 'simple1', 'price' => 100.50], as: 'product'),
59+
DataFixture(
60+
AddProductToCart::class,
61+
['cart_id' => '$quote.id$', 'product_id' => '$product.id$', 'qty' => 2],
62+
'item'
63+
),
64+
]
5765
public function testValidateReturnsTrueForSufficientQuantity()
5866
{
5967
$this->subselectCondition->setData([
@@ -66,20 +74,13 @@ public function testValidateReturnsTrueForSufficientQuantity()
6674
$productCondition->setData([
6775
'attribute' => 'sku',
6876
'operator' => '==',
69-
'value' => 'simple',
77+
'value' => 'simple1',
7078
]);
7179
$this->subselectCondition->setConditions([$productCondition]);
72-
$productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
73-
$product = $productRepository->get('simple');
74-
$product->setPrice(100.50);
80+
$product = $this->productRepository->get('simple1');
7581
$this->assertNotNull($product->getId());
76-
$quote = $this->objectManager->create(Quote::class);
77-
$quote->setStoreId(1)
78-
->setIsActive(true)
79-
->setIsMultiShipping(false)
80-
->setReservedOrderId('test_quote')
81-
->addProduct($product, 2);
82-
$quote->collectTotals()->save();
82+
$quote = DataFixtureStorageManager::getStorage()->get('quote');
83+
$quote->setStoreId(1)->setIsActive(true)->setIsMultiShipping(false);
8384
$this->assertNotNull($quote->getId());
8485
$this->assertNotEmpty($quote->getAllVisibleItems());
8586
$quoteItem = $quote->getAllVisibleItems()[0];

0 commit comments

Comments
 (0)