8 use Magento\CurrencySymbol\Model\System\CurrencysymbolFactory;
23 private $mockSymbolFactory;
33 private $mockEventObserver;
42 $this->mockSymbolFactory = $this->createPartialMock(
43 \
Magento\CurrencySymbol\Model\System\CurrencysymbolFactory::class,
47 $this->mockSymbol = $this->createPartialMock(
48 \
Magento\CurrencySymbol\Model\System\Currencysymbol::class,
52 $this->mockEventObserver = $this->createPartialMock(\
Magento\Framework\Event\Observer::class, [
'getEvent']);
54 $this->mockEvent = $this->createPartialMock(
55 \
Magento\Framework\Event::class,
56 [
'getBaseCode',
'getCurrencyOptions']
59 $this->mockEventObserver->expects($this->any())->method(
'getEvent')->willReturn($this->mockEvent);
60 $this->mockSymbolFactory->expects($this->any())->method(
'create')->willReturn($this->mockSymbol);
62 $this->observer = new \Magento\CurrencySymbol\Observer\CurrencyDisplayOptions($this->mockSymbolFactory);
70 $sampleCurrencyOptionObject = new \Magento\Framework\DataObject($baseData);
73 $this->mockEvent->expects($this->once())->method(
'getBaseCode')->willReturn(
null);
74 $this->mockEvent->expects($this->once())->method(
'getCurrencyOptions')->willReturn($sampleCurrencyOptionObject);
75 $this->mockSymbol->expects($this->never())->method(
'getCurrencySymbol')->with(
null)->willReturn(
null);
77 $this->observer->execute($this->mockEventObserver);
80 $this->assertEquals($baseData, $sampleCurrencyOptionObject->getData());
88 $sampleCurrencyOptionObject = new \Magento\Framework\DataObject($baseData);
89 $sampleCurrency =
'USD';
90 $sampleCurrencySymbol =
'$';
92 $expectedCurrencyOptions = array_merge(
95 \
Magento\Framework\Locale\Currency::CURRENCY_OPTION_NAME =>
'US Dollar',
96 \
Magento\Framework\Locale\Currency::CURRENCY_OPTION_SYMBOL => $sampleCurrencySymbol,
97 \
Magento\Framework\Locale\Currency::CURRENCY_OPTION_DISPLAY => \
Magento\Framework\Currency::USE_SYMBOL
101 $this->mockEvent->expects($this->once())->method(
'getBaseCode')->willReturn($sampleCurrency);
102 $this->mockEvent->expects($this->once())->method(
'getCurrencyOptions')->willReturn($sampleCurrencyOptionObject);
103 $this->mockSymbol->expects($this->once())
104 ->method(
'getCurrencySymbol')
105 ->with($sampleCurrency)
106 ->willReturn($sampleCurrencySymbol);
108 $this->observer->execute($this->mockEventObserver);
110 $this->assertEquals($expectedCurrencyOptions, $sampleCurrencyOptionObject->getData());
const CURRENCY_OPTION_NAME
testCurrencyDisplayOptionsEmpty()
testCurrencyDisplayOptions()