![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/vendor/magento/module-catalog-rule/Test/Unit/Helper/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\CatalogRule\Test\Unit\Helper; use Magento\CatalogRule\Helper\Data; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use PHPUnit\Framework\TestCase; class DataTest extends TestCase { /** * Helper object * * @var \Magento\CatalogRule\Helper\Data */ protected $helper; protected function setUp(): void { $this->helper = (new ObjectManager($this))->getObject(Data::class); } /** * Test price rule calculation * * @param string $actionOperator * @param int|float $ruleAmount * @param int|float $price * @param int|float $expectedAmount * * @dataProvider calcPriceRuleDataProvider */ public function testCalcPriceRule($actionOperator, $ruleAmount, $price, $expectedAmount) { $this->assertEquals($expectedAmount, $this->helper->calcPriceRule($actionOperator, $ruleAmount, $price)); } /** * Data provider for cal price rule test * * @return array */ public function calcPriceRuleDataProvider() { return [ ['to_fixed', 10, 10, 10], ['to_fixed', 0, 10, 0], ['to_fixed', 10, 0, 0], ['to_fixed', 0, 0, 0], ['to_percent', 100, 100, 100], ['to_percent', 10, 100, 10], ['to_percent', 10, 70, 7], ['to_percent', 100, 10, 10], ['by_fixed', 100, 100, 0], ['by_fixed', 10, 100, 90], ['by_fixed', 100, 10, 0], ['by_percent', 100, 100, 0], ['by_percent', 100, 10, 0], ['by_percent', 100, 1, 0], ['by_percent', 10, 100, 90], ['by_percent', 10, 10, 9], ['by_percent', 1, 10, 9.90], ]; } }