コード例 #1
0
 /**
  * @covers ::processPluginOptions
  */
 public function testProcessPluginOptions()
 {
     $element = array();
     $definitions = array('foo' => array('description' => $this->randomMachineName()), 'bar' => array('description' => $this->randomMachineName()), 'baz' => array());
     $this->currencyAmountFormatterManager->expects($this->once())->method('getDefinitions')->willReturn($definitions);
     $expected = array('foo' => array('#description' => $definitions['foo']['description']), 'bar' => array('#description' => $definitions['bar']['description']));
     $this->assertSame($expected, $this->controller->processPluginOptions($element));
 }
コード例 #2
0
 /**
  * @covers ::formatAmount
  * @covers ::getCurrencyAmountFormatterManager
  *
  * @depends testGetRoundingStep
  *
  * @dataProvider providerTestFormatAmount
  */
 function testFormatAmount($expected, $amount, $amount_with_currency_precision_applied)
 {
     $amount_formatter = $this->getMock(AmountFormatterInterface::class);
     $amount_formatter->expects($this->atLeastOnce())->method('formatAmount')->with($this->sut, $amount_with_currency_precision_applied)->willReturn($expected);
     $this->currencyAmountFormatterManager->expects($this->atLeastOnce())->method('getDefaultPlugin')->willReturn($amount_formatter);
     $this->sut->setCurrencyCode('BLA');
     $this->sut->setSubunits(100);
     $this->assertSame($expected, $this->sut->formatAmount($amount, $amount !== $amount_with_currency_precision_applied));
 }
コード例 #3
0
 /**
  * @covers ::overview
  */
 public function testOverview()
 {
     $currency_code_from = 'EUR';
     $currency_code_to = 'NLG';
     $rate = '2.20371';
     $currency_from = $this->getMock(CurrencyInterface::class);
     $currency_from->expects($this->once())->method('label');
     $currency_to = $this->getMock(CurrencyInterface::class);
     $currency_to->expects($this->once())->method('label');
     $map = array(array($currency_code_from, $currency_from), array($currency_code_to, $currency_to));
     $this->currencyStorage->expects($this->any())->method('load')->willReturnMap($map);
     $rates_configuration = array($currency_code_from => array($currency_code_to => $rate));
     $fixed_rates = $this->getMockBuilder(FixedRates::class)->disableOriginalConstructor()->getMock();
     $fixed_rates->expects($this->once())->method('loadAll')->willReturn($rates_configuration);
     $this->currencyExchangeRateProviderManager->expects($this->once())->method('createInstance')->with('currency_fixed_rates')->willReturn($fixed_rates);
     $this->urlGenerator->expects($this->once())->method('generateFromRoute')->with('currency.exchange_rate_provider.fixed_rates.add');
     $amount_formatter = $this->getMock(AmountFormatterInterface::class);
     $amount_formatter->expects($this->once())->method('formatAmount')->with($currency_to, $rate);
     $this->currencyAmountFormatterManager->expects($this->once())->method('getDefaultPlugin')->willReturn($amount_formatter);
     $build = $this->sut->overview();
     $this->assertInternalType('array', $build);
 }