1717use Magento \Framework \Exception \NoSuchEntityException ;
1818use Magento \Framework \Exception \StateException ;
1919use Magento \TestFramework \Helper \Bootstrap ;
20+ use Magento \Framework \App \ProductMetadataInterface ;
2021
2122/**
2223 * Check prices for single (non-complex) products
@@ -31,6 +32,7 @@ class ExportSingleProductPriceTest extends AbstractProductPriceTestHelper
3132 * @var CatalogRuleRepositoryInterface $catalogRuleRepository
3233 */
3334 private CatalogRuleRepositoryInterface $ catalogRuleRepository ;
35+ private static ?string $ version ;
3436
3537 protected function setUp (): void
3638 {
@@ -441,7 +443,7 @@ public static function expectedSimpleProductPricesWithCatalogRuleDataProvider():
441443 'customerGroupCode ' => 'b6589fc6ab0dc82cf12099d1c2d40ab994e8410c ' ,
442444 'websiteCode ' => 'base ' ,
443445 'regular ' => 55.55 ,
444- 'discounts ' => [0 => ['code ' => 'catalog_rule ' , 'price ' => 41.6625 ]],
446+ 'discounts ' => [0 => ['code ' => 'catalog_rule ' , 'price ' => self :: getPriceForVersion ( 41.6625 ) ]],
445447 'deleted ' => false
446448 ],
447449 'simple_product_with_regular_price_test_0 ' => [
@@ -470,7 +472,7 @@ public static function expectedSimpleProductPricesWithCatalogRuleDataProvider():
470472 'regular ' => 100.1 ,
471473 'discounts ' => [
472474 0 => ['code ' => 'special_price ' , 'price ' => 55.55 ],
473- 1 => ['code ' => 'catalog_rule ' , 'price ' => 75.075 ]
475+ 1 => ['code ' => 'catalog_rule ' , 'price ' => self :: getPriceForVersion ( 75.075 ) ]
474476 ],
475477 'deleted ' => false
476478 ],
@@ -500,7 +502,7 @@ public static function expectedSimpleProductPricesWithCatalogRuleDataProvider():
500502 'regular ' => 100.1 ,
501503 'discounts ' => [
502504 0 => ['code ' => 'special_price ' , 'price ' => 55.55 ],
503- 1 => ['code ' => 'catalog_rule ' , 'price ' => 75.075 ]
505+ 1 => ['code ' => 'catalog_rule ' , 'price ' => self :: getPriceForVersion ( 75.075 ) ]
504506 ],
505507 'deleted ' => false
506508 ],
@@ -530,7 +532,7 @@ public static function expectedSimpleProductPricesWithCatalogRuleDataProvider():
530532 'regular ' => 100.1 ,
531533 'discounts ' => [
532534 0 => ['code ' => 'group ' , 'price ' => 15.15 ],
533- 1 => ['code ' => 'catalog_rule ' , 'price ' => 75.075 ]
535+ 1 => ['code ' => 'catalog_rule ' , 'price ' => self :: getPriceForVersion ( 75.075 ) ]
534536 ],
535537 'deleted ' => false
536538 ],
@@ -581,7 +583,7 @@ public static function expectedSimpleProductPricesWithCatalogRuleDisabledDataPro
581583 'customerGroupCode ' => 'b6589fc6ab0dc82cf12099d1c2d40ab994e8410c ' ,
582584 'websiteCode ' => 'base ' ,
583585 'regular ' => 55.55 ,
584- 'discounts ' => [0 => ['code ' => 'catalog_rule ' , 'price ' => 41.6625 ]],
586+ 'discounts ' => [0 => ['code ' => 'catalog_rule ' , 'price ' => self :: getPriceForVersion ( 41.6625 ) ]],
585587 'deleted ' => true ,
586588 ],
587589 'simple_product_with_regular_price_test_0 ' => [
@@ -610,7 +612,7 @@ public static function expectedSimpleProductPricesWithCatalogRuleDisabledDataPro
610612 'regular ' => 100.1 ,
611613 'discounts ' => [
612614 0 => ['code ' => 'special_price ' , 'price ' => 55.55 ],
613- 1 => ['code ' => 'catalog_rule ' , 'price ' => 75.075 ]
615+ 1 => ['code ' => 'catalog_rule ' , 'price ' => self :: getPriceForVersion ( 75.075 ) ]
614616 ],
615617 'deleted ' => true
616618 ],
@@ -640,7 +642,7 @@ public static function expectedSimpleProductPricesWithCatalogRuleDisabledDataPro
640642 'regular ' => 100.1 ,
641643 'discounts ' => [
642644 0 => ['code ' => 'special_price ' , 'price ' => 55.55 ],
643- 1 => ['code ' => 'catalog_rule ' , 'price ' => 75.075 ]
645+ 1 => ['code ' => 'catalog_rule ' , 'price ' => self :: getPriceForVersion ( 75.075 ) ]
644646 ],
645647 'deleted ' => true
646648 ],
@@ -933,7 +935,7 @@ public static function expectedSimpleProductWithTierPricesAndCatalogRulesDataPro
933935 'regular ' => 100.1 ,
934936 'discounts ' => [
935937 ['code ' => 'group ' , 'percentage ' => 10 ],
936- ['code ' => 'catalog_rule ' , 'price ' => 75.075 ]
938+ ['code ' => 'catalog_rule ' , 'price ' => self :: getPriceForVersion ( 75.075 ) ]
937939 ],
938940 'tierPrices ' => [
939941 ['qty ' => 2 , 'percentage ' => 20 ],
@@ -1003,7 +1005,7 @@ public static function expectedSimpleProductWithTierPricesOnAllWebsitesAndCatalo
10031005 'regular ' => 100.1 ,
10041006 'discounts ' => [
10051007 ['code ' => 'group ' , 'percentage ' => 10 ],
1006- ['code ' => 'catalog_rule ' , 'price ' => 75.075 ]
1008+ ['code ' => 'catalog_rule ' , 'price ' => self :: getPriceForVersion ( 75.075 ) ]
10071009 ],
10081010 'tierPrices ' => [
10091011 ['qty ' => 2 , 'percentage ' => 20 ],
@@ -1063,4 +1065,10 @@ private function getRuleByName(string $name): RuleInterface
10631065
10641066 return $ this ->catalogRuleRepository ->get ((int )$ ruleId );
10651067 }
1068+
1069+ private static function getPriceForVersion (float $ price ): float
1070+ {
1071+ self ::$ version = Bootstrap::getObjectManager ()->get (ProductMetadataInterface::class)->getVersion ();
1072+ return version_compare (self ::$ version , '2.4.9-dev ' , '>= ' ) ? $ price : round ($ price , 2 );
1073+ }
10661074}
0 commit comments