Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace Magento\SalesRule\Test\Unit\Model; use Magento\Framework\DataObject; use..

Decoded Output download

<?php
  namespace Magento\SalesRule\Test\Unit\Model; use Magento\Framework\DataObject; use Magento\Framework\DataObjectFactory; use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Quote\Model\Quote; use Magento\Quote\Model\Quote\Address; use Magento\Quote\Model\Quote\Item\AbstractItem; use Magento\SalesRule\Model\Coupon; use Magento\SalesRule\Model\CouponFactory; use Magento\SalesRule\Model\ResourceModel\Coupon\Usage; use Magento\SalesRule\Model\ResourceModel\Coupon\UsageFactory; use Magento\SalesRule\Model\Rule; use Magento\SalesRule\Model\Rule\Action\Discount\Data; use Magento\SalesRule\Model\Rule\Customer; use Magento\SalesRule\Model\Rule\CustomerFactory; use Magento\SalesRule\Model\Utility; use Magento\SalesRule\Model\ValidateCoupon; use Magento\Store\Model\Store; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class UtilityTest extends TestCase { protected $usageFactory; protected $couponFactory; protected $coupon; protected $quote; protected $customerFactory; protected $customer; protected $address; protected $rule; protected $objectFactory; protected $item; protected $utility; protected $priceCurrency; protected $validateCoupon; protected function setUp() : void { $this->usageFactory = $this->createPartialMock(UsageFactory::class, array("create")); $this->couponFactory = $this->createPartialMock(CouponFactory::class, array("create")); $this->objectFactory = $this->createPartialMock(DataObjectFactory::class, array("create")); $this->customerFactory = $this->createPartialMock(CustomerFactory::class, array("create")); $this->coupon = $this->createPartialMock(Coupon::class, array("load", "getId", "getUsageLimit", "getTimesUsed", "getUsagePerCustomer")); $this->quote = $this->createPartialMock(Quote::class, array("getStore")); $this->customer = $this->createPartialMock(Customer::class, array("loadByCustomerRule")); $this->rule = $this->getMockBuilder(Rule::class)->addMethods(array("getDiscountQty"))->onlyMethods(array("hasIsValidForAddress", "getIsValidForAddress", "setIsValidForAddress", "validate", "afterLoad"))->disableOriginalConstructor()->getMock(); $this->address = $this->getMockBuilder(Address::class)->addMethods(array("setIsValidForAddress"))->onlyMethods(array("isObjectNew", "getQuote", "validate", "afterLoad"))->disableOriginalConstructor()->getMock(); $this->address->setQuote($this->quote); $this->item = $this->getMockBuilder(AbstractItem::class)->addMethods(array("getDiscountCalculationPrice", "getBaseDiscountCalculationPrice"))->onlyMethods(array("getCalculationPrice", "getBaseCalculationPrice", "getQuote", "getAddress", "getOptionByCode", "getTotalQty"))->disableOriginalConstructor()->getMockForAbstractClass(); $this->priceCurrency = $this->getMockBuilder(PriceCurrencyInterface::class)->getMock(); $this->validateCoupon = $this->createMock(ValidateCoupon::class); $this->utility = new Utility($this->usageFactory, $this->couponFactory, $this->customerFactory, $this->objectFactory, $this->priceCurrency, $this->validateCoupon); } public function testCanProcessRuleValidAddress() : void { $this->rule->expects($this->once())->method("hasIsValidForAddress")->with($this->address)->willReturn(true); $this->rule->expects($this->once())->method("getIsValidForAddress")->with($this->address)->willReturn(true); $this->address->expects($this->once())->method("isObjectNew")->willReturn(false); $this->assertTrue($this->utility->canProcessRule($this->rule, $this->address)); } public function testCanProcessRuleCouponUsageLimitFail() : void { $couponCode = 111; $quoteId = 4; $this->rule->setCouponType(Rule::COUPON_TYPE_SPECIFIC); $this->quote->setCouponCode($couponCode); $this->quote->setId($quoteId); $this->address->expects($this->once())->method("getQuote")->willReturn($this->quote); $this->validateCoupon->method("execute")->willReturn(false); $this->assertFalse($this->utility->canProcessRule($this->rule, $this->address)); } public function testCanProcessRuleCouponUsagePerCustomerFail() : void { $couponCode = 111; $quoteId = 4; $customerId = 1; $this->rule->setCouponType(Rule::COUPON_TYPE_SPECIFIC); $this->quote->setCouponCode($couponCode); $this->quote->setId($quoteId); $this->quote->setCustomerId($customerId); $this->address->expects($this->atLeastOnce())->method("getQuote")->willReturn($this->quote); $this->validateCoupon->method("execute")->willReturn(false); $this->assertFalse($this->utility->canProcessRule($this->rule, $this->address)); } public function testCanProcessRuleUsagePerCustomer() : void { $customerId = 1; $usageLimit = 1; $timesUsed = 2; $ruleId = 4; $this->rule->setId($ruleId); $this->rule->setUsesPerCustomer($usageLimit); $this->quote->setCustomerId($customerId); $this->address->expects($this->atLeastOnce())->method("getQuote")->willReturn($this->quote); $this->customer->setId($customerId); $this->customer->setTimesUsed($timesUsed); $this->customerFactory->expects($this->once())->method("create")->willReturn($this->customer); $this->validateCoupon->method("execute")->willReturn(true); $this->assertFalse($this->utility->canProcessRule($this->rule, $this->address)); } public function testCanProcessRuleInvalidConditions() : void { $this->address->expects($this->atLeastOnce())->method("getQuote")->willReturn($this->quote); $this->assertFalse($this->utility->canProcessRule($this->rule, $this->address)); } public function testCanProcessRule() : void { $this->rule->setCouponType(Rule::COUPON_TYPE_NO_COUPON); $this->rule->expects($this->once())->method("validate")->willReturn(true); $this->address->expects($this->atLeastOnce())->method("getQuote")->willReturn($this->quote); $this->validateCoupon->method("execute")->willReturn(true); $this->assertTrue($this->utility->canProcessRule($this->rule, $this->address)); } public function testGetItemPrice() : void { $price = $this->getItemPrice(); $this->assertEquals($price, $this->utility->getItemPrice($this->item)); } public function testGetItemPriceNull() : void { $price = 4; $this->item->expects($this->once())->method("getDiscountCalculationPrice")->willReturn($price); $this->item->expects($this->once())->method("getCalculationPrice")->willReturn(null); $this->assertEquals($price, $this->utility->getItemPrice($this->item)); } public function testGetItemBasePrice() : void { $price = $this->getItemBasePrice(); $this->assertEquals($price, $this->utility->getItemBasePrice($this->item)); } public function testGetBaseItemPriceCalculation() : void { $calcPrice = 5; $this->item->expects($this->once())->method("getDiscountCalculationPrice")->willReturn(null); $this->item->expects($this->any())->method("getBaseCalculationPrice")->willReturn($calcPrice); $this->assertEquals($calcPrice, $this->utility->getItemBasePrice($this->item)); } public function testGetItemQtyMin() : void { $qty = 7; $discountQty = 4; $this->item->expects($this->once())->method("getTotalQty")->willReturn($qty); $this->rule->expects($this->once())->method("getDiscountQty")->willReturn($discountQty); $this->assertEquals(min($discountQty, $qty), $this->utility->getItemQty($this->item, $this->rule)); } public function testGetItemQty() : void { $qty = 7; $this->item->expects($this->once())->method("getTotalQty")->willReturn($qty); $this->rule->expects($this->once())->method("getDiscountQty")->willReturn(null); $this->assertEquals($qty, $this->utility->getItemQty($this->item, $this->rule)); } public function testMergeIds($a1, $a2, bool $isSting, $expected) : void { $this->assertEquals($expected, $this->utility->mergeIds($a1, $a2, $isSting)); } public static function mergeIdsDataProvider() : array { return array(array("id1,id2", '', true, "id1,id2"), array("id1,id2", '', false, array("id1", "id2")), array('', "id3,id4", false, array("id3", "id4")), array('', "id3,id4", true, "id3,id4"), array(array("id1", "id2"), array("id3", "id4"), false, array("id1", "id2", "id3", "id4")), array(array("id1", "id2"), array("id3", "id4"), true, "id1,id2,id3,id4")); } public function testMinFix() : void { $qty = 13; $amount = 10; $baseAmount = 12; $fixedAmount = 20; $fixedBaseAmount = 24; $this->getItemPrice(); $this->getItemBasePrice(); $this->item->setDiscountAmount($amount); $this->item->setBaseDiscountAmount($baseAmount); $discountData = $this->createMock(Data::class); $discountData->expects($this->atLeastOnce())->method("getAmount")->willReturn($amount); $discountData->expects($this->atLeastOnce())->method("getBaseAmount")->willReturn($baseAmount); $discountData->expects($this->once())->method("setAmount")->with($fixedAmount); $discountData->expects($this->once())->method("setBaseAmount")->with($fixedBaseAmount); $this->assertNull($this->utility->minFix($discountData, $this->item, $qty)); } protected function getItemPrice() : int { $price = 4; $calcPrice = 5; $this->item->expects($this->atLeastOnce())->method("getDiscountCalculationPrice")->willReturn($price); $this->item->expects($this->once())->method("getCalculationPrice")->willReturn($calcPrice); return $price; } protected function getItemBasePrice() : int { $price = 4; $calcPrice = 5; $this->item->expects($this->atLeastOnce())->method("getDiscountCalculationPrice")->willReturn($calcPrice); $this->item->expects($this->any())->method("getBaseDiscountCalculationPrice")->willReturn($price); return $price; } public function testDeltaRoundignFix($discountAmount, $baseDiscountAmount, $percent, $rowTotal) : void { $roundedDiscount = round($discountAmount, 2); $roundedBaseDiscount = round($baseDiscountAmount, 2); $delta = $discountAmount - $roundedDiscount; $baseDelta = $baseDiscountAmount - $roundedBaseDiscount; $secondRoundedDiscount = round($discountAmount + $delta); $secondRoundedBaseDiscount = round($baseDiscountAmount + $baseDelta); $this->item->expects($this->any())->method("getQuote")->willReturn($this->quote); $store = $this->createMock(Store::class); $this->priceCurrency->expects($this->any())->method("round")->willReturnMap(array(array($discountAmount, $roundedDiscount), array($baseDiscountAmount, $roundedBaseDiscount), array($discountAmount + $delta, $secondRoundedDiscount), array($baseDiscountAmount + $baseDelta, $secondRoundedBaseDiscount))); $this->quote->expects($this->any())->method("getStore")->willReturn($store); $this->item->setDiscountPercent($percent); $this->item->setRowTotal($rowTotal); $discountData = $this->createMock(Data::class); $discountData->method("getAmount")->willReturnOnConsecutiveCalls($discountAmount, $discountAmount); $discountData->method("setBaseAmount")->willReturnCallback(function ($arg1) use($roundedBaseDiscount, $secondRoundedBaseDiscount) { if ($arg1 == $roundedBaseDiscount || $arg1 == $secondRoundedBaseDiscount) { return null; } }); $discountData->method("setAmount")->willReturnCallback(function ($arg1) use($roundedDiscount, $secondRoundedDiscount) { if ($arg1 == $roundedDiscount || $arg1 == $secondRoundedDiscount) { return null; } }); $discountData->method("getBaseAmount")->willReturnOnConsecutiveCalls($baseDiscountAmount, $baseDiscountAmount); $this->assertEquals($this->utility, $this->utility->deltaRoundingFix($discountData, $this->item)); } public static function deltaRoundingFixDataProvider() { return array(array("discountAmount" => 10.003, "baseDiscountAmount" => 12.465, "percent" => 15, "rowTotal" => 100), array("discountAmount" => 5.0015, "baseDiscountAmount" => 6.2325, "percent" => 7.5, "rowTotal" => 100)); } public function testResetRoundingDeltas() : void { $this->assertNull($this->utility->resetRoundingDeltas()); } } ?>

Did this file decode correctly?

Original Code

<?php
  namespace Magento\SalesRule\Test\Unit\Model; use Magento\Framework\DataObject; use Magento\Framework\DataObjectFactory; use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Quote\Model\Quote; use Magento\Quote\Model\Quote\Address; use Magento\Quote\Model\Quote\Item\AbstractItem; use Magento\SalesRule\Model\Coupon; use Magento\SalesRule\Model\CouponFactory; use Magento\SalesRule\Model\ResourceModel\Coupon\Usage; use Magento\SalesRule\Model\ResourceModel\Coupon\UsageFactory; use Magento\SalesRule\Model\Rule; use Magento\SalesRule\Model\Rule\Action\Discount\Data; use Magento\SalesRule\Model\Rule\Customer; use Magento\SalesRule\Model\Rule\CustomerFactory; use Magento\SalesRule\Model\Utility; use Magento\SalesRule\Model\ValidateCoupon; use Magento\Store\Model\Store; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class UtilityTest extends TestCase { protected $usageFactory; protected $couponFactory; protected $coupon; protected $quote; protected $customerFactory; protected $customer; protected $address; protected $rule; protected $objectFactory; protected $item; protected $utility; protected $priceCurrency; protected $validateCoupon; protected function setUp() : void { $this->usageFactory = $this->createPartialMock(UsageFactory::class, array("\143\162\x65\141\x74\x65")); $this->couponFactory = $this->createPartialMock(CouponFactory::class, array("\x63\162\x65\x61\x74\x65")); $this->objectFactory = $this->createPartialMock(DataObjectFactory::class, array("\x63\162\145\141\x74\145")); $this->customerFactory = $this->createPartialMock(CustomerFactory::class, array("\143\162\x65\x61\164\145")); $this->coupon = $this->createPartialMock(Coupon::class, array("\154\157\x61\144", "\147\x65\x74\x49\144", "\x67\x65\x74\125\x73\141\x67\x65\x4c\x69\x6d\x69\x74", "\147\x65\x74\124\x69\x6d\145\163\x55\x73\145\144", "\147\x65\x74\x55\163\x61\x67\x65\x50\x65\x72\103\165\x73\x74\x6f\155\145\x72")); $this->quote = $this->createPartialMock(Quote::class, array("\147\145\164\x53\x74\x6f\x72\x65")); $this->customer = $this->createPartialMock(Customer::class, array("\154\157\x61\144\x42\x79\103\x75\163\164\157\155\145\162\122\165\154\x65")); $this->rule = $this->getMockBuilder(Rule::class)->addMethods(array("\147\145\164\104\151\x73\143\157\x75\156\x74\x51\x74\171"))->onlyMethods(array("\150\x61\163\x49\163\126\x61\154\x69\144\x46\157\x72\101\x64\144\x72\145\x73\163", "\x67\x65\x74\x49\163\x56\x61\154\151\144\x46\157\x72\x41\144\144\162\145\x73\163", "\163\145\164\x49\x73\x56\141\x6c\151\144\106\157\162\x41\x64\x64\x72\x65\163\163", "\166\x61\x6c\x69\x64\x61\164\145", "\x61\146\164\x65\162\x4c\x6f\x61\144"))->disableOriginalConstructor()->getMock(); $this->address = $this->getMockBuilder(Address::class)->addMethods(array("\163\x65\164\111\x73\126\141\x6c\x69\x64\106\x6f\x72\101\144\x64\162\145\x73\x73"))->onlyMethods(array("\x69\163\x4f\142\152\145\x63\x74\116\145\167", "\147\145\164\x51\165\x6f\164\145", "\x76\x61\154\x69\144\141\164\x65", "\141\146\x74\x65\162\x4c\x6f\141\x64"))->disableOriginalConstructor()->getMock(); $this->address->setQuote($this->quote); $this->item = $this->getMockBuilder(AbstractItem::class)->addMethods(array("\147\145\x74\x44\151\x73\x63\157\165\156\164\x43\x61\154\143\x75\154\141\164\151\157\x6e\x50\x72\x69\143\145", "\x67\x65\x74\x42\x61\x73\145\104\151\163\x63\157\x75\156\x74\x43\141\x6c\143\165\x6c\x61\x74\x69\157\x6e\120\162\x69\143\x65"))->onlyMethods(array("\147\145\164\103\141\154\143\165\x6c\141\x74\x69\157\x6e\x50\x72\x69\143\145", "\x67\x65\164\102\141\x73\145\103\x61\154\x63\165\x6c\141\164\x69\157\156\x50\162\x69\143\x65", "\147\x65\164\121\165\157\164\x65", "\147\x65\164\101\144\144\162\145\163\163", "\147\x65\x74\x4f\x70\164\151\x6f\156\102\x79\x43\x6f\x64\145", "\x67\145\164\x54\157\164\x61\x6c\121\x74\171"))->disableOriginalConstructor()->getMockForAbstractClass(); $this->priceCurrency = $this->getMockBuilder(PriceCurrencyInterface::class)->getMock(); $this->validateCoupon = $this->createMock(ValidateCoupon::class); $this->utility = new Utility($this->usageFactory, $this->couponFactory, $this->customerFactory, $this->objectFactory, $this->priceCurrency, $this->validateCoupon); } public function testCanProcessRuleValidAddress() : void { $this->rule->expects($this->once())->method("\x68\141\163\x49\163\126\x61\x6c\151\x64\106\x6f\x72\101\144\x64\x72\x65\x73\x73")->with($this->address)->willReturn(true); $this->rule->expects($this->once())->method("\147\145\x74\111\163\126\141\x6c\x69\x64\x46\x6f\162\x41\x64\x64\162\145\x73\x73")->with($this->address)->willReturn(true); $this->address->expects($this->once())->method("\151\163\x4f\142\x6a\145\143\x74\116\x65\x77")->willReturn(false); $this->assertTrue($this->utility->canProcessRule($this->rule, $this->address)); } public function testCanProcessRuleCouponUsageLimitFail() : void { $couponCode = 111; $quoteId = 4; $this->rule->setCouponType(Rule::COUPON_TYPE_SPECIFIC); $this->quote->setCouponCode($couponCode); $this->quote->setId($quoteId); $this->address->expects($this->once())->method("\147\x65\x74\121\165\157\164\x65")->willReturn($this->quote); $this->validateCoupon->method("\145\x78\145\x63\165\x74\145")->willReturn(false); $this->assertFalse($this->utility->canProcessRule($this->rule, $this->address)); } public function testCanProcessRuleCouponUsagePerCustomerFail() : void { $couponCode = 111; $quoteId = 4; $customerId = 1; $this->rule->setCouponType(Rule::COUPON_TYPE_SPECIFIC); $this->quote->setCouponCode($couponCode); $this->quote->setId($quoteId); $this->quote->setCustomerId($customerId); $this->address->expects($this->atLeastOnce())->method("\147\145\x74\121\x75\x6f\x74\x65")->willReturn($this->quote); $this->validateCoupon->method("\145\170\145\x63\x75\164\x65")->willReturn(false); $this->assertFalse($this->utility->canProcessRule($this->rule, $this->address)); } public function testCanProcessRuleUsagePerCustomer() : void { $customerId = 1; $usageLimit = 1; $timesUsed = 2; $ruleId = 4; $this->rule->setId($ruleId); $this->rule->setUsesPerCustomer($usageLimit); $this->quote->setCustomerId($customerId); $this->address->expects($this->atLeastOnce())->method("\147\x65\164\121\165\157\164\145")->willReturn($this->quote); $this->customer->setId($customerId); $this->customer->setTimesUsed($timesUsed); $this->customerFactory->expects($this->once())->method("\143\x72\145\141\164\145")->willReturn($this->customer); $this->validateCoupon->method("\145\170\145\x63\x75\x74\x65")->willReturn(true); $this->assertFalse($this->utility->canProcessRule($this->rule, $this->address)); } public function testCanProcessRuleInvalidConditions() : void { $this->address->expects($this->atLeastOnce())->method("\x67\x65\164\x51\165\x6f\164\x65")->willReturn($this->quote); $this->assertFalse($this->utility->canProcessRule($this->rule, $this->address)); } public function testCanProcessRule() : void { $this->rule->setCouponType(Rule::COUPON_TYPE_NO_COUPON); $this->rule->expects($this->once())->method("\x76\141\x6c\x69\x64\x61\x74\145")->willReturn(true); $this->address->expects($this->atLeastOnce())->method("\x67\145\x74\121\165\x6f\x74\145")->willReturn($this->quote); $this->validateCoupon->method("\145\x78\145\x63\165\164\x65")->willReturn(true); $this->assertTrue($this->utility->canProcessRule($this->rule, $this->address)); } public function testGetItemPrice() : void { $price = $this->getItemPrice(); $this->assertEquals($price, $this->utility->getItemPrice($this->item)); } public function testGetItemPriceNull() : void { $price = 4; $this->item->expects($this->once())->method("\x67\145\164\104\151\x73\x63\157\165\x6e\164\x43\141\x6c\143\165\154\141\164\x69\x6f\156\120\162\x69\143\x65")->willReturn($price); $this->item->expects($this->once())->method("\147\145\x74\103\141\154\143\165\154\x61\x74\151\157\x6e\x50\162\151\143\145")->willReturn(null); $this->assertEquals($price, $this->utility->getItemPrice($this->item)); } public function testGetItemBasePrice() : void { $price = $this->getItemBasePrice(); $this->assertEquals($price, $this->utility->getItemBasePrice($this->item)); } public function testGetBaseItemPriceCalculation() : void { $calcPrice = 5; $this->item->expects($this->once())->method("\x67\x65\164\104\x69\x73\143\x6f\x75\156\164\103\x61\x6c\143\165\154\141\164\x69\x6f\x6e\120\x72\151\x63\145")->willReturn(null); $this->item->expects($this->any())->method("\x67\145\x74\x42\x61\163\x65\103\x61\x6c\x63\165\x6c\141\x74\x69\157\156\120\x72\x69\143\x65")->willReturn($calcPrice); $this->assertEquals($calcPrice, $this->utility->getItemBasePrice($this->item)); } public function testGetItemQtyMin() : void { $qty = 7; $discountQty = 4; $this->item->expects($this->once())->method("\x67\x65\164\124\x6f\164\x61\x6c\x51\x74\x79")->willReturn($qty); $this->rule->expects($this->once())->method("\x67\x65\164\104\x69\163\x63\157\165\156\x74\121\x74\171")->willReturn($discountQty); $this->assertEquals(min($discountQty, $qty), $this->utility->getItemQty($this->item, $this->rule)); } public function testGetItemQty() : void { $qty = 7; $this->item->expects($this->once())->method("\147\145\x74\x54\157\164\141\x6c\x51\x74\171")->willReturn($qty); $this->rule->expects($this->once())->method("\147\x65\x74\104\151\x73\143\x6f\x75\156\164\121\164\171")->willReturn(null); $this->assertEquals($qty, $this->utility->getItemQty($this->item, $this->rule)); } public function testMergeIds($a1, $a2, bool $isSting, $expected) : void { $this->assertEquals($expected, $this->utility->mergeIds($a1, $a2, $isSting)); } public static function mergeIdsDataProvider() : array { return array(array("\x69\144\x31\x2c\151\144\62", '', true, "\151\x64\x31\x2c\151\144\x32"), array("\x69\144\x31\54\x69\x64\62", '', false, array("\x69\144\61", "\151\x64\x32")), array('', "\151\x64\63\54\151\x64\64", false, array("\x69\144\x33", "\151\144\x34")), array('', "\151\x64\x33\54\x69\144\x34", true, "\x69\x64\63\54\151\144\x34"), array(array("\x69\x64\x31", "\x69\144\62"), array("\x69\144\63", "\x69\144\x34"), false, array("\151\x64\61", "\x69\144\x32", "\x69\144\x33", "\x69\x64\x34")), array(array("\151\x64\x31", "\x69\144\62"), array("\x69\x64\63", "\x69\x64\x34"), true, "\151\144\61\54\x69\144\x32\x2c\151\x64\x33\x2c\x69\144\x34")); } public function testMinFix() : void { $qty = 13; $amount = 10; $baseAmount = 12; $fixedAmount = 20; $fixedBaseAmount = 24; $this->getItemPrice(); $this->getItemBasePrice(); $this->item->setDiscountAmount($amount); $this->item->setBaseDiscountAmount($baseAmount); $discountData = $this->createMock(Data::class); $discountData->expects($this->atLeastOnce())->method("\147\x65\x74\101\x6d\157\x75\x6e\x74")->willReturn($amount); $discountData->expects($this->atLeastOnce())->method("\147\x65\164\102\x61\x73\145\101\155\157\165\156\164")->willReturn($baseAmount); $discountData->expects($this->once())->method("\x73\145\x74\101\155\x6f\165\x6e\164")->with($fixedAmount); $discountData->expects($this->once())->method("\163\x65\x74\x42\141\163\145\101\155\x6f\165\156\164")->with($fixedBaseAmount); $this->assertNull($this->utility->minFix($discountData, $this->item, $qty)); } protected function getItemPrice() : int { $price = 4; $calcPrice = 5; $this->item->expects($this->atLeastOnce())->method("\x67\x65\164\x44\x69\163\143\157\x75\x6e\164\x43\141\154\x63\x75\154\141\164\x69\x6f\x6e\120\162\x69\143\x65")->willReturn($price); $this->item->expects($this->once())->method("\x67\x65\x74\103\141\154\x63\165\154\141\x74\x69\157\156\120\162\x69\143\145")->willReturn($calcPrice); return $price; } protected function getItemBasePrice() : int { $price = 4; $calcPrice = 5; $this->item->expects($this->atLeastOnce())->method("\147\x65\x74\104\151\x73\143\157\165\x6e\x74\103\141\x6c\143\165\154\141\164\151\157\156\x50\x72\x69\x63\145")->willReturn($calcPrice); $this->item->expects($this->any())->method("\x67\x65\164\102\141\163\x65\104\151\163\x63\x6f\165\x6e\164\x43\x61\154\x63\x75\154\x61\164\151\x6f\156\120\162\151\143\x65")->willReturn($price); return $price; } public function testDeltaRoundignFix($discountAmount, $baseDiscountAmount, $percent, $rowTotal) : void { $roundedDiscount = round($discountAmount, 2); $roundedBaseDiscount = round($baseDiscountAmount, 2); $delta = $discountAmount - $roundedDiscount; $baseDelta = $baseDiscountAmount - $roundedBaseDiscount; $secondRoundedDiscount = round($discountAmount + $delta); $secondRoundedBaseDiscount = round($baseDiscountAmount + $baseDelta); $this->item->expects($this->any())->method("\x67\145\164\121\165\x6f\164\x65")->willReturn($this->quote); $store = $this->createMock(Store::class); $this->priceCurrency->expects($this->any())->method("\162\157\165\156\144")->willReturnMap(array(array($discountAmount, $roundedDiscount), array($baseDiscountAmount, $roundedBaseDiscount), array($discountAmount + $delta, $secondRoundedDiscount), array($baseDiscountAmount + $baseDelta, $secondRoundedBaseDiscount))); $this->quote->expects($this->any())->method("\147\x65\x74\123\x74\157\162\145")->willReturn($store); $this->item->setDiscountPercent($percent); $this->item->setRowTotal($rowTotal); $discountData = $this->createMock(Data::class); $discountData->method("\147\145\x74\x41\x6d\157\165\x6e\164")->willReturnOnConsecutiveCalls($discountAmount, $discountAmount); $discountData->method("\163\145\164\102\141\163\145\101\155\157\x75\x6e\x74")->willReturnCallback(function ($arg1) use($roundedBaseDiscount, $secondRoundedBaseDiscount) { if ($arg1 == $roundedBaseDiscount || $arg1 == $secondRoundedBaseDiscount) { return null; } }); $discountData->method("\163\145\x74\101\155\157\x75\x6e\x74")->willReturnCallback(function ($arg1) use($roundedDiscount, $secondRoundedDiscount) { if ($arg1 == $roundedDiscount || $arg1 == $secondRoundedDiscount) { return null; } }); $discountData->method("\x67\145\164\x42\141\163\145\101\x6d\x6f\x75\x6e\x74")->willReturnOnConsecutiveCalls($baseDiscountAmount, $baseDiscountAmount); $this->assertEquals($this->utility, $this->utility->deltaRoundingFix($discountData, $this->item)); } public static function deltaRoundingFixDataProvider() { return array(array("\x64\x69\x73\x63\157\165\156\x74\101\155\157\x75\156\164" => 10.003, "\x62\141\163\145\104\151\x73\143\x6f\165\x6e\164\x41\155\157\165\x6e\x74" => 12.465, "\x70\x65\162\x63\x65\156\164" => 15, "\162\157\167\x54\x6f\x74\x61\x6c" => 100), array("\x64\x69\x73\143\x6f\165\x6e\164\x41\x6d\x6f\165\156\164" => 5.0015, "\x62\x61\x73\145\104\x69\163\x63\157\x75\156\x74\x41\x6d\x6f\165\156\164" => 6.2325, "\160\x65\x72\x63\145\x6e\x74" => 7.5, "\162\157\x77\124\x6f\164\141\154" => 100)); } public function testResetRoundingDeltas() : void { $this->assertNull($this->utility->resetRoundingDeltas()); } }

Function Calls

None

Variables

None

Stats

MD5 3fce9d1cca3c84d376cdc8afce2c8da2
Eval Count 0
Decode Time 120 ms