/** * Test for aroundConverterRound (ceil) * * @return void */ public function testAroundConvertRoundCeil() { $this->helper->expects($this->atLeastOnce())->method('getRoundMethod')->willReturn('ceil'); $currency = $this->getMockBuilder('Magento\\Directory\\Model\\Currency')->disableOriginalConstructor()->getMock(); $currency->expects($this->atLeastOnce())->method('getCode')->willReturn('JPY'); $this->priceCurrency->expects($this->atLeastOnce())->method('getCurrency')->willReturn($currency); $this->assertEquals(101, $this->priceRoundPlugin->aroundConvertAndRound($this->priceCurrency, $this->closure, 100.49, [], null, 'JPY', 2)); }
/** * Modify rounding method * * @param PriceCurrency $subject Price Currency * @param \Closure $proceed Closure * @param float $amount Price * @param int $precision Currency precision * * @return mixed */ public function aroundRound(PriceCurrency $subject, \Closure $proceed, $amount, $precision = 2) { if ($subject->getCurrency()->getCode() == 'JPY') { /** * Rounding method * * @var string $method rounding method */ $method = $this->helper->getRoundMethod(); if ($method != 'round') { return $method($amount); } } return $proceed($amount, $precision); }