/** * Stores random exchange rates in the mocked config and returns them. * * @return array * An array of the same format as the return value of * \Drupal\currency\Plugin\Currency\ExchangeRateProvider\FixedRates::loadAll(). */ protected function prepareExchangeRates() { $rates = array('EUR' => array('DEM' => '1.95583', 'NLG' => '2.20371'), 'NLG' => array('EUR' => '0.453780216')); $rates_data = array(); foreach ($rates as $currency_code_from => $currency_code_from_rates) { foreach ($currency_code_from_rates as $currency_code_to => $rate) { $rates_data[] = array('currency_code_from' => $currency_code_from, 'currency_code_to' => $currency_code_to, 'rate' => $rate); } } $this->config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); $this->config->expects($this->any())->method('get')->with('rates')->willReturn($rates_data); $this->configFactory->expects($this->any())->method('get')->with('currency.exchanger.fixed_rates')->willReturn($this->config); $this->configFactory->expects($this->any())->method('getEditable')->with('currency.exchanger.fixed_rates')->willReturn($this->config); return array($rates, $rates_data); }