Skip to content

Commit c3fc0a7

Browse files
author
Roman Lytvynenko
committed
Merge branch 'MC-29865' of https://github.com/magento-tango/magento2ce into PR-01-02-2020
2 parents 8d879fd + 11ba7ed commit c3fc0a7

File tree

2 files changed

+21
-10
lines changed
  • app/code/Magento/Catalog/Model/Product/Type
  • dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Type

2 files changed

+21
-10
lines changed

app/code/Magento/Catalog/Model/Product/Type/Price.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ protected function _applyTierPrice($product, $qty, $finalPrice)
262262

263263
$tierPrice = $product->getTierPrice($qty);
264264
if (is_numeric($tierPrice)) {
265-
$finalPrice = min($finalPrice, $tierPrice);
265+
$finalPrice = min($finalPrice, (float) $tierPrice);
266266
}
267267
return $finalPrice;
268268
}
@@ -645,7 +645,7 @@ public function calculateSpecialPrice(
645645
) {
646646
if ($specialPrice !== null && $specialPrice != false) {
647647
if ($this->_localeDate->isScopeDateInInterval($store, $specialPriceFrom, $specialPriceTo)) {
648-
$finalPrice = min($finalPrice, $specialPrice);
648+
$finalPrice = min($finalPrice, (float) $specialPrice);
649649
}
650650
}
651651
return $finalPrice;

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Type/PriceTest.php

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,19 @@ public function testTierPriceWithDifferentCustomerGroups(): void
111111
*/
112112
public function testGetPrice(): void
113113
{
114-
$objectWithPrice = $this->objectManager->create(DataObject::class, ['data' => ['price' => 'test']]);
115-
$this->assertEquals('test', $this->productPrice->getPrice($objectWithPrice));
114+
$objectWithPrice = $this->objectManager->create(DataObject::class, ['data' => ['price' => 9.0]]);
115+
$this->assertEquals(9.0, $this->productPrice->getPrice($objectWithPrice));
116+
}
117+
118+
/**
119+
* Get base price from product.
120+
*
121+
* @return void
122+
*/
123+
public function testGetBasePrice(): void
124+
{
125+
$product = $this->productRepository->get('simple');
126+
$this->assertSame(10.0, $this->productPrice->getBasePrice($product));
116127
}
117128

118129
/**
@@ -175,13 +186,13 @@ public function testCalculatePrice(): void
175186
*/
176187
public function testCalculateSpecialPrice(): void
177188
{
178-
$this->assertEquals(
179-
10,
180-
$this->productPrice->calculateSpecialPrice(10, 8, '1970-12-12 23:59:59', '1971-01-01 01:01:01')
189+
$this->assertSame(
190+
10.0,
191+
$this->productPrice->calculateSpecialPrice(10.0, 8.0, '1970-12-12 23:59:59', '1971-01-01 01:01:01')
181192
);
182-
$this->assertEquals(
183-
8,
184-
$this->productPrice->calculateSpecialPrice(10, 8, '1970-12-12 23:59:59', '2034-01-01 01:01:01')
193+
$this->assertSame(
194+
8.0,
195+
$this->productPrice->calculateSpecialPrice(10.0, 8.0, '1970-12-12 23:59:59', '2034-01-01 01:01:01')
185196
);
186197
}
187198

0 commit comments

Comments
 (0)