/** * Test for aroundFormat to others * * @return void */ public function testNonJpyAroundFormat() { $currency = $this->getMockBuilder('Magento\\Directory\\Model\\Currency')->disableOriginalConstructor()->getMock(); $currency->expects($this->atLeastOnce())->method('getCode')->willReturn('USD'); $this->priceCurrency->expects($this->atLeastOnce())->method('getCurrency')->willReturn($currency); $this->assertNotEquals('<span class="price">¥100</span>', $this->formatPlugin->aroundFormat($this->priceCurrency, $this->closure, 100.49, 2, null, null)); }
/** * Modify Currency Format * * @param PriceCurrency $subject Price Currency Object * @param \Closure $proceed Closure * @param float $amount Price Amount * @param bool $includeContainer Include Container Flag * @param int $precision Precision digits * @param null $scope Data scope * @param null $currency Currency Code * * @return mixed */ public function aroundFormat(PriceCurrency $subject, \Closure $proceed, $amount, $includeContainer = true, $precision = \Magento\Directory\Model\PriceCurrency::DEFAULT_PRECISION, $scope = null, $currency = null) { if ($subject->getCurrency()->getCode() == 'JPY') { $precision = '0'; return $subject->getCurrency($scope, $currency)->formatPrecision($amount, $precision, [], $includeContainer); } return $proceed($amount, $includeContainer, $precision, $scope, $currency); }
/** * 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)); }
public function testConvertAndRound() { $amount = 5.6; $storeCode = 2; $convertedAmount = 9.326000000000001; $roundedConvertedAmount = 9.33; $currency = $this->getCurrentCurrencyMock(); $baseCurrency = $this->getBaseCurrencyMock($amount, $convertedAmount, $currency); $store = $this->getStoreMock($baseCurrency); $this->storeManager->expects($this->once())->method('getStore')->with($storeCode)->will($this->returnValue($store)); $this->assertEquals($roundedConvertedAmount, $this->priceCurrency->convertAndRound($amount, $storeCode, $currency)); }
/** * 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); }
/** * Test for method renderWeeeTaxAttributeWithTax * * @param \Magento\Framework\DataObject $attribute * @param string $expectedResult * @dataProvider renderWeeeTaxAttributeAmountWithTaxDataProvider */ public function testRenderWeeeTaxAttributeWithTax($attribute, $expectedResult) { $this->priceCurrencyMock->expects($this->any())->method('convertAndFormat')->will($this->returnArgument(0)); $result = $this->model->renderWeeeTaxAttributeWithTax($attribute); $this->assertEquals($expectedResult, $result); }