public function testCurrencyDisplayOptions() { $sampleCurrencyOptionObject = new \Magento\Framework\DataObject(); $sampleCurrency = 'USD'; $sampleCurrencySymbol = '$'; $expectedCurrencyOptions = [\Magento\Framework\Locale\Currency::CURRENCY_OPTION_SYMBOL => $sampleCurrencySymbol, \Magento\Framework\Locale\Currency::CURRENCY_OPTION_DISPLAY => \Magento\Framework\Currency::USE_SYMBOL]; //Return invalid value $this->mockEvent->expects($this->once())->method('getBaseCode')->willReturn($sampleCurrency); $this->mockEvent->expects($this->once())->method('getCurrencyOptions')->willReturn($sampleCurrencyOptionObject); $this->mockSymbol->expects($this->once())->method('getCurrencySymbol')->with($sampleCurrency)->willReturn($sampleCurrencySymbol); $this->observer->execute($this->mockEventObserver); // Check if option set is empty $this->assertEquals($expectedCurrencyOptions, $sampleCurrencyOptionObject->getData()); }
public function testExecute() { $firstElement = 'firstElement'; $symbolsDataArray = [$firstElement]; $redirectUrl = 'redirectUrl'; $this->requestMock->expects($this->once())->method('getParam')->with('custom_currency_symbol')->willReturn($symbolsDataArray); $this->helperMock->expects($this->once())->method('getUrl')->with('*'); $this->redirectMock->expects($this->once())->method('getRedirectUrl')->willReturn($redirectUrl); $this->currencySymbolMock->expects($this->once())->method('setCurrencySymbolsData')->with($symbolsDataArray); $this->responseMock->expects($this->once())->method('setRedirect'); $this->filterManagerMock->expects($this->once())->method('stripTags')->with($firstElement)->willReturn($firstElement); $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\CurrencySymbol\\Model\\System\\Currencysymbol')->willReturn($this->currencySymbolMock); $this->objectManagerMock->expects($this->once())->method('get')->with('Magento\\Framework\\Filter\\FilterManager')->willReturn($this->filterManagerMock); $this->messageManagerMock->expects($this->once())->method('addSuccess')->with(__('You applied the custom currency symbols.')); $this->action->execute(); }
public function testGetCurrencySymbolNonExistent() { $this->assertFalse($this->currencySymbolModel->getCurrencySymbol('AUD')); }
/** * @dataProvider getCurrencySymbolDataProvider */ public function testGetCurrencySymbol($code, $expectedSymbol, $serializedCustomSymbols) { $this->scopeConfigMock->expects($this->any())->method('getValue')->willReturnMap([[CurrencySymbol::XML_PATH_CUSTOM_CURRENCY_SYMBOL, ScopeInterface::SCOPE_STORE, null, $serializedCustomSymbols]]); $currencySymbol = $this->model->getCurrencySymbol($code); $this->assertEquals($expectedSymbol, $currencySymbol); }